# comm16 makefile
#
# Copyright (c) 1992, Microsoft Corporation
#
# History:
#   27-Mar-1992 Nandurir
#   Created.
#   6-Feb-1994  LeeHart
#   Modified for version resources & CV Symbols
#

!INCLUDE ..\..\makefile.inc
.SUFFIXES:
.SUFFIXES: .c   .asm .h   .inc .obj .lst .sys .exe .com .map .sym .def .lib .rc .res


!ifdef INCLUDE
INCS    =
!else
INCS    = -I..\..\inc -I..\..\..\inc
!endif

DEFINES = -DWOW $(MVDMFLAGS)

AOBJ    = -t $(DEFINES) $(INCS)

CW16    = -AS -G2sw -Os -W3 -Zp $(DEFINES) $(INCS)
CW16B   = $(CW16) -B1 c1l.exe -B2 c2l.exe -B3 c3l.exe

LINK    = /map /align:16

!if !$(FREEBUILD)
AOBJ    = $(AOBJ) -Zd
CW16    = $(CW16) /Od /Oi /Zd
LINK    = $(LINK) /LI
!endif

W16LIBS = ..\..\lib\snocrtd.lib


.asm{$(DEST)\}.obj:
    masm $(AOBJ) $<,$(DEST)\;


.asm.lst:
    masm $(AOBJ) -l $*,nul,$*.lst;


.c.obj:
    cl16 -c -nologo $(CW16) $*.c

.c.lst:
    cl16 -c -nologo $(CW16) -Fonul -Fc$*.lst $*.c


.def.lib:
    implib $*.lib $*.def

.map.sym:
    mapsym $*

.rc.res:
    rc16 -r $(INCS) -fo $@ $*.rc


all:$(DEST)\comm.drv $(DEST)\comm.map $(DEST)\comm.sym $(DEST)\comm.lrf
    binplace -o $(ALT_PROJECT_TARGET) $(DEST)\comm.drv $(DEST)\comm.map $(DEST)\comm.sym


clean: cleanup all

cleanup:
    if exist $(DEST)\*.lrf del $(DEST)\*.lrf
    if exist $(DEST)\*.obj del $(DEST)\*.obj
    if exist $(DEST)\*.exe del $(DEST)\*.exe
    if exist $(DEST)\*.map del $(DEST)\*.map
    if exist $(DEST)\*.sym del $(DEST)\*.sym
    if exist $(DEST)\*.drv del $(DEST)\*.drv
    if exist $(DEST)\*.res del $(DEST)\*.res
    if exist $(DEST)\*.def del $(DEST)\*.def
    if exist $(DEST)\*.asm del $(DEST)\*.asm


$(DEST)\ccom.obj ccom.lst: ccom.asm ibmcom.inc comdev.inc

$(DEST)\ibmsetup.obj ibmsetup.lst: ibmsetup.asm ibmcom.inc comdev.inc ins8250.inc

$(DEST)\ibmcom.obj: ibmcom.asm ibmcom.inc comdev.inc ins8250.inc

$(DEST)\ibmint.obj: ibmint.asm ibmcom.inc comdev.inc ins8250.inc

$(DEST)\ibmlpt.obj: ibmlpt.asm ibmcom.inc comdev.inc

$(DEST)\commmsg.obj: commmsg.asm


$(DEST)\comm.res: comm.rc comm.rcv ..\..\inc\common.ver
    rc16 -r $(INCS) -fo $@ comm.rc

$(DEST)\comm.lrf: makefile.sub
    echo ccom+ibmsetup+ibmcom+ibmint+ibmlpt+commmsg >$@
    echo comm.exe/align:16>>$@
    echo comm $(LINK)>>$@
    echo ..\..\..\..\..\lib\$(ALT_PROJECT)\libw.lib ..\..\..\..\..\lib\snocrtd.lib /map /nod>>$@
    echo ..\..\..\comm;>>$@


$(DEST)\comm.drv: $(DEST)\ccom.obj $(DEST)\ibmsetup.obj $(DEST)\ibmcom.obj $(DEST)\ibmint.obj $(DEST)\ibmlpt.obj $(DEST)\commmsg.obj \
      comm.def $*.res $(DEST)\comm.lrf
    cd $(DEST)
    link16 @comm.lrf;
    rc16 -t comm.res comm.exe
    if exist *.drv del *.drv
    ren comm.exe *.drv
    mapsym comm
    cd ..\..\..
