#
# Jamfile
#
# TADS 2 + 3 runtime with gargoyle glk mods
#

SubDir TOP tads ;
ObjDir tads ;

SubDirHdrs $(SUBDIR) ;
SubDirHdrs $(SUBDIR) tads2 ;
SubDirHdrs $(SUBDIR) tads3 ;

SubDirCcFlags
    # -DGLK_ANSI_ONLY # if you don't have garglk_fileref_to_name
    -DGARGOYLE
    -DVMGLOB_STRUCT
    -DGLK_UNICODE
    -DGLK_TIMERS
    -DTC_TARGET_T3
    -DRUNTIME
    ;

# HTMLMODE ?= yes ;

if $(OS) = LINUX || $(OS) = SOLARIS
{
    SubDirCcFlags
        -DOS_USHORT_DEFINED
        -DOS_UINT_DEFINED
        -DOS_ULONG_DEFINED
        ;
}

if $(OS) = MACOSX
{
    SubDirCcFlags $(MAINARCH) $(ALTARCH) ;
    LINKFLAGS = -headerpad_max_install_names $(MAINARCH) $(ALTARCH) ;
}

if $(OS) = MINGW
{
    SubDirCcFlags -DMSDOS -DT_WIN32 ;
}

SEARCH_SOURCE =
        [ FDirName $(SUBDIR) tads2 ]
        [ FDirName $(SUBDIR) tads3 ]
        $(SUBDIR)
        ;

TADS2SRCS =
    argize.c bif.c bifgdum.c cmap.c cmd.c dat.c dbgtr.c errmsg.c execmd.c
    fio.c fioxor.c getstr.c ler.c linfdum.c lst.c mch.c mcm.c mcs.c obj.c
    oem.c os0.c oserr.c osifc.c osnoui.c osrestad.c osstzprs.c ostzposix.c
    out.c output.c ply.c qas.c regex.c run.c runstat.c suprun.c trd.c
    voc.c vocab.c
    ;


TADS3SRCS =
    charmap.cpp md5.cpp resldexe.cpp resload.cpp sha2.cpp std.cpp
    tcerr.cpp tcerrmsg.cpp tcgen.cpp tcglob.cpp tcmain.cpp tcprs.cpp
    tcprs_rt.cpp tcprsnf.cpp tcprsnl.cpp tcprsstm.cpp tcsrc.cpp tct3.cpp
    tct3_d.cpp tct3nl.cpp tct3stm.cpp tct3unas.cpp tctok.cpp utf8.cpp
    vmanonfn.cpp vmbif.cpp vmbifl.cpp vmbifreg.cpp vmbift3.cpp
    vmbiftad.cpp vmbiftio.cpp vmbignum.cpp vmbignumlib.cpp vmbt3_nd.cpp
    vmbytarr.cpp vmcfgmem.cpp vmcoll.cpp vmconhmp.cpp vmconsol.cpp
    vmcrc.cpp vmcset.cpp vmdate.cpp vmdict.cpp vmdynfunc.cpp vmerr.cpp
    vmerrmsg.cpp vmfile.cpp vmfilnam.cpp vmfilobj.cpp vmfref.cpp
    vmfunc.cpp vmglob.cpp vmgram.cpp vmhash.cpp vmhostsi.cpp vmhosttx.cpp
    vmimage.cpp vmimg_nd.cpp vmini_nd.cpp vminit.cpp vminitim.cpp
    vmintcls.cpp vmisaac.cpp vmiter.cpp vmlog.cpp vmlookup.cpp vmlst.cpp
    vmmain.cpp vmmcreg.cpp vmmeta.cpp vmnetfillcl.cpp vmobj.cpp vmop.cpp
    vmpack.cpp vmpat.cpp vmpool.cpp vmpoolim.cpp vmregex.cpp vmrun.cpp
    vmrunsym.cpp vmsa.cpp vmsave.cpp vmsort.cpp vmsortv.cpp vmsrcf.cpp
    vmstack.cpp vmstr.cpp vmstrbuf.cpp vmstrcmp.cpp vmtmpfil.cpp
    vmtobj.cpp vmtype.cpp vmtypedh.cpp vmtz.cpp vmtzobj.cpp vmundo.cpp
    vmvec.cpp
    ;

if $(HTMLMODE) = yes
{
    SubDirCcFlags -DUSE_HTML ;
    TADS3SRCS += vmconhtm.cpp ;
}
else
{
    TADS3SRCS += vmconnom.cpp ;
}

SUBDIRC++FLAGS = $(SUBDIRCCFLAGS) ;

Library libtads2 : $(TADS2SRCS) ;
Library libtads3 : $(TADS3SRCS) ;

Main $(GARGLKPRE)tadsr :
    memicmp.c
    osbuffer.c
    osextra.c
    osglk.c
    osglkban.c
    osmisc.c
    osparse.c
    osportable.cc
    t23run.cpp
    t2askf.c
    t2indlg.c
    t3askf.cpp
    t3indlg.cpp
    vmuni_cs.cpp
    ;

LinkLibraries $(GARGLKPRE)tadsr : libtads3 libtads2 ;

LINK on $(GARGLKPRE)tadsr$(SUFEXE) = $(CXX) ;

APPS += $(GARGLKPRE)tadsr ;

