#
# NMAKE-compatible MAKE file for building REXX/SQL with C Set/2
# This port works with Dirk Ohme's port of mSQL 1.1.13 or above
#
# will generate:
#
#      rexxsql.dll
#      rexxsql.exe
#      rexxmin.dll
#      rexxmin.exe
# 
# Usage: nmake [LIST=1] [DEBUG=1] [rexxsql.dll|rexxsql.exe|rexxmin.dll|rexxmin.exe]
#

#
# These variables specify where the mSQL include and library files
# for mSQL can be found. Change as necessary.
# You will also have to change the path to the mSQL library in:
#	minexe.lnk
#	sqlexe.lnk
#
MSQLINCDIR=h:\public\msql\include        
MSQLLIBDIR=h:\public\msql\lib

#---------------------------------------------------------------------
# You should not have to change anything below here...
#---------------------------------------------------------------------

!ifdef LIST
listopt = /Fl /Le /Ls+
!endif

!ifdef DEBUG
copts  = /Ti- /O- /dDEBUG /I.. /I..\..\common /I$(MSQLINCDIR) #/Kf+
lopts  = /NOLOGO /EXEPACK /ALIGN:4 /DEBUG /MAP:FULL
!else
copts  = /Ti+ /O+ /dNDEBUG /I.. /I..\..\common /I$(MSQLINCDIR) #/Kf+
lopts  = /NOLOGO /EXEPACK /PACKCODE /PACKDATA /ALIGN:4
!endif

cflagsdll = $(copts) /C /Ge- /Gm /Q /Sa /J+ #/Ms
cflagsexe = $(copts) /C /Ge+ /Gm /Q /Sa /J+ /Mp
lflagsdll = $(lopts)
lflagsexe = /NOE /ST:900000 /SE:512 $(lopts)

objssqldll = hashdll.obj msqldll.obj
objssqlexe = getopt.obj hashexe.obj rsqlexe.obj msqlexe.obj
objsmindll = hashdll.obj mmindll.obj
objsminexe = getopt.obj hashexe.obj rminexe.obj mminexe.obj

ccsqldll = icc $(cflagsdll) $(listopt)
ccsqlexe = icc $(cflagsexe) $(listopt)
ccmindll = icc $(cflagsdll) $(listopt) -DMIN_PREFIX
ccminexe = icc $(cflagsexe) $(listopt) -DMIN_PREFIX

DLL_LIBS = rexx+so32dll+tcp32dll+$(MSQLLIBDIR)\msql_dll
EXE_LIBS = rexx+so32dll+tcp32dll+$(MSQLLIBDIR)\msql

all: rexxsql.dll rexxsql.exe rexxmin.dll rexxmin.exe

getopt.obj: ..\..\common\getopt.c
    $(ccsqlexe) /Fogetopt.obj ..\..\common\getopt.c

hashdll.obj: ..\..\common\hash.c
    $(ccsqldll) /Fohashdll.obj ..\..\common\hash.c

hashexe.obj: ..\..\common\hash.c
    $(ccsqlexe) /Fohashexe.obj ..\..\common\hash.c

rsqlexe.obj: ..\rexxsql.c ..\rexxsql.h
    $(ccsqlexe) /Forsqlexe.obj ..\rexxsql.c

msqldll.obj: ..\minsql.c ..\rexxsql.h
    $(ccsqldll) /Fomsqldll.obj ..\minsql.c

msqlexe.obj: ..\minsql.c ..\rexxsql.h
    $(ccsqlexe) /Fomsqlexe.obj ..\minsql.c

rminexe.obj: ..\rexxsql.c ..\rexxsql.h
    $(ccminexe) /Forminexe.obj ..\rexxsql.c

mmindll.obj: ..\minsql.c ..\rexxsql.h
    $(ccmindll) /Fommindll.obj ..\minsql.c

mminexe.obj: ..\minsql.c ..\rexxsql.h
    $(ccminexe) /Fomminexe.obj ..\minsql.c

#                link386 $(lflagsdll) @sqldll.lnk
rexxsql.dll: $(objssqldll)
	link386 $(lflagsdll) hashdll.obj+msqldll.obj,$@,$*.map,$(DLL_LIBS),sqldll.def;
	rc ..\..\rexxsql.res rexxsql.dll

#                link386 $(lflagsexe) getopt.obj+hashexe.obj+rsqlexe.obj+msqlexe.obj,$@,$*.map,$(EXE_LIBS),sqlexe.def;
rexxsql.exe: $(objssqlexe)
	link386 $(lflagsexe) @sqlexe.lnk
	rc ..\..\rexxsql.res rexxsql.exe

rexxmin.dll: $(objsmindll)
	link386 $(lflagsdll) hashdll.obj+mmindll.obj,$@,$*.map,$(DLL_LIBS),mindll.def;
#	link386 $(lflagsdll) @mindll.lnk
	rc ..\..\rexxsql.res rexxmin.dll

rexxmin.exe: $(objsminexe)
#   link386 $(lflagsexe) rminexe.obj+hashexe.obj+mminexe.obj+getopt.obj,$@,$*.map,$(EXE_LIBS),minexe.def;
	link386 $(lflagsexe) @minexe.lnk
	rc ..\..\rexxsql.res rexxmin.exe
