# -----------------------------------------------------------------------
#   Makefile for MSDOS Citadel v3.11.xxd, for use with NDMAKE
# -----------------------------------------------------------------------

# -----------------------------------------------------------------------
#   ALL JOBS:
#
all:     cflags.cit ctdl.exe
# -----------------------------------------------------------------------

# -----------------------------------------------------------------------
#   set up compiler (Turbo C)
#
.C.OBJ:
    tcc $(CFLAGS) -Qx -c {$*.c }
# -----------------------------------------------------------------------

# -----------------------------------------------------------------------
# Option: Serial package to use (CSER || CSERL)
# NOTE: CSER.ASM still has problems, use CSERL!
#
SERIAL=cserl
# -----------------------------------------------------------------------

# -----------------------------------------------------------------------
# Options: (linker)
#
LFLAGS=
# -----------------------------------------------------------------------

# -----------------------------------------------------------------------
# Options: (compile time and Defines)
CFLAGS= @cflags.cit
#DEBUG= -v
DEBUG=  -DIBM -DALPHA-TEST -DNETWORK -DBATA-TEST
#
#       -DIBM
#       Running under an IBM PC/XT/AT environment
#
#       -DDRAGON
#       user abuse: ctdl.c dragon.c modem.c
#
#       -DALPHA_TEST
#       Enable ALPHA-test debugging code
#
#       -DBETA_TEST
#       Enable BETA-test debugging code
#
#       -DNETWORK
#       Endable network related code
#
#       -DCOMPILER
#       Give the name of the compiler..
#
# -----------------------------------------------------------------------

# -----------------------------------------------------------------------
# Object file list, .ASM and then .C

OBJS  = $(SERIAL).obj   \
        swap.obj        \
        account.obj     \
        aplic.obj       \
        carrier.obj     \
        chat.obj        \
        config.obj      \
        console.obj     \
        console.obj     \
        cron.obj        \
        dragon.obj      \
        ctdl.obj        \
        do.obj          \
        doaide.obj      \
        dosysop.obj     \
        down.obj        \
        dumbterm.obj    \
        edit.obj        \
        files.obj       \
        format.obj      \
        group.obj       \
        grpedit.obj     \
        hall.obj        \
        halledit.obj    \
        help.obj        \
        info.obj        \
        infofile.obj    \
        init.obj        \
        input.obj       \
        library.obj     \
        log.obj         \
        log2.obj        \
        logedit.obj     \
        login.obj       \
        loginnew.obj    \
        logout.obj      \
        lzhfile.obj     \
        misc.obj        \
        misc2.obj       \
        modem.obj       \
        msg.obj         \
        msgmake.obj     \
        msgmod.obj      \
        msgread.obj     \
        msgcfg.obj      \
        net.obj         \
        netdc15.obj     \
        netmail.obj     \
        netmsg.obj      \
        netnode.obj     \
        output.obj      \
        port.obj        \
        room.obj        \
        room2.obj       \
        roomedit.obj    \
        strftime.obj    \
        term.obj        \
        timedate.obj    \
        trap.obj        \
        version.obj     \
        window.obj      \
        zipfile.obj

# -----------------------------------------------------------------------

# -----------------------------------------------------------------------
#
#   CTDL.EXE
#
#   Use the link with the $(OVL) for an overlayed version of the program
#
ctdl.exe: $(OBJS)
        tlink @link.cit /o
#        tcc $(CFLAGS) $(DEBUG) -eCTDL.EXE @ctdl.lnk

# -----------------------------------------------------------------------

# -----------------------------------------------------------------------
# Some special stuff for c / asm files
#
$(SERIAL).obj:      $(SERIAL).asm
    tasm /o /m4 $(SERIAL);

SWAP.OBJ:           SWAP.ASM
    tasm /mx /JMASM51 /D_large /Dxms /Dems /Ddisk /m4 SWAP.ASM
# -----------------------------------------------------------------------

# -----------------------------------------------------------------------
# Some other special stuff
#
CFLAGS.CIT:         MAKEFILE
    echo -ml -N -O -d -w -Z -D$(SERIAL) -DALPHA_TEST -DNETWORK -DIBM -DSWAP > CFLAGS.CIT
# -----------------------------------------------------------------------

# -----------------------------------------------------------------------
# Backup makes an zip file of all the sources, headers, and the $(SERIAL).obj
# file.
#
BACKUPDIR = \ts\bak
backup:
        del $(BACKUPDIR)\ctdlsrc.zip
        pkzip -ex $(BACKUPDIR)\ctdlsrc *.asm *.h *.c *.bat makefile *.cit

# -----------------------------------------------------------------------

# -----------------------------------------------------------------------
#
# Make alpha tests and update the version number..
#
alpha:
    util\vercmd version.c "z -a alpha\dcexe%v ctdl.exe alpha\license.doc"
    util\vercmd version.c "z -a bak\dcsrc%v *.asm *.h *.c *.bat makefile *.cit"
    util\upver version.c version.tmp
    del version.bak
    rename version.c version.bak
    rename version.tmp version.c

back:
    util\vercmd version.c "z -a bak\dcsrc%v *.asm *.h *.c *.bat makefile *.cit"

# -----------------------------------------------------------------------

# -----------------------------------------------------------------------
#  Special list for debugging testing..
#
#output.obj: output.c
#    tcc -c $(CFLAGS) $(DEBUG) output.c

#net.obj: net.c
#    tcc -c $(CFLAGS) $(DEBUG) net.c