#******************************************************************************
#  Makefile for the ATCOM directory
#
#       SCCSID = @(#)makefile   6.9 92/02/15
#
#       IBM/Microsoft Confidential
#
#       Copyright (c) IBM Corporation 1987, 1989
#       Copyright (c) Microsoft Corporation 1987, 1989
#
#       All Rights Reserved
#
#******************************************************************************

#
# ******  NOTE  ******
#
#        If you are using a SED command with TAB characters, many editors
#        will expand tabs causing unpredictable results in other programs.
#
#        Documentation:
#
#        Using SED command with TABS. Besure to invoke set tab save option
#        on your editor. If you don't, the program 'xyz' will not work
#        correctly.
#
#
#       When building the AT asynch driver it is possible to do
#       so with a number of assembler flags defined. The flags that
#       you wish to define should be set up in your environment with
#       the 'set' command. For example,
#
#               A> set COMFLAGS=-DCISTRICT -DRLPSTRICT
#
#       Currently the defined flags are:
#
#         - COMDEBUG    enables 'int 3' instruction throughtout the driver
#         - DEVHLP      enables 'int 3' to occur before every DevHlp call
#         - ALLSTRICT   CISTRICT RPLSTRICT RPTSTRICT RPSTRICT
#         - CISTRICT    verifies pointers to the ComInfo structure
#         - RPLSTRICT   verifies pointers to the RP_List structure
#         - RPTSTRICT   verifies request packets are of the expected type
#         - RPSTRICT    verifies pointers to request packets
#         - MESSAGES    ComErr messages will be included in non-debugging
#                       (messages are always in debugging version)
#         - COM2_1F8    make COM2 port address 1F8 (specially modifed COM card)
#                       so COM1, COM2 and the kernel debugger can all be used.
#                       This requires a machine with 3 COM boards:
#                        COM1 - 3F8
#                        COM2 - 1F8  2F8 with A8 and A9 crossed from bus
#                        KDB  - 2F8  (normal COM2 address)
#
#       WARNING: Be sure to do a clean build after changing any flags.
#

#****************************************************************************
#  Dot directive definition area (usually just suffixes)
#****************************************************************************

.SUFFIXES:      .asm .obj .obd .lst .lsd .def .lnk .lrf .sys .sym .xbj .xbd

#****************************************************************************
#  Environment Setup for the component(s).
#****************************************************************************


#
# Compiler Location w/ includes, libs and tools
#

H         = ..\..\..\h
INC       = ..\..\..\inc
RMINC     = ..\resource\rsm_h
DISKH     = ..\dasd\diskh
DOSINC    = ..\..\dos\dosinc
LIB       = ..\..\..\lib
RMLIBP    = ..\resource\rmcalls
DHCALLS   = ..\dasd\devhelp
TOOLSPATH =..\..\..\tools

LIBS      = $(RMLIBP)\rmcalls.lib $(LIB)\doscalls.lib $(DHCALLS)\dhcalls.lib
DEF       = com01.def
DEF2      = com01x.def

#
# Since the compiler/linker and other tools use environment
# variables ( INCLUDE, LIB, etc ) in order to get the location of files,
# the following line will check the environment for the LIFE of the
# makefile and will be specific to this set of instructions. All MAKEFILES
# are requested to use this format to insure that they are using the correct
# level of files and tools.


!if [set INCLUDE=.;$(RMINC);$(INC);$(DOSINC);$(H);$(DISKH)] || [set LIB=$(LIB)] ||\
  [set PATH=$(TOOLSPATH)]
!endif


#
# Compiler/tools Macros
#

AS=masm
CC=cl
IMPLIB=implib
IPF=ipfc
LIBUTIL=lib
LINK=link
MAPSYM=mapsym
RC=rc

#
# Compiler and Linker Options
#
CFLAGS = /c /Zp1 /G2s /Asfw -I. /Oti  $(ENV) /Gm /nologo

CINC   = -I$(H) -I$(RMINC)

!ifndef smp
AFLAGS = -Mx -t $(COMFLAGS)
!else
AFLAGS = -Mx -t $(COMFLAGS) -DSMP
!endif
AINC   = -I$(INC) -I$(DOSINC) -I$(MAKEDIR)
LFLAGS = /noe /nod /map /EXEPACK /ALIGN:16 /FAR
RFLAGS = -r

#****************************************************************************
# Set up Macros that will contain all the different dependencies for the
# executables and dlls etc. that are generated.
#****************************************************************************

# WARNING: the order of the objects in the .lnk file is VERY important.
# 'atcom.obj' MUST be first so the device driver headers are the first
# thing in the data segment.
# 'atinit.obj' MUST be next to last  and 'ateisai.obj' MUST be last so init
# code can be released memory after initalization.
# Do not change their order unless you thoroughly understand the effects.

# !!!atcom.obj MUST be first, atinit.obj then ateisai.obj MUST be last!!!
OBJ1 = atcom.obj
OBJ2 = atintrpt.obj atsub.obj atioctl.obj atmvdm.obj
OBJ3 = atqueue.obj
OBJ4 = atinit.obj rmhelp.obj ateisai.obj compci.obj
OBJS = $(OBJ1) $(OBJ2) $(OBJ3) $(OBJ4)

# !!!atcom.pbj MUST be first, atinit.pbj then ateisai.pbj MUST be last!!!
PBJ1 = atcom.pbj
PBJ2 = atintrpt.pbj atsub.pbj atioctl.pbj atmvdm.pbj
PBJ3 = atqueue.pbj
PBJ4 = atinit.pbj rmhelp.obj ateisai.pbj compci.obj
PBJS = $(PBJ1) $(PBJ2) $(PBJ3) $(PBJ4)

# !!!atcom.obd MUST be first, atinit.obd then ateisai.obd MUST be last!!!
OBD1 = atcom.obd
OBD2 = atintrpt.obd atsub.obd atioctl.obd atmvdm.obd
OBD3 = atqueue.obd
OBD4 = atinit.obd rmhelp.obj ateisai.obd compci.obj
OBDS = $(OBD1) $(OBD2) $(OBD3) $(OBD4)

# !!!atcom.PBD MUST be first, atinit.PBD then ateisai.PBD MUST be last!!!
PBD1 = atcom.PBD
PBD2 = atintrpt.PBD atsub.PBD atioctl.PBD atmvdm.PBD
PBD3 = atqueue.PBD
PBD4 = atinit.PBD rmhelp.obj ateisai.PBD compci.obj
PBDS = $(PBD1) $(PBD2) $(PBD3) $(PBD4)

# Only atinit.??? changes from OBJ version
XBJ4 = atinit.xbj rmhelp.obj ateisai.obj compci.obj
XBJS = $(OBJ1) $(OBJ2) $(OBJ3) $(XBJ4)

# Only atinit.??? changes from OBD version
XBD4 = atinit.xbd rmhelp.obj ateisai.obd compci.obj
XBDS = $(OBD1) $(OBD2) $(OBD3) $(XBD4)



#****************************************************************************
#   Setup the inference rules for compiling and assembling source code to
#   obejct code.
#****************************************************************************
.c.obj:
        $(CC) $(CFLAGS) $(CINC) $*.c

.c.lst:
        $(CC) $(CFLAGS) /Fc $(CINC) $*.c
        copy $*.cod $*.lst
        del $*.cod

.asm.obj:
        $(AS) $(AFLAGS) $(AINC) $*.asm;

.asm.pbj:
        $(AS) $(AFLAGS) $(AINC) -DPERFVIEW $*.asm,$*.pbj;

.asm.obd:
        $(AS) $(AFLAGS) -DCOMDEBUG $(AINC) $*.asm,$*.obd;

.asm.pbd:
        $(AS) $(AFLAGS) -DCOMDEBUG -DPERFVIEW $(AINC) $*.asm,$*.pbd;

.asm.lst:
        $(AS) -n $(AFLAGS) $(AINC) $*.asm,,$*.lst;

.asm.lsd:
        $(AS) -n $(AFLAGS) -DCOMDEBUG $(AINC) $*.asm,,$*.lsd;

.asm.pst:
        $(AS) -n $(AFLAGS) $(AINC) -DPERFVIEW $*.asm,,$*.pst;

.asm.psd:
        $(AS) -n $(AFLAGS) -DCOMDEBUG -DPERFVIEW $(AINC) $*.asm,,$*.psd;

.asm.xbj:
        $(AS) $(AFLAGS) -DCOM2_1F8 $(AINC) $*.asm,$*.xbj;

.asm.xbd:
        $(AS) $(AFLAGS) -DCOM2_1F8 -DCOMDEBUG $(AINC) $*.asm,$*.xbd;

.sys.sym:
        $(MAPSYM) $*.map


#****************************************************************************
#   Target Information
#****************************************************************************
#
# This is a very important step. The following small amount of code MUST
# NOT be removed from the program. The following directive will do
# dependency checking every time this component is built UNLESS the
# following is performed:
#                    A specific tag is used -- ie. all
#
# This allows the developer as well as the B & I group to perform incremental
# build with a degree of accuracy that has not been used before.
# There are some instances where certain types of INCLUDE files must be
# created first. This type of format will allow the developer to require
# that file to be created first. In order to achive that, all that has to
# be done is to make the DEPEND.MAK tag have your required target. Below is
# an example:
#
#    depend.mak:   { your file(s) } dephold
#
# Please DON'T remove the following line
#



# default, just build retail COMDD
all:    com comp

com:    com.sys com.sym

comp:   comp.sys comp.sym

comd:   comd.sys comd.sym

compd:  comp.sys compd.sym

comx:   comx.sys comx.sym

comdx:  comdx.sys comdx.sym

clean:
        if exist *.lnk  del *.lnk
        if exist *.obj  del *.obj
        if exist *.pbj  del *.pbj
        if exist *.pbd  del *.pbd
        if exist *.obd  del *.obd
        if exist *.xbj  del *.xbj
        if exist *.xbd  del *.xbd
        if exist *.map  del *.map
        if exist *.old  del *.old
        if exist *.lst  del *.lst
        if exist *.lsd  del *.lsd
        if exist *.sym  del *.sym
        if exist *.sys  del *.sys


#*****************************************************************************
#   Specific Description Block Information
#*****************************************************************************

# This section would only be for specific direction as to how to create
# unique elements that are necessary to the build process. This could
# be compiling or assembling, creation of DEF files and other unique
# files.
# If all compiler and assembly rules are the same, use an inference rule to
# perform the compilation.
#


com01.def: makefile
        @echo Make .DEF file
        @echo ; ***************************************************************************  > com01.def
        @echo ; *                                                                           >> com01.def
        @echo ; *                       IBM/Microsoft Confidential                          >> com01.def
        @echo ; *                                                                           >> com01.def
        @echo ; *                 Copyright (c) IBM Corporation  1987, 1990                 >> com01.def
        @echo ; *                 Copyright (c) Microsoft Corp.  1987, 1990                 >> com01.def
        @echo ; *                           All Rights Reserved                             >> com01.def
        @echo ; *                                                                           >> com01.def
        @echo ; *************************************************************************** >> com01.def
        @echo LIBRARY COM                               >> com01.def
        @echo PROTMODE                                  >> com01.def
        @echo CODE    PRELOAD                           >> com01.def
        @echo DATA    PRELOAD                           >> com01.def
        @echo SEGMENTS                                  >> com01.def
        @echo    HSEG     CLASS 'RESDATA'               >> com01.def
        @echo    RSEG     CLASS 'RESCODE'               >> com01.def
        @echo    DSEG     CLASS 'DATA'       IOPL       >> com01.def
        @echo    _DATA    CLASS 'DATA'       IOPL       >> com01.def
        @echo    CONST    CLASS 'CONST'      IOPL       >> com01.def
        @echo    c_common CLASS 'BSS'        IOPL       >> com01.def
        @echo    _BSS     CLASS 'BSS'        IOPL       >> com01.def
        @echo    CSEG     CLASS 'CODE'       IOPL       >> com01.def
        @echo    'RMCode' CLASS 'CODE'       IOPL       >> com01.def
        @echo    _TEXT    CLASS 'CODE'       IOPL       >> com01.def
        @echo IMPORTS                                   >> com01.def
        @echo    DOSIODELAYCNT=DOSCALLS.427             >> com01.def


com01x.def: makefile
        @echo Make .DEF file
        @echo ; ***************************************************************************  > com01x.def
        @echo ; *                                                                           >> com01x.def
        @echo ; *                       IBM/Microsoft Confidential                          >> com01x.def
        @echo ; *                                                                           >> com01x.def
        @echo ; *                 Copyright (c) IBM Corporation  1987, 1990                 >> com01x.def
        @echo ; *                 Copyright (c) Microsoft Corp.  1987, 1990                 >> com01x.def
        @echo ; *                           All Rights Reserved                             >> com01x.def
        @echo ; *                                                                           >> com01x.def
        @echo ; *************************************************************************** >> com01x.def
        @echo LIBRARY COMDMA                            >> com01x.def
        @echo PROTMODE                                  >> com01x.def
        @echo CODE    PRELOAD                           >> com01x.def
        @echo DATA    PRELOAD                           >> com01x.def
        @echo SEGMENTS                                  >> com01x.def
        @echo    HSEG     CLASS 'RESDATA'                >> com01x.def
        @echo    RSEG     CLASS 'RESCODE'                >> com01x.def
        @echo    DSEG     CLASS 'DATA'       IOPL       >> com01x.def
        @echo    _DATA    CLASS 'DATA'       IOPL       >> com01x.def
        @echo    CONST    CLASS 'CONST'      IOPL       >> com01.def
        @echo    c_common CLASS 'BSS'        IOPL       >> com01.def
        @echo    _BSS     CLASS 'BSS'        IOPL       >> com01.def
        @echo    CSEG     CLASS 'CODE'       IOPL       >> com01x.def
        @echo    'RMCode' CLASS 'CODE'       IOPL       >> com01.def
        @echo    _TEXT    CLASS 'CODE'       IOPL       >> com01.def
        @echo IMPORTS                                   >> com01x.def
        @echo    DOSIODELAYCNT=DOSCALLS.427             >> com01x.def



# Standard Non-Debugging COM driver
com.sys:   $(OBJS) $(LIBS) $(DEF) makefile
        $(LINK) $(LFLAGS) @<<$(@B).lnk
$(OBJ1) +
$(OBJ2) +
$(OBJ3) +
$(OBJ4)
$@
$*.map
$(LIBS)
$(DEF)
<<keep

comp.sys:   $(PBJS) $(LIBS) $(DEF) makefile
        $(LINK) $(LFLAGS) @<<$(@B).lnk
$(PBJ1) +
$(PBJ2) +
$(PBJ3) +
$(PBJ4)
$@
$*.map
$(LIBS)
$(DEF)
<<keep

#comdma.sys:   $(OBJS) $(LIBS) $(DEF2) makefile
#        $(LINK) $(LFLAGS) @<<$(@B).lnk
#$(OBJ1) +
#$(OBJ2) +
#$(OBJ3) +
#$(OBJ4)
#$@
#$*.map
#$(LIBS)
#$(DEF2)
#<<keep

#comdma.sym: comdma.sys
#        mapsym comdma.map
#        move comdma.sy* ..\rucom

# Debugging COM driver
comd.sys:  $(OBDS) $(LIBS) $(DEF)  makefile
        $(LINK) $(LFLAGS) @<<$(@B).lnk
$(OBD1) +
$(OBD2) +
$(OBD3) +
$(OBD4)
$@
$*.map
$(LIBS)
$(DEF)
<<keep

# Debugging COM driver
compd.sys:  $(PBDS) $(LIBS) $(DEF)  makefile
        $(LINK) $(LFLAGS) @<<$(@B).lnk
$(PDBD1) +
$(PDBD2) +
$(PDBD3) +
$(PDBD4)
$@
$*.map
$(LIBS)
$(DEF)
<<keep

# Non-Debugging COM driver with COM2 at 1F8
comx.sys:  $(XBJS) $(LIBS) $(DEF) makefile
        $(LINK) $(LFLAGS) @<<$(@B).lnk
$(OBJ1) +
$(OBJ2) +
$(OBJ3) +
$(XBJ4)
$@
$*.map
$(LIBS)
$(DEF)
<<keep

# Debugging COM driver with COM2 at 1F8
comdx.sys: $(XBDS) $(LIBS) $(DEF) makefile
        $(LINK) $(LFLAGS) @<<$(@B).lnk
$(OBD1) +
$(OBD2) +
$(OBD3) +
$(XBD4)
$@
$*.map
$(LIBS)
$(DEF)
<<keep


#****************************************************************************
