###########################################################################
#                                                                         #
# makefile for REDUCE 3.7 using CSL                                       #
#                                                                         #
###########################################################################

# The following lines indicates the place on your disc where the "cslbase"
# directory exists. This is the  place where the C sources files for CSL
# live. There are two versions here, the first should use Unix-like
# file name conventions (in particular "/" as a directory separator) while
# the second will (in some cases) be a host-specific translation.

UCSLBASE  = ../cslbase
CSLBASE   = ..\cslbase


###########################################################################
# This is for 32-bit operation with Watcom C version 10.5, 10.6, 11.0     #
# Note that other release of Watcom C need command line options changed   #
###########################################################################

CC        = *wcc386
OPTFLAGS  = -d2 -d_DEBUG -DDEBUG=1
MPIFLAGS  =
CCFLAGS   = -d_MBCS=1 -d_WINDOWS=1 -dWINDOWS_NT=1 -bt=nt -DCWIN=1
CCFLAGS1  = -d_MBCS=1 -d_WINDOWS=1 -dWINDOWS_NT=1 -bt=nt -DCOMMAND_LINE_VERSION=1
CFLAGS    = $(OPTFLAGS) $(CCFLAGS) -i=$(CSLBASE) $(MPIFLAGS) -5r-zp4-ei-w3-bm-fhq
CFLAGS1   = $(OPTFLAGS) $(CCFLAGS1) -i=$(CSLBASE) $(MPIFLAGS) -5r-zp4-ei-w3-bm-fhq
CPP       = *wpp386
!ifeq __VERSION__ 11
CPPFLAGS  = $(CFLAGS) -xs
!else
CPPFLAGS  = $(CFLAGS) -xs-zo
!endif
ASM       = *wasm
ASMFLAGS  = -mf -5r -w4 -zq
LINK      = *wlink
LDEBUG    = debug all
LSYS      = nt_win
LSYSX     = nt
LIBS      = REFERENCE _wstart2_
LIBSX     =
LFLAGS    = system $(LSYS) option eliminate,stack=256K $(LDEBUG) file
LFLAGSX   = system $(LSYSX) option eliminate,stack=256K $(LDEBUG) file
ASMSRC    = imulwat.asm
ASMOBJ    = imulwat.obj
ASMOBJDEP = imulwat.obj
STORE     = -k8000
XSTORE    = -k8000
# The .SYMBOLIC directive tells Watcom "wmake" not to fuss when a
# target in the makefile does not correspond to a file that will get
# create by activating it.
SYMBOLIC  = .SYMBOLIC
OUT       = name
OUTOBJ    = -fo=
SYS       = syscwin
SYS1      = sysdos
WX        =
RM        = del
MKDIR     = mkdir
COPY      = copy
STRIP     = -echo
###########################################################################


###########################################################################
###########################################################################
#                                                                         #
# This is the main bulk of the "makefile" for building Reduce 3.7 and CSL #
# on MSDOS, Windows and Unix.  This part of the file expects a number of  #
# symbols to have been defined:                                           #
#                                                                         #
# CSLBASE   = file-path for CSLBASE directory                             #
# CC        = The C compiler to use                                       #
# CFLAGS    = Flags for C compiler when compiling CSL                     #
# LINK      = Linker to use                                               #
# LFLAGS    = Flags for linker                                            #
# LIBS      = Libraries to quote to linker                                #
# OUT       = "-o" or "-out:"   See link commands                         #
# OUTOBJ    = "-o" often : where to put object code from C compilation    #
# ASM       = The assembler to use                                        #
# ASMFLAGS  = Flags for the assembler                                     #
# ASMSRC    = Assembly code source file to use                            #
# ASMOBJ    = Object file for above (or NULL if no assembly used)         #
# ASMOBJDEP = Ditto, but may not be NULL                                  #
# SYS       = name of system-specific file (sysdos or sysnt etc)          #
# STORE     = Memory option to pass to CSL (-k2500 is minimum)            #
# XSTORE    = Memory for the rebuild job that generates C code            #
# RM        = del for DOS, = rm for Unix                                  #
# MKDIR     = mkdir                                                       #
# COPY      = copy for DOS, = cp for Unix                                 #
# STRIP     = echo for DOS, = strip for Unix                              #
# SYMBOLIC  = .SYMBOLIC is using Watcom's "make" utility                  #
# WX        = wx for Windows 3.1, null in all other cases                 #
#                                                                         #
# The master version of this file is called "makebase" and is used to     #
# create both DOS and Unix makefiles.  Use the Codemist "makemake"        #
# program to perform the conversion - eg                                  #
#     makemake -f makebase -o makemake.386 watcom dos                     #
#     makemake -f makebase -o Makefile.sgi sgi                            #
# Just "makemake -f makebase" gives list of systems supported             #
###########################################################################
###########################################################################



###########################################################################
###########################################################################
#
# The main final target is r37.img, the image file for full REDUCE.
# If you want to rebuild stage-by-stage (eg while testing), try the
# sequence
#    make slowr37.exe            compiles and links C coded kernel
#    make slowr37.img            makes bootstrap REDUCE
#                                 (roughly twice as slow as final one)
#                                 only used for system recompilation.
#    make profile                 runs tests, collects profile information.
#                                 This takes a long time!
#    make prof-inst               installs profile data
#    make c-code                  Create files u*.c and u*.lsp
#                                 out of hot-spot parts of REDUCE.
###########################################################################
# Note that only the steps from here downwards are usually needed
#
#    make r37.exe                final compilation of most of REDUCE
#    make r37.img                build final image file
#    make testall                 runs test files, output to log directory
#    make checkall                creates log\checkall.log
#
# (for Windows 95/98/NT only)
#    make r37c.exe                command-line version
#
###########################################################################
###########################################################################


#
# C is another name for CSLBASE, the directory that CSL source files live
# in. I introduce it here mainly because $(C) is so much more compact
# then $(CSLBASE).
#

C =     $(CSLBASE)

#
# DOBJS is a list of all the object files that are common to all variants
# on the system built here
#

DOBJS =		arith01.obj arith02.obj arith03.obj arith04.obj &
		arith05.obj arith06.obj arith07.obj arith08.obj &
		arith09.obj arith10.obj arith11.obj arith12.obj &
		char.obj csl.obj cslmpi.obj eval1.obj eval2.obj &
		eval3.obj eval4.obj fns1.obj fns2.obj fns3.obj &
		print.obj read.obj restart.obj $(ASMOBJ) &
		$(SYS).obj c_applic.obj c_text.obj &
		c_graph.obj c_render.obj c_viewpt.obj

CDOBJS =	arith01.obj,arith02.obj,arith03.obj,arith04.obj,&
		arith05.obj,arith06.obj,arith07.obj,arith08.obj,&
		arith09.obj,arith10.obj,arith11.obj,arith12.obj,&
		char.obj,csl.obj,cslmpi.obj,eval1.obj,eval2.obj,&
		eval3.obj,eval4.obj,fns1.obj,fns2.obj,fns3.obj,&
		print.obj,read.obj,restart.obj,$(ASMOBJ),&
		$(SYS).obj,c_applic.obj,c_text.obj,&
		c_graph.obj,c_render.obj,c_viewpt.obj

#
# OBJS adds in the files used when I am not building a demonstration-mode CSL
#

OBJS =		$(DOBJS) fasl.obj gc.obj preserve.obj

COBJS =		$(CDOBJS),fasl.obj,gc.obj,preserve.obj

#
# UOBJS come from that code that is compiled from Lisp into C
#

UOBJS =		u01.obj u02.obj u03.obj u04.obj u05.obj &
		u06.obj u07.obj u08.obj u09.obj u10.obj &
		u11.obj u12.obj

CUOBJS =	u01.obj,u02.obj,u03.obj,u04.obj,u05.obj,&
		u06.obj,u07.obj,u08.obj,u09.obj,u10.obj,&
		u11.obj,u12.obj


###########################################################################
###########################################################################

# This default target may be a dangerous one to use
# since it supposes that all the C code is up to date already.

default:	$(SYMBOLIC) &
		r37c.exe &
		r37.exe r37.img



###########################################################################
###########################################################################

r37.img:	r37.exe
	..\util\full37

r37.exe:	bytes.obj $(OBJS) &
		$(UOBJS)
	$(LINK) $(LFLAGS) bytes.obj,$(COBJS),$(CUOBJS) $(LIBS) $(OUT) r37.exe $(TAIL)
	wrc -i..\util -i$(C) -bt=nt ..\util\r37.rc r37.exe
	$(STRIP) r37.exe
	-$(MKDIR) log


#
# A few targets here may help me tidy up my filespace from time to time
#


clean: $(SYMBOLIC)
	-$(RM) slowr37.exe
	-$(RM) slowr37.img
	-$(RM) r37.exe
	-$(RM) r37.img
	-$(RM) csl.exe
	-$(RM) csl.img
	-$(RM) slowr37c.exe
	-$(RM) r37c.exe
	-$(RM) cslc.exe
	-$(RM) *.obj
	-$(MKDIR) log
	-$(RM) log\*.log


###########################################################################


csl.exe:	bytes.obj $(OBJS) &
		stubs.obj
	$(LINK) $(LFLAGS) bytes.obj,$(COBJS),stubs.obj $(LIBS) $(OUT) csl.exe $(TAIL)
	wrc -i$(C) -i$(C) -bt=nt $(C)\csl.rc csl.exe
	$(STRIP) csl.exe

slowr37.exe:	bytes1.obj $(OBJS) &
		stubs.obj
	$(LINK) $(LFLAGS) bytes1.obj,$(COBJS),stubs.obj $(LIBS) $(OUT) slowr37.exe $(TAIL)
	wrc -i$(C) -i$(C) -bt=nt $(C)\csl.rc slowr37.exe
	$(STRIP) slowr37.exe
	-$(MKDIR) log


slowr37.img:	slowr37.exe
	..\util\boot37

profile:	slowr37.img $(SYMBOLIC)
	..\util\profile

prof-inst:	profile.dat $(SYMBOLIC)
	$(COPY) profile.dat ..\csl-c
	-$(RM) profile.dat

c-code:	slowr37.img $(SYMBOLIC)
	..\util\c-code37

testslow:	slowr37.img $(SYMBOLIC)
	..\util\testslow

testall:	r37.img $(SYMBOLIC)
	..\util\testrest

checkall:	r37.img $(SYMBOLIC)
	..\util\checkall

patchup:	r37.img $(SYMBOLIC)
	..\util\patchup

cleanlog:	$(SYMBOLIC)
	-$(RM) ../../../log/*.rlg



csl.img:	csl.exe $(C)\compat.lsp $(C)\compiler.lsp &
			$(C)\ccomp.lsp $(C)\extras.lsp
	-$(RM) csl.img
	$(WX) .\csl $(STORE) -v -z $(C)\build0.lsp &
		-D@cslbase="$(C)" -- log\cslimg.log

#
# "make lispfile"
#           recreates compiler.lsp, extras.lsp and ccomp.lsp from
#           the corresponding master sources which are held in RLISP
#           form.  Temporarily builds an RLISP parser on the way.
#       NB: only for system maintainance use.

lispfile:	csl.exe csl.img $(C)\lispfile.lsp $(SYMBOLIC)
	$(WX) .\csl $(STORE) -v -z $(C)\lispfile.lsp &
		-D@cslbase="$(C)" -- log\lispfile.log

signature:	$(C)\version.hhh register.key $(SYMBOLIC)
	filesign -u $(C)\version.hhh $(C)\version.h Developer or tester


############################################################################
# Now rules for re-compiling the main collection of CSL source files. I
# write each case out individually since that makes the makefile less
# delicate than one that relies on setting up general rules - and I want this
# file to work on several different systems.
#

# There is a special nasty with the Watcom assembler (at least version
# 10.5) in that tab characters on the command line upset it, so I MUST
# have the command given here all on one line in that case.

$(ASMOBJDEP):	$(C)\$(ASMSRC)
	$(ASM) $(ASMFLAGS) $(C)\$(ASMSRC)

arith01.obj:	$(C)\arith01.c $(C)\arith.h $(C)\tags.h $(C)\machine.h &
		$(C)\externs.h $(C)\sys.h $(C)\cslerror.h
	$(CC) $(CFLAGS) &
		$(C)\arith01.c

arith02.obj:	$(C)\arith02.c $(C)\arith.h $(C)\tags.h $(C)\machine.h &
		$(C)\externs.h $(C)\sys.h $(C)\cslerror.h
	$(CC) $(CFLAGS) &
		$(C)\arith02.c

arith03.obj:	$(C)\arith03.c $(C)\arith.h $(C)\tags.h $(C)\machine.h &
		$(C)\externs.h $(C)\sys.h $(C)\cslerror.h
	$(CC) $(CFLAGS) &
		$(C)\arith03.c

arith04.obj:	$(C)\arith04.c $(C)\arith.h $(C)\tags.h $(C)\machine.h &
		$(C)\externs.h $(C)\sys.h $(C)\cslerror.h
	$(CC) $(CFLAGS) &
		$(C)\arith04.c

arith05.obj:	$(C)\arith05.c $(C)\arith.h $(C)\tags.h $(C)\machine.h &
		$(C)\externs.h $(C)\sys.h $(C)\cslerror.h $(C)\stream.h
	$(CC) $(CFLAGS) &
		$(C)\arith05.c

arith06.obj:	$(C)\arith06.c $(C)\arith.h $(C)\tags.h $(C)\machine.h &
		$(C)\externs.h $(C)\sys.h $(C)\cslerror.h $(C)\entries.h
	$(CC) $(CFLAGS) &
		$(C)\arith06.c

arith07.obj:	$(C)\arith07.c $(C)\arith.h $(C)\tags.h $(C)\machine.h &
		$(C)\externs.h $(C)\sys.h $(C)\cslerror.h
	$(CC) $(CFLAGS) &
		$(C)\arith07.c

arith08.obj:	$(C)\arith08.c $(C)\arith.h $(C)\tags.h $(C)\machine.h &
		$(C)\externs.h $(C)\sys.h $(C)\cslerror.h $(C)\entries.h
	$(CC) $(CFLAGS) &
		$(C)\arith08.c

arith09.obj:	$(C)\arith09.c $(C)\arith.h $(C)\tags.h $(C)\machine.h &
		$(C)\externs.h $(C)\sys.h $(C)\cslerror.h
	$(CC) $(CFLAGS) &
		$(C)\arith09.c

arith10.obj:	$(C)\arith10.c $(C)\arith.h $(C)\tags.h $(C)\machine.h &
		$(C)\externs.h $(C)\sys.h $(C)\cslerror.h $(C)\entries.h
	$(CC) $(CFLAGS) &
		$(C)\arith10.c

arith11.obj:	$(C)\arith11.c $(C)\arith.h $(C)\tags.h $(C)\machine.h &
		$(C)\externs.h $(C)\sys.h $(C)\cslerror.h
	$(CC) $(CFLAGS) &
		$(C)\arith11.c

arith12.obj:	$(C)\arith12.c $(C)\arith.h $(C)\tags.h $(C)\machine.h &
		$(C)\externs.h $(C)\sys.h $(C)\cslerror.h $(C)\entries.h
	$(CC) $(CFLAGS) &
		$(C)\arith12.c

bytes.obj:	$(C)\bytes1.c $(C)\bytes.c $(C)\tags.h $(C)\machine.h &
		$(C)\externs.h $(C)\sys.h $(C)\cslerror.h &
		$(C)\bytes.h $(C)\arith.h
	$(CC) $(CFLAGS) &
		$(C)\bytes.c

bytes1.obj:	$(C)\bytes1.c $(C)\bytes.c $(C)\tags.h $(C)\machine.h &
		$(C)\externs.h $(C)\sys.h $(C)\cslerror.h &
		$(C)\bytes.h $(C)\arith.h
	$(CC) $(CFLAGS) &
		$(C)\bytes1.c

#
# The target "bytes1a.o" recompiles bytes1.c, but with the flag set that
# arranges that the number of GET operations performed and the associated
# indicators will be recorded, so that (bytecounts) will display statistics
# about it. This slows things down considerably, but can help when you are in
# the process of deciding which indicators are specified as "fast" ones.
#

bytes1a.obj:	$(C)\bytes1.c $(C)\bytes.c $(C)\tags.h $(C)\machine.h &
		$(C)\externs.h $(C)\sys.h $(C)\cslerror.h &
		$(C)\bytes.h $(C)\arith.h
	$(CC) $(CFLAGS) -DRECORD_GET=1 &
		$(C)\bytes1.c

char.obj:	$(C)\char.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\sys.h $(C)\cslerror.h $(C)\entries.h
	$(CC) $(CFLAGS) &
		$(C)\char.c

csl.obj:	$(C)\csl.c $(C)\tags.h $(C)\machine.h $(C)\externs.h $(C)\version.h &
		$(C)\sys.h $(C)\cslerror.h $(C)\entries.h $(C)\stream.h $(C)\sockhdr.h
	$(CC) $(CFLAGS) &
		$(C)\csl.c

r37front.obj:	$(C)\r37front.c $(C)\tags.h $(C)\machine.h $(C)\externs.h $(C)\version.h &
		$(C)\sys.h $(C)\cslerror.h $(C)\entries.h $(C)\stream.h $(C)\sockhdr.h
	$(CC) $(CFLAGS) &
		$(C)\r37front.c


# the cwin window manager package is for use with Watcom C only (at present)

c_applic.obj:	$(C)\c_applic.cpp $(C)\cwin.h $(C)\cwin.hpp $(C)\cwinres.h
	$(CPP) $(CPPFLAGS) &
		$(C)\c_applic.cpp

c_applic1.obj:	$(C)\c_applic.cpp $(C)\cwin.h $(C)\cwin.hpp $(C)\cwinres.h
	$(CPP) $(CPPFLAGS) -DDEMOVERSION=1 &
                $(OUTOBJ)c_applic1.obj
		$(C)\c_applic.cpp

c_text.obj:	$(C)\c_text.cpp $(C)\cwin.h $(C)\cwin.hpp $(C)\cwinres.h
	$(CPP) $(CPPFLAGS) &
		$(C)\c_text.cpp

c_graph.obj:	$(C)\c_graph.cpp $(C)\cwin.h $(C)\cwin.hpp $(C)\cwinres.h
	$(CPP) $(CPPFLAGS) &
		$(C)\c_graph.cpp

c_render.obj:	$(C)\c_render.cpp $(C)\cwin.h $(C)\cwin.hpp $(C)\cwinres.h
	$(CPP) $(CPPFLAGS) &
		$(C)\c_render.cpp

c_viewpt.obj:	$(C)\c_viewpt.cpp $(C)\cwin.h $(C)\cwin.hpp $(C)\cwinres.h
	$(CPP) $(CPPFLAGS) &
		$(C)\c_viewpt.cpp



eval1.obj:	$(C)\eval1.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\sys.h $(C)\cslerror.h $(C)\arith.h $(C)\entries.h
	$(CC) $(CFLAGS) &
		$(C)\eval1.c

eval2.obj:	$(C)\eval2.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\sys.h $(C)\cslerror.h $(C)\arith.h $(C)\entries.h
	$(CC) $(CFLAGS) &
		$(C)\eval2.c

eval3.obj:	$(C)\eval3.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\sys.h $(C)\cslerror.h $(C)\entries.h
	$(CC) $(CFLAGS) &
		$(C)\eval3.c

eval4.obj:	$(C)\eval4.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\sys.h $(C)\cslerror.h $(C)\arith.h
	$(CC) $(CFLAGS) &
		$(C)\eval4.c

fasl.obj:	$(C)\fasl.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\sys.h $(C)\cslerror.h $(C)\arith.h
	$(CC) $(CFLAGS) &
		$(C)\fasl.c

fns1.obj:	$(C)\fns1.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\sys.h $(C)\cslerror.h $(C)\entries.h
	$(CC) $(CFLAGS) &
		$(C)\fns1.c

fns2.obj:	$(C)\fns2.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\sys.h $(C)\cslerror.h $(C)\read.h $(C)\entries.h &
		$(C)\sockhdr.h
	$(CC) $(CFLAGS) &
		$(C)\fns2.c

fns3.obj:	$(C)\fns3.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\sys.h $(C)\cslerror.h $(C)\read.h $(C)\entries.h
	$(CC) $(CFLAGS) &
		$(C)\fns3.c

gc.obj:	$(C)\gc.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\sys.h $(C)\cslerror.h
	$(CC) $(CFLAGS) &
		$(C)\gc.c

#
# For each major target I have one file that is system specific - eg
# sysdos.c, sysunix.c, ...
#

$(SYS).obj:	$(C)\$(SYS).c $(C)\machine.h $(C)\externs.h &
		$(C)\sys.h $(C)\fileops.c $(C)\scandir.c $(C)\version.h &
		$(C)\filename.c
	$(CC) $(CFLAGS) &
		$(C)\$(SYS).c

preserve.obj:	$(C)\preserve.c $(C)\tags.h $(C)\machine.h $(C)\stream.h &
		$(C)\externs.h $(C)\sys.h $(C)\cslerror.h $(C)\read.h $(C)\version.h
	$(CC) $(CFLAGS) &
		$(C)\preserve.c

print.obj:	$(C)\print.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\sys.h $(C)\cslerror.h $(C)\read.h &
		$(C)\arith.h $(C)\entries.h $(C)\stream.h $(C)\sockhdr.h
	$(CC) $(CFLAGS) &
		$(C)\print.c

read.obj:	$(C)\read.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\sys.h $(C)\cslerror.h $(C)\read.h &
		$(C)\arith.h $(C)\entries.h $(C)\stream.h $(C)\sockhdr.h
	$(CC) $(CFLAGS) &
		$(C)\read.c

restart.obj:	$(C)\restart.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\sys.h $(C)\cslerror.h $(C)\read.h $(C)\version.h &
		$(C)\arith.h $(C)\entries.h $(C)\stream.h
	$(CC) $(CFLAGS) &
		$(C)\restart.c

stubs.obj:	$(C)\stubs.c $(C)\machine.h $(C)\externs.h $(C)\sys.h &
		$(C)\tags.h $(C)\cslerror.h
	$(CC) $(CFLAGS) &
		$(C)\stubs.c

cslmpi.obj:	$(C)\cslmpi.c $(C)\machine.h $(C)\externs.h $(C)\sys.h &
		$(C)\mpipack.c $(C)\tags.h $(C)\cslerror.h
	$(CC) $(CFLAGS) &
		$(C)\cslmpi.c


###########################################################################

u01.obj:	..\csl-c\u01.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\cslerror.h $(C)\entries.h
	$(CC) $(CFLAGS) &
		..\csl-c\u01.c

u02.obj:	..\csl-c\u02.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\cslerror.h $(C)\entries.h
	$(CC) $(CFLAGS) &
		..\csl-c\u02.c

u03.obj:	..\csl-c\u03.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\cslerror.h $(C)\entries.h
	$(CC) $(CFLAGS) &
		..\csl-c\u03.c

u04.obj:	..\csl-c\u04.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\cslerror.h $(C)\entries.h
	$(CC) $(CFLAGS) &
		..\csl-c\u04.c

u05.obj:	..\csl-c\u05.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\cslerror.h $(C)\entries.h
	$(CC) $(CFLAGS) &
		..\csl-c\u05.c

u06.obj:	..\csl-c\u06.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\cslerror.h $(C)\entries.h
	$(CC) $(CFLAGS) &
		..\csl-c\u06.c

u07.obj:	..\csl-c\u07.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\cslerror.h $(C)\entries.h
	$(CC) $(CFLAGS) &
		..\csl-c\u07.c

u08.obj:	..\csl-c\u08.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\cslerror.h $(C)\entries.h
	$(CC) $(CFLAGS) &
		..\csl-c\u08.c

u09.obj:	..\csl-c\u09.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\cslerror.h $(C)\entries.h
	$(CC) $(CFLAGS) &
		..\csl-c\u09.c

u10.obj:	..\csl-c\u10.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\cslerror.h $(C)\entries.h
	$(CC) $(CFLAGS) &
		..\csl-c\u10.c

u11.obj:	..\csl-c\u11.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\cslerror.h $(C)\entries.h
	$(CC) $(CFLAGS) &
		..\csl-c\u11.c

u12.obj:	..\csl-c\u12.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\cslerror.h $(C)\entries.h
	$(CC) $(CFLAGS) &
		..\csl-c\u12.c

#
# I also arrange to be able to make a command-line version of the system.
#
DOBJSX =		arith01x.obj arith02x.obj arith03x.obj arith04x.obj &
		arith05x.obj arith06x.obj arith07x.obj arith08x.obj &
		arith09x.obj arith10x.obj arith11x.obj arith12x.obj &
		charx.obj cslx.obj cslmpix.obj eval1x.obj eval2x.obj &
		eval3x.obj eval4x.obj fns1x.obj fns2x.obj fns3x.obj &
		printx.obj readx.obj restartx.obj $(ASMOBJ) &
		$(SYS1)x.obj

CDOBJSX =	arith01x.obj,arith02x.obj,arith03x.obj,arith04x.obj,&
		arith05x.obj,arith06x.obj,arith07x.obj,arith08x.obj,&
		arith09x.obj,arith10x.obj,arith11x.obj,arith12x.obj,&
		charx.obj,cslx.obj,cslmpix.obj,eval1x.obj,eval2x.obj,&
		eval3x.obj,eval4x.obj,fns1x.obj,fns2x.obj,fns3x.obj,&
		printx.obj,readx.obj,restartx.obj,$(ASMOBJ),&
		$(SYS1)x.obj

#
# OBJSX adds in the files used when I am not building a demonstration-mode CSL
#

OBJSX =		$(DOBJSX) faslx.obj gcx.obj preservex.obj

COBJSX =		$(CDOBJSX),faslx.obj,gcx.obj,preservex.obj

#
# UOBJSX come from that code that is compiled from Lisp into C
#

UOBJSX =		u01x.obj u02x.obj u03x.obj u04x.obj u05x.obj &
		u06x.obj u07x.obj u08x.obj u09x.obj u10x.obj &
		u11x.obj u12x.obj

CUOBJSX =	u01x.obj,u02x.obj,u03x.obj,u04x.obj,u05x.obj,&
		u06x.obj,u07x.obj,u08x.obj,u09x.obj,u10x.obj,&
		u11x.obj,u12x.obj

cslc.exe:	bytesx.obj $(OBJSX) &
		stubsx.obj
	$(LINK) $(LFLAGSX) bytesx.obj,$(COBJSX),stubsx.obj $(LIBSX) $(OUT) cslc.exe $(TAILX)
	wrc -i$(C) -i$(C) -bt=nt $(C)\csl.rc cslc.exe
	$(STRIP) cslc.exe

slowr37c.exe:	bytes1x.obj $(OBJSX) &
		stubsx.obj
	$(LINK) $(LFLAGSX) bytes1x.obj,$(COBJSX),stubsx.obj $(LIBSX) $(OUT) slowr37c.exe $(TAILX)
	wrc -i$(C) -i$(C) -bt=nt $(C)\csl.rc slowr37c.exe
	$(STRIP) slowr37c.exe
	-$(MKDIR) log


r37c.exe:	bytesx.obj $(OBJSX) &
		$(UOBJSX)
	$(LINK) $(LFLAGSX) bytesx.obj,$(COBJSX),$(CUOBJSX) $(LIBSX) $(OUT) r37c.exe $(TAILX)
	wrc -i..\util -i$(C) -bt=nt ..\util\r37.rc r37c.exe
	$(STRIP) r37c.exe
	-$(MKDIR) log



arith01x.obj:	$(C)\arith01.c $(C)\arith.h $(C)\tags.h $(C)\machine.h &
		$(C)\externs.h $(C)\sys.h $(C)\cslerror.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)arith01x.obj &
		$(C)\arith01.c

arith02x.obj:	$(C)\arith02.c $(C)\arith.h $(C)\tags.h $(C)\machine.h &
		$(C)\externs.h $(C)\sys.h $(C)\cslerror.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)arith02x.obj &
		$(C)\arith02.c

arith03x.obj:	$(C)\arith03.c $(C)\arith.h $(C)\tags.h $(C)\machine.h &
		$(C)\externs.h $(C)\sys.h $(C)\cslerror.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)arith03x.obj &
		$(C)\arith03.c

arith04x.obj:	$(C)\arith04.c $(C)\arith.h $(C)\tags.h $(C)\machine.h &
		$(C)\externs.h $(C)\sys.h $(C)\cslerror.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)arith04x.obj &
		$(C)\arith04.c

arith05x.obj:	$(C)\arith05.c $(C)\arith.h $(C)\tags.h $(C)\machine.h &
		$(C)\externs.h $(C)\sys.h $(C)\cslerror.h $(C)\stream.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)arith05x.obj &
		$(C)\arith05.c

arith06x.obj:	$(C)\arith06.c $(C)\arith.h $(C)\tags.h $(C)\machine.h &
		$(C)\externs.h $(C)\sys.h $(C)\cslerror.h $(C)\entries.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)arith06x.obj &
		$(C)\arith06.c

arith07x.obj:	$(C)\arith07.c $(C)\arith.h $(C)\tags.h $(C)\machine.h &
		$(C)\externs.h $(C)\sys.h $(C)\cslerror.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)arith07x.obj &
		$(C)\arith07.c

arith08x.obj:	$(C)\arith08.c $(C)\arith.h $(C)\tags.h $(C)\machine.h &
		$(C)\externs.h $(C)\sys.h $(C)\cslerror.h $(C)\entries.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)arith08x.obj &
		$(C)\arith08.c

arith09x.obj:	$(C)\arith09.c $(C)\arith.h $(C)\tags.h $(C)\machine.h &
		$(C)\externs.h $(C)\sys.h $(C)\cslerror.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)arith09x.obj &
		$(C)\arith09.c

arith10x.obj:	$(C)\arith10.c $(C)\arith.h $(C)\tags.h $(C)\machine.h &
		$(C)\externs.h $(C)\sys.h $(C)\cslerror.h $(C)\entries.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)arith10x.obj &
		$(C)\arith10.c

arith11x.obj:	$(C)\arith11.c $(C)\arith.h $(C)\tags.h $(C)\machine.h &
		$(C)\externs.h $(C)\sys.h $(C)\cslerror.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)arith11x.obj &
		$(C)\arith11.c

arith12x.obj:	$(C)\arith12.c $(C)\arith.h $(C)\tags.h $(C)\machine.h &
		$(C)\externs.h $(C)\sys.h $(C)\cslerror.h $(C)\entries.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)arith12x.obj &
		$(C)\arith12.c

bytesx.obj:	$(C)\bytes1.c $(C)\bytes.c $(C)\tags.h $(C)\machine.h &
		$(C)\externs.h $(C)\sys.h $(C)\cslerror.h &
		$(C)\bytes.h $(C)\arith.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)bytesx.obj &
		$(C)\bytes.c

bytes1x.obj:	$(C)\bytes1.c $(C)\bytes.c $(C)\tags.h $(C)\machine.h &
		$(C)\externs.h $(C)\sys.h $(C)\cslerror.h &
		$(C)\bytes.h $(C)\arith.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)bytes1x.obj &
		$(C)\bytes1.c

#
# The target "bytes1ax.o" recompiles bytes1.c, but with the flag set that
# arranges that the number of GET operations performed and the associated
# indicators will be recorded, so that (bytecounts) will display statistics
# about it. This slows things down considerably, but can help when you are in
# the process of deciding which indicators are specified as "fast" ones.
#

bytes1ax.obj:	$(C)\bytes1.c $(C)\bytes.c $(C)\tags.h $(C)\machine.h &
		$(C)\externs.h $(C)\sys.h $(C)\cslerror.h &
		$(C)\bytes.h $(C)\arith.h
	$(CC) $(CFLAGS1) -DRECORD_GET=1 &
		$(OUTOBJ)bytes1x.obj &
		$(C)\bytes1.c

charx.obj:	$(C)\char.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\sys.h $(C)\cslerror.h $(C)\entries.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)charx.obj &
		$(C)\char.c

cslx.obj:	$(C)\csl.c $(C)\tags.h $(C)\machine.h $(C)\externs.h $(C)\version.h &
		$(C)\sys.h $(C)\cslerror.h $(C)\entries.h $(C)\stream.h $(C)\sockhdr.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)cslx.obj &
		$(C)\csl.c

eval1x.obj:	$(C)\eval1.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\sys.h $(C)\cslerror.h $(C)\arith.h $(C)\entries.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)eval1x.obj &
		$(C)\eval1.c

eval2x.obj:	$(C)\eval2.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\sys.h $(C)\cslerror.h $(C)\arith.h $(C)\entries.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)eval2x.obj &
		$(C)\eval2.c

eval3x.obj:	$(C)\eval3.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\sys.h $(C)\cslerror.h $(C)\entries.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)eval3x.obj &
		$(C)\eval3.c

eval4x.obj:	$(C)\eval4.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\sys.h $(C)\cslerror.h $(C)\arith.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)eval4x.obj &
		$(C)\eval4.c

faslx.obj:	$(C)\fasl.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\sys.h $(C)\cslerror.h $(C)\arith.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)faslx.obj &
		$(C)\fasl.c

fns1x.obj:	$(C)\fns1.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\sys.h $(C)\cslerror.h $(C)\entries.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)fns1x.obj &
		$(C)\fns1.c

fns2x.obj:	$(C)\fns2.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\sys.h $(C)\cslerror.h $(C)\read.h $(C)\entries.h &
		$(C)\sockhdr.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)fns2x.obj &
		$(C)\fns2.c

fns3x.obj:	$(C)\fns3.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\sys.h $(C)\cslerror.h $(C)\read.h $(C)\entries.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)fns3x.obj &
		$(C)\fns3.c

gcx.obj:	$(C)\gc.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\sys.h $(C)\cslerror.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)gcx.obj &
		$(C)\gc.c

#
# For each major target I have one file that is system specific - eg
# sysdos.c, sysunix.c, ...
#

$(SYS1)x.obj:	$(C)\$(SYS1).c $(C)\machine.h $(C)\externs.h &
		$(C)\sys.h $(C)\fileops.c $(C)\scandir.c $(C)\version.h &
		$(C)\filename.c
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)$(SYS1)x.obj &
		$(C)\$(SYS1).c

preservex.obj:	$(C)\preserve.c $(C)\tags.h $(C)\machine.h $(C)\stream.h &
		$(C)\externs.h $(C)\sys.h $(C)\cslerror.h $(C)\read.h $(C)\version.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)preservex.obj &
		$(C)\preserve.c

printx.obj:	$(C)\print.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\sys.h $(C)\cslerror.h $(C)\read.h &
		$(C)\arith.h $(C)\entries.h $(C)\stream.h $(C)\sockhdr.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)printx.obj &
		$(C)\print.c

readx.obj:	$(C)\read.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\sys.h $(C)\cslerror.h $(C)\read.h &
		$(C)\arith.h $(C)\entries.h $(C)\stream.h $(C)\sockhdr.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)readx.obj &
		$(C)\read.c

restartx.obj:	$(C)\restart.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\sys.h $(C)\cslerror.h $(C)\read.h $(C)\version.h &
		$(C)\arith.h $(C)\entries.h $(C)\stream.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)restartx.obj &
		$(C)\restart.c

stubsx.obj:	$(C)\stubs.c $(C)\machine.h $(C)\externs.h $(C)\sys.h &
		$(C)\tags.h $(C)\cslerror.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)stubsx.obj &
		$(C)\stubs.c

cslmpix.obj:	$(C)\cslmpi.c $(C)\machine.h $(C)\externs.h $(C)\sys.h &
		$(C)\mpipack.c $(C)\tags.h $(C)\cslerror.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)cslmpix.obj &
		$(C)\cslmpi.c


###########################################################################

u01x.obj:	..\csl-c\u01.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\cslerror.h $(C)\entries.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)u01x.obj &
		..\csl-c\u01.c

u02x.obj:	..\csl-c\u02.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\cslerror.h $(C)\entries.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)u02x.obj &
		..\csl-c\u02.c

u03x.obj:	..\csl-c\u03.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\cslerror.h $(C)\entries.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)u03x.obj &
		..\csl-c\u03.c

u04x.obj:	..\csl-c\u04.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\cslerror.h $(C)\entries.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)u04x.obj &
		..\csl-c\u04.c

u05x.obj:	..\csl-c\u05.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\cslerror.h $(C)\entries.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)u05x.obj &
		..\csl-c\u05.c

u06x.obj:	..\csl-c\u06.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\cslerror.h $(C)\entries.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)u06x.obj &
		..\csl-c\u06.c

u07x.obj:	..\csl-c\u07.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\cslerror.h $(C)\entries.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)u07x.obj &
		..\csl-c\u07.c

u08x.obj:	..\csl-c\u08.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\cslerror.h $(C)\entries.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)u08x.obj &
		..\csl-c\u08.c

u09x.obj:	..\csl-c\u09.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\cslerror.h $(C)\entries.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)u09x.obj &
		..\csl-c\u09.c

u10x.obj:	..\csl-c\u10.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\cslerror.h $(C)\entries.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)u10x.obj &
		..\csl-c\u10.c

u11x.obj:	..\csl-c\u11.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\cslerror.h $(C)\entries.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)u11x.obj &
		..\csl-c\u11.c

u12x.obj:	..\csl-c\u12.c $(C)\tags.h $(C)\machine.h $(C)\externs.h &
		$(C)\cslerror.h $(C)\entries.h
	$(CC) $(CFLAGS1) &
		$(OUTOBJ)u12x.obj &
		..\csl-c\u12.c



# end of makefile
