#!/bin/sh

# mkmf_bc - create a Borland C makefile.  This is executed by the
# top-level Makefile, when specifying a target of "makefile.bc".
# Environment variables are set up by Makefile.



# set some default locations etc.

cat <<ENDOFIT
# Borland C Makefile for DeviceMate Target Communications Library
CC = bcc

# Defile locations for Borland C libraries and include files
BCINC = -IE:\bc45\include
BCLIBDIR = E:\bc45\lib
BCLIBS = -L\$(BCLIBDIR)

# Locations of TCL
INC = -I.
LIBDIR = E:\lib
LIBS = -L\$(LIBDIR)

other_objs = tc.obj i386ser.obj tc_386ex.obj
other_hdrs = tc.h tc_386ex.h
tc_objs = ${tc_bcobjs}
tc_hdrs = ${tc_hdrs}

#CFLAGS = -v \$(INC) \$(BCINC) \$(LIBS) \$(BCLIBS)
CFLAGS = -ml -d -RT- -M -Os \$(INC) \$(BCINC) \$(LIBS) \$(BCLIBS)

all:	${tc_demo_exe}

ENDOFIT

# Loop over all target executables, emitting makefile constructs

for i in ${DEMOS}; do
x=${i}_x
extralibs=
if [ "$i" == "var" ]; then
	extralibs="mathl.lib emu.lib"
elif [ "$i" == "tcp_time" ]; then
	extralibs="mathl.lib emu.lib"
fi
cat <<ENDOFIT
${i}.exe:	\$(tc_objs) ${i}.obj \$(other_objs)
	tlink \$(LIBS) \$(BCLIBS) @&&!
C0l.obj ${!x} ${i}.obj \$(other_objs)
${i}.exe
${i}.map
Cl.lib ${extralibs}
!

${i}.obj:	${i}.c \$(tc_hdrs) \$(other_hdrs)

ENDOFIT

done


# Loop over all library objects, emitting makefile constructs

for i in ${TC_LIBEXE}; do

cat <<ENDOFIT
${i}.obj:	${i}.c \$(tc_hdrs)

ENDOFIT

done


# Create a few ad-hoc targets
cat <<ENDOFIT

tc.obj:		tc.c tc.h ${CONFIG} tc_defs.h
tc_386ex.obj:	tc_386ex.c ${CONFIG} tc_defs.h \$(other_hdrs)
i386ser.obj:	i386ser.c ${CONFIG} tc_defs.h \$(other_hdrs)

clean:
	del *.obj
	del *.map
ENDOFIT
for i in ${tc_demo_exe}; do
echo "	del ${i}"
done
echo ""

