############################################################
#
# make file for MT MIDI Sequencer - Microsoft C 6.00 version
#
############################################################

CC = cl /c
CFLAGS = /W4 /Ot /Oi /Ol /Oe /Og /Gs
#             ^optimizations; from standard DOS .COM and .EXE build options
#         ^warning level; the only allowable warning must be:
# "warning C4127: conditional expression is constant" when a while(1) is found

# compiler can't make global optimization for larger functions
CFLAGS_NOG = /W4 /Ot /Oi /Gs

LFLAGS_EXE = /EXE /FAR /PACKC
LFLAGS_COM = /NOI /NOE /TINY /FAR

all : mt.exe  install.exe  mf2mt.exe  mt2mf.com  makesong.com

#####################  MT object files  ####################

mt.obj    : mt.c    ; $(CC) /AM $(CFLAGS) mt.c
mted1.obj : mted1.c ; $(CC) /AM $(CFLAGS) mted1.c
mted2.obj : mted2.c ; $(CC) /AM $(CFLAGS) mted2.c
mted3.obj : mted3.c ; $(CC) /AM $(CFLAGS) mted3.c
mtrc1.obj : mtrc1.c ; $(CC) /AM $(CFLAGS) mtrc1.c
mtrc2.obj : mtrc2.c ; $(CC) /AM $(CFLAGS) mtrc2.c
mtrc3.obj : mtrc3.c ; $(CC) /AM $(CFLAGS) mtrc3.c
mtrc4.obj : mtrc4.c ; $(CC) /AM $(CFLAGS) mtrc4.c
mtsc1.obj : mtsc1.c ; $(CC) /AM $(CFLAGS) mtsc1.c
mtsc2.obj : mtsc2.c ; $(CC) /AM $(CFLAGS) mtsc2.c
mtsc3.obj : mtsc3.c ; $(CC) /AM $(CFLAGS) mtsc3.c
mtsc4.obj : mtsc4.c ; $(CC) /AM $(CFLAGS) mtsc4.c
mtut1.obj : mtut1.c ; $(CC) /AM $(CFLAGS) mtut1.c
mtut2.obj : mtut2.c ; $(CC) /AM $(CFLAGS) mtut2.c
filefunc.obj : filefunc.c ; $(CC) /AM $(CFLAGS) filefunc.c

mio401.obj   : mio401.asm ; masm mio401.asm;

######################  screenf.lib  ##############################

videofnc.obj : videofnc.c ; $(CC) /AM $(CFLAGS) videofnc.c
chain.obj    : chain.c    ; $(CC) /AM $(CFLAGS) chain.c
writscrn.obj : writscrn.c ; $(CC) /AM $(CFLAGS) writscrn.c
inputf.obj   : inputf.c   ; $(CC) /AM $(CFLAGS) inputf.c

screenf.lib  : videofnc.obj   chain.obj   writscrn.obj   inputf.obj
 lib screenf -+videofnc.obj -+chain.obj -+writscrn.obj -+inputf.obj,screenf.lst;

###################### .EXE files  ################################

mt.exe :  mt.obj    mted1.obj mted2.obj mted3.obj \
mtrc1.obj mtrc2.obj mtrc3.obj mtrc4.obj \
mtsc1.obj mtsc2.obj mtsc3.obj mtsc4.obj \
mtut1.obj mtut2.obj filefunc.obj mio401.obj screenf.lib
   echo $(LFLAGS_EXE)+> mt.lrf
   echo    mt.obj+mted1.obj+mted2.obj+mted3.obj+>> mt.lrf
   echo mtrc1.obj+mtrc2.obj+mtrc3.obj+mtrc4.obj+>> mt.lrf
   echo mtsc1.obj+mtsc2.obj+mtsc3.obj+mtsc4.obj+>> mt.lrf
   echo mtut1.obj+mtut2.obj+filefunc.obj+mio401 >> mt.lrf
   echo mt.exe >> mt.lrf
   echo mt.map >> mt.lrf
   echo screenf.lib+graphics.lib; >> mt.lrf
   link @mt.lrf

install.obj  : install.c  ; $(CC) /AM $(CFLAGS) install.c
install.exe  : install.obj  screenf.lib
         link $(LFLAGS_EXE) install.obj,,,screenf.lib+graphics.lib;


######################  Utilities  ################################

mf2mt.obj : mf2mt.c ; $(CC) $(CFLAGS_NOG) mf2mt.c
mf2mt.exe : mf2mt.obj
         link $(LFLAGS_EXE) mf2mt.obj;

mt2mf.obj : mt2mf.c ; $(CC) $(CFLAGS) mt2mf.c
mt2mf.com : mt2mf.obj
         link $(LFLAGS_COM) crtcom.lib+mt2mf.obj,mt2mf.com;

makesong.obj : makesong.c ; $(CC) $(CFLAGS) makesong.c
makesong.com : makesong.obj
         link $(LFLAGS_COM) crtcom.lib+makesong.obj,makesong.com;

buldmenu.obj : buldmenu.c ; $(CC) $(CFLAGS) buldmenu.c
buldmenu.com : buldmenu.obj
         link $(LFLAGS_COM) crtcom.lib+buldmenu.obj,buldmenu.com;


####################  Mouse Definition File  ######################

m_simple.com : m_simple.msc ; msc m_simple.msc


##########  Clean garbage (run after everything is done) ##########

clean :
        if exist *.bak del *.bak
        if exist *.crf del *.crf
        if exist *.ilk del *.ilk
        if exist *.lib del *.lib
        if exist *.lrf del *.lrf
        if exist *.lst del *.lst
        if exist *.map del *.map
        if exist *.mdt del *.mdt
        if exist *.obj del *.obj
        if exist *.sym del *.sym
