# Genesis, the ColdC driver
# The name of the program to invoke yacc
YACC = yacc
# Flags to YACC - bison would use -y -d
YFLAGS = -d -l
CC = cl
LD = cl
AR = link /LIB
WINZIP = C:\apps\winzip\wzzip
# Version info generated by version.bat
!include <version.cfg>
# Version info generated by systype.bat
!include <systype.cfg>
# The location of the Genesis distribution
# Here we assume directory just below the current directory
DSTDIR = ..
# The distribution source directory
SD = $(DSTDIR)\src
DN = $(DSTDIR)\ndbm
# Include directories
COLDINCDIRS = -I$(SD)\include -I$(SD)\modules -I.
NDBMINCDIRS = -I$(DN)
INCDIRS = $(NDBMINCDIRS) $(COLDINCDIRS)
# Compiler directives for debugging
!ifdef DEBUG
DEBUG_CFLAGS = /MTd /ZI /Od /DDEBUG
DEBUG_LFLAGS = /DEBUG /PDBTYPE:SEPT
LIBS= libcmtd.lib kernel32.lib ws2_32.lib
!else
DEBUG_CFLAGS = /MT /Ot /Oy /Ob2 /Gs /GF /Gy /DNDEBUG
DEBUG_LFLAGS =
LIBS= libcmt.lib kernel32.lib ws2_32.lib
!endif
# Compiler directives
DEFS= -DWIN32 -DWIN32_LEAN_AND_MEAN -D_CONSOLE -D_MBCS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -D_USE_32BIT_TIME_T
OPTIM= /nologo /W1 $(DEBUG_CFLAGS)
CFLAGS= $(OPTIM) $(DEFS)
# Linker directives
LFLAGS = /link /NOLOGO /NODEFAULTLIB /SUBSYSTEM:CONSOLE $(DEBUG_LFLAGS)
# ndbm parts
NDBM_OBJ = $(DN)\ndbm.obj $(DN)\hash.obj $(DN)\hash_buf.obj $(DN)\hash_page.obj \
$(DN)\hash_bigkey.obj $(DN)\hash_log2.obj $(DN)\hash_func.obj
NDBM_LIB = $(DN)\ndbm.lib
GDBM_LIB = wingdbm.lib
# objects to be compiled
DD = $(SD)\data
DATA_OBJ = $(DD)\data.obj $(DD)\buffer.obj $(DD)\dict.obj $(DD)\ident.obj \
$(DD)\list.obj $(DD)\object.obj $(DD)\string.obj \
$(DD)\handled_frob.obj $(DD)\quickhash.obj
DO = $(SD)\ops
OPS_OBJ = $(DO)\operators.obj $(DO)\buffer.obj $(DO)\error.obj $(DO)\list.obj \
$(DO)\object.obj $(DO)\dict.obj $(DO)\string.obj $(DO)\data.obj $(DO)\sys.obj \
$(DO)\misc.obj $(DO)\task.obj $(DO)\file.obj $(DO)\network.obj $(DO)\math.obj
DM = $(SD)\modules
MOD_OBJ = $(DM)\cdc.obj $(DM)\cdc_buffer.obj $(DM)\cdc_dict.obj $(DM)\cdc_list.obj \
$(DM)\cdc_misc.obj $(DM)\cdc_string.obj $(DM)\cdc_integer.obj $(DM)\web.obj \
$(DM)\ext_math.obj $(DM)\veil.obj
GRM_OBJ = $(SD)\grammar.obj
DB_OBJ = $(SD)\cache.obj $(SD)\binarydb.obj $(SD)\dbpack.obj \
$(SD)\decode.obj $(SD)\lookup.obj
IO_OBJ = $(SD)\io.obj $(SD)\log.obj $(SD)\net.obj $(SD)\file.obj
MISC_OBJ = $(SD)\strutil.obj $(SD)\memory.obj $(SD)\sig.obj \
$(SD)\util.obj $(SD)\regexp.obj $(SD)\defs.obj $(SD)\dns.obj
CRYPT_OBJ = $(SD)\shs.obj $(SD)\crypt.obj
PCODE_OBJ = $(SD)\codegen.obj $(SD)\execute.obj $(SD)\opcodes.obj \
$(SD)\token.obj $(SD)\native.obj
COMMON_OBJ = $(DATA_OBJ) $(DB_OBJ) $(IO_OBJ) $(MISC_OBJ) \
$(PCODE_OBJ) $(OPS_OBJ) $(MOD_OBJ) $(CRYPT_OBJ)
DRIVER_OBJ = $(GRM_OBJ) $(COMMON_OBJ) $(SD)\genesis.obj
COMPILER_OBJ = $(GRM_OBJ) $(COMMON_OBJ) $(SD)\coldcc.obj $(SD)\textdb.obj
PARSER_SRC = $(SD)\grammar.c $(SD)\include\parse.h
# The final targets
DRIVER = genesis.exe
COMPILER = coldcc.exe
# default make rule
all: $(GRM_OBJ) $(NDBM_LIB) $(COMMON_OBJ) $(DRIVER) $(COMPILER)
# Rule to link genesis driver
$(DRIVER): $(DRIVER_OBJ)
@echo Linking driver...
$(LD) $** $(LIBS) $(NDBM_LIB) /Fe$@ $(LFLAGS)
# Rule to link coldcc compiler
$(COMPILER): $(COMPILER_OBJ)
@echo Linking compile...
$(LD) $** $(LIBS) $(NDBM_LIB) /Fe$@ $(LFLAGS)
# Rule for compiling grammar
$(PARSER_SRC): $(SD)\grammar.y
@echo Generating parser source...
@$(YACC) $(YFLAGS) $(SD)\grammar.y
@move y.tab.c $(SD)\grammar.c
@move y.tab.h $(SD)\include\parse.h
# Clean up the products of compilation and linking
clean:
@echo Cleaning...
-@del $(PARSER_SRC) $(DRIVER_OBJ) $(COMPILER_OBJ) 2>NUL
-@del $(NDBM_LIB) $(NDBM_OBJ) 2>NUL
-@del $(DRIVER) $(COMPILER) 2>NUL
-@del *.pdb *.ilk *.idb 2>NUL
-@del y.tab.* 2>NUL
# Clean up the products of the configure.bat script
cleanconfig:
@echo Cleaning configuration...
-@del version.cfg systype.cfg version.h systype.h 2>NUL
-@del $(SD)\include\config.h $(SD)\include\systype.h $(SD)\include\version.h
# Install the genesis driver and coldcc compiler to the supplied directory
install: $(DRIVER) $(COMPILER)
@echo Installing...
!ifdef INSTDIR
-@if not exist $(INSTDIR) echo Installation directory [$(INSTDIR)] does not exist.
@© $** $(INSTDIR) 2>NUL 1>NUL
@for /f %f in ('dir ..\bin /b /a-d') do @copy ..\bin\%f $(INSTDIR) 2>NUL 1>NUL
!else
@echo Installation directory not defined use - make -DINSTDIR=C:\mydir install
!endif
# Run the regression tests
test: $(DRIVER) $(COMPILER)
@runtests.bat
# Rule for building ndbm library
$(NDBM_LIB): $(NDBM_OBJ)
@echo "making ndbm library..."
-@del $@ 2>NUL
$(AR) /OUT:$@ $**
# Implicit rule for all C compiles
.c.obj:
$(CC) $(CFLAGS) $(INCDIRS) /c /Tc$< /Fo$@
# Some overrides for specific files follow
# regexp.h is a borland C++ header so we switch the order of includes for this file - yuck
#$(SD)\regexp.obj: $(SD)\regexp.c
# $(CC) $(CFLAGS) $(COLDINCDIRS) $(BCCINCDIRS) -c -n$(@D) $(SD)\regexp.c
# list.h is a borland C++ header so we switch the order of includes for this file - yuck
#$(DM)\ext_math.obj: $(DM)\ext_math.c
# $(CC) $(CFLAGS) $(COLDINCDIRS) $(BCCINCDIRS) -c -n$(@D) $(DM)\ext_math.c
# remove coldc net.h and io.h headers from search for ndbm compile
$(DN)\ndbm.obj: $(DN)\ndbm.c
$(CC) $(CFLAGS) $(NDBMINCDIRS) /c /Tc$** /Fo$@
# remove coldc net.h and io.h headers from search for ndbm compile
$(DN)\hash.obj: $(DN)\hash.c
$(CC) $(CFLAGS) $(NDBMINCDIRS) /c /Tc$** /Fo$@
# remove coldc net.h and io.h headers from search for ndbm compile
$(DN)\hash_buf.obj: $(DN)\hash_buf.c
$(CC) $(CFLAGS) $(NDBMINCDIRS) /c /Tc$** /Fo$@
# remove coldc net.h and io.h headers from search for ndbm compile
$(DN)\hash_page.obj: $(DN)\hash_page.c
$(CC) $(CFLAGS) $(NDBMINCDIRS) /c /Tc$** /Fo$@
# remove coldc net.h and io.h headers from search for ndbm compile
$(DN)\hash_bigkey.obj: $(DN)\hash_bigkey.c
$(CC) $(CFLAGS) $(NDBMINCDIRS) /c /Tc$** /Fo$@
# remove coldc net.h and io.h headers from search for ndbm compile
$(DN)\hash_log2.obj: $(DN)\hash_log2.c
$(CC) $(CFLAGS) $(NDBMINCDIRS) /c /Tc$** /Fo$@
# remove coldc net.h and io.h headers from search for ndbm compile
$(DN)\hash_func.obj: $(DN)\hash_func.c
$(CC) $(CFLAGS) $(NDBMINCDIRS) /c /Tc$** /Fo$@