#
# Borland C++ 3.1 makefile for PCOak
#
# Targets:
#	pcoak.exe	Make the PCOak executable (default)
#	config		Create/update the BCC options/config file pcoak.cfg
#
# *** Make sure the BC_DIR macro is set correctly for your system! ***
#

!if !$d(BC_DIR)
BC_DIR	= c:\borlandc		# Top-level BC++ directory: alter if required
!endif

CC	= $(BC_DIR)\bin\bcc	# Full path to compiler
TLINK	= $(BC_DIR)\bin\tlink	# Full path to linker
TASM	= $(BC_DIR)\bin\tasm	# Full path to assembler
LIBPATH	= $(BC_DIR)\lib		# Compiler library directory
INCPATH	= $(BC_DIR)\include	# Compiler include directory

BCC_CFG	= pcoak.cfg		# BC++ 3.1 options/config file
AFLAGS  = /zn /DMODL=large /JMASM51 /mx /z /w2	# TASM options

#
# Implicit rules
#
.AUTODEPEND			# Use auto-dependency info for .c -> .obj

.c.obj:
	$(CC) +$(BCC_CFG) -c {$< }

.cas.obj:
	$(CC) +$(BCC_CFG) -c {$< }

.asm.obj:
	$(TASM) $(AFLAGS) $<, $@;

#
# List of objects required for the executable
#
EXE_OBJ =	\
keymake.obj	\
notepad.obj	\
inthandl.obj	\
lpr.obj		\
copymail.obj	\
maxgets.obj	\
help.obj	\
dirutil.obj	\
header.obj	\
bmutil.obj	\
tcmain.obj	\
send.obj	\
tcutil.obj	\
version.obj	\
bell.obj	\
wildmat.obj	\
alias.obj	\
miscutil.obj	\
ustring.obj	\
parser.obj	\
tzset.obj	\
dates.obj	\
display.obj	\
config.obj	\
str.obj		\
weedout.obj	\
system.obj	\
spawn.obj	\
checkpat.obj	\
exec.obj

#
# Explicit rules: default target is PCOak executable pcoak.exe
#

#
# Linker options:
#	/v-		exclude debugging info
#	/s		full map file
#	/c		symbols are case significant
#	/P-		turn off code segment packing
#	/L$(LIBPATH)	path for library files
#
pcoak.exe: $(CC).exe $(EXE_OBJ)
	$(TLINK) /v-/s/c/P-/L$(LIBPATH) @&&|
c0l.obj+			# Large memory model startup object
$(EXE_OBJ)			# List of object files
$@				# Executable name
pcoak				# Map file
cl.lib				# Libraries
|

#
# tzset.c needs -d- (don't merge literal strings) and some segment naming
# options, to make sure it replaces the standard library stuff properly;
# use an with-commands explicit rule to override the normal implicit rules.
# Make it depend on the config file as well as its normal dependents
#
TZFLAGS = -d- -zC_TEXT -zR_DATA -zTDATA
tzset.obj: tzset.c tzfile.h $(BCC_CFG)
	$(CC) +$(BCC_CFG) $(TZFLAGS) -c $*.c

#
# Make all the objects except tzset.obj depend on the config file (as well as
# their .AUTODEPEND dependents), using the normal implicit rules for building
#
$(EXE_OBJ:tzset.obj=): $(BCC_CFG)    # BC++ objects depend on BCC config file

#
# Compiler options:
#	-w		all warnings on
#	-ml		large memory model
#	-f-		no floating point present
#	-K		char is unsigned char
#	-v-		debugging off
#	-Z		enable register load suppression optimisation
#	-d		merge literal strings
#	-vi		expand C++ inline functions inline
#	-I$(INCPATH)	path for include files
#	-L$(LIBPATH)	path for library files
#	-P-.C		compile .c files as C
#
config:
	command.com /c copy &&|
-w
-ml
-f-
-K
-v-
-Z
-d
-vi
-I$(INCPATH)
-L$(LIBPATH)
-P-.C
| $(BCC_CFG)
