# Gargoyle Glk -- a pretty glk library

SubDir TOP garglk ;
ObjDir garglk ;

SubDirCcFlags $(GARGLKCCFLAGS) ;

SubDirCcFlags -DGARGLKINI=\\\"$(GARGLKINI)\\\" ;
SubDirCcFlags -DGARGLKPRE=\\\"$(GARGLKPRE)\\\" ;

# SubDirCcFlags -DGARGLK_PROFILE_TIME ;

if $(OS) = MINGW
{
    SubDirHdrs $(TOP) support freetype ;
    SubDirHdrs $(TOP) support libjpeg ;
    SubDirHdrs $(TOP) support libpng ;
    SubDirHdrs $(TOP) support zlib ;
}

if $(USESDL) = yes
{
    SubDirHdrs $(TOP) support sdl ;
    SubDirHdrs $(TOP) support sdl_sound ;
}

if $(USEBABEL) = yes
{
    SubDirHdrs $(TOP) support babel ;
    SubDirCcFlags -DBABEL_HANDLER -Isupport/babel ;
}

if $(BUNDLEFONTS) = yes
{
    SubDirCcFlags -DBUNDLED_FONTS ;
}

GARGSRCS = 
    gi_blorb.c gi_dispa.c
    cggestal.c cgblorb.c cgfref.c cgmisc.c
    cgstyle.c cgstream.c cgunicod.c cgdate.c
    window.c winblank.c winpair.c wingrid.c
    wintext.c wingfx.c winmask.c
    event.c draw.c config.c
    imgload.c imgscale.c
    fontdata.c babeldata.c
    ;

if $(USETTS) = yes
{
    switch $(OS)
    {
        case MINGW :
            GARGSRCS += ttswin.c ;
        case *LINUX* :
            GARGSRCS += ttsspeechd.c ;
        case MACOSX :
            GARGSRCS += ttsmac.m ;
        case * :
            Exit "TTS requested but no implementation is available on this platform ($(OS))." ;
    }
}
else
{
    GARGSRCS += ttsnull.c ;
}

if $(OS) = IPLINUX { ObjectCcFlags draw.c : -DEFL_1BPP ; }
else if $(GUILIB) = EFL { ObjectCcFlags draw.c : -DEFL_4BPP ; }

if $(USESDL) = yes { GARGSRCS += sndsdl.c ; }
else if $(USEFMOD) = yes { GARGSRCS += sndfmod.c ; }
else { GARGSRCS += sndnull.c ; }

if $(OS) = MINGW { GARGSRCS += syswin.c fontwin.c icons.rc ; }
else if $(OS) = MACOSX { GARGSRCS += sysmac.m fontmac.m ; }
else if $(OS) = IPLINUX { GARGSRCS += syseoi.c fontfc.c ; }
else if $(OS) = LINUX && $(GUILIB) = EFL { GARGSRCS += sysefl.c fontfc.c ; }
else { GARGSRCS += sysgtk.c fontfc.c ; }

if $(OS) = MINGW { Main gargoyle : launchwin.c launcher.c ; }
else if $(OS) = MACOSX { Main gargoyle : launchmac.m launcher.c ; }
else if $(OS) = IPLINUX { Main gargoyle : launcheoi.c launcher.c ; }
else if $(OS) = LINUX && $(GUILIB) = EFL { Main gargoyle : launchefl.c launcher.c ; }
else { Main gargoyle : launchgtk.c launcher.c ; }

Library libgarglkmain : main.c ;

if $(STATIC)
{
    Library libgarglk : $(GARGSRCS) ;
}
else
{
    SharedLibrary libgarglk : $(GARGSRCS) ;

    if $(USEBABEL) = yes
    {
        LinkLibrariesOnSharedLibrary libgarglk : babel_static ;
    }

    if ( $(OS) = SOLARIS || $(OS) = MACOSX ) && $(USESDL) = yes
    {
        LinkLibrariesOnSharedLibrary libgarglk : SDL_sound_static ;
    }
}
