#
# Makefile for COMMKIT 
#
# Notes:
# - all object modules and executables have been created using Turbo C++ 3.0
#
# - if you want to recompile with Turbo C, everything must be recompiled 
#   since Turbo C++ object modules cannot link with Turbo C modules.  So, 
#   you must do the following:
#   * first touch *.c
#   * then type make
#   * this will recreate all modules 
#
# - all compiles explicity use the .c extension (for Borland/Turbo C++)
#

obj: ipc.exe \
	 pt2pt.exe analyser.exe \
	 s&wex.exe s&wdisk.exe external.exe internal.exe statmux.exe wanex.exe \
	 busex.exe ringex.exe \
	 ringsox.exe bussox.exe wansox.exe ringb.exe busb.exe

#
# Common software (Chapter 2):
#
#  commkit  - low level software
#  srcalls  - send/receive call software
#
# Note: the warning generated by the Turbo C compiler when compiling commkit.c
#       refer to the `bp' register in send_ih() and recv_ih().  The register 
#       is not used in either of these subroutines, hence the warning.
#

commkit.obj: commkit.c srcalls.obj general.h devices.h ascii.h commkit.h
	tcc -ms -c commkit.c

srcalls.obj: srcalls.c
	tcc -ms -c srcalls.c

#
# CRC utilities (Chapter 6):
#
#  crctbl   - the crc utility (table look-up)
#  crcsr    - the crc utility (shift register)
#

crctbl.obj: crctbl.c
	tcc -ms -c crctbl.c

crcsr.obj: crcsr.c
	tcc -ms -c crcsr.c

#
# Interprocess communication example (Chapter 2): ipc.c
#

ipc.exe: ipc.obj commkit.obj srcalls.obj 
	tlink \tc\lib\c0s ipc commkit srcalls, ipc, , \
	\tc\lib\emu \tc\lib\maths \tc\lib\cs

ipc.obj: ipc.c general.h ascii.h devices.h
	tcc -ms -c ipc.c

#
# Point-to-point software (Chapter 3): pt2pt.c
#

pt2pt.exe: pt2pt.obj commkit.obj srcalls.obj
	tlink \tc\lib\c0s pt2pt commkit srcalls, pt2pt, , \
	\tc\lib\emu \tc\lib\maths \tc\lib\cs

pt2pt.obj: pt2pt.c general.h ascii.h devices.h
	tcc -ms -c pt2pt.c

#
# Network analyser tool (Chapter 5): analyser.c
#

analyser.exe: analyser.obj commkit.obj srcalls.obj
	tlink \tc\lib\c0s analyser commkit srcalls, analyser, , \
	\tc\lib\emu \tc\lib\maths \tc\lib\cs

analyser.obj: analyser.c general.h ascii.h devices.h
	tcc -ms -c analyser.c

#
# Stop and wait protocol software (Chapter 6):
#
#  s&w.h     - definitions for s&wlow.c
#  s&wlow.c  - low level driver
#  s&wex.c   - message transmission example
#
# File transfer software (Chapter 7): s&wdisk.c
#
# All `high-level' software must be linked with s&wlow.obj.
#

s&wex.exe: s&wex.obj s&wlow.obj commkit.obj srcalls.obj crcsr.obj 
	tlink \tc\lib\c0s s&wex s&wlow commkit srcalls crcsr, s&wex, , \
	\tc\lib\emu \tc\lib\maths \tc\lib\cs

s&wdisk.exe: s&wdisk.obj s&wlow.obj commkit.obj srcalls.obj crcsr.obj 
	tlink \tc\lib\c0s s&wdisk s&wlow commkit srcalls crcsr, s&wdisk, , \
	\tc\lib\emu \tc\lib\maths \tc\lib\cs

s&wdisk.obj: s&wdisk.c general.h ascii.h devices.h 
	tcc -ms -c s&wdisk.c

s&wex.obj: s&wex.c general.h ascii.h devices.h 
	tcc -ms -c s&wex.c

s&wlow.obj: s&wlow.c s&w.h general.h ascii.h devices.h
	tcc -ms -c s&wlow.c

#
# Modem software for external modems (external.c - Chapter 8)
#

external.exe: external.obj commkit.obj srcalls.obj 
	tlink \tc\lib\c0s external commkit srcalls, external, , \
	\tc\lib\emu \tc\lib\maths \tc\lib\cs

external.obj: external.c general.h ascii.h devices.h
	tcc -ms -c external.c

#
# Modem software for internal modems (internal.c - Chapter 8)
#

internal.exe: internal.obj commkit.obj srcalls.obj 
	tlink \tc\lib\c0s internal commkit srcalls, internal, , \
	\tc\lib\emu \tc\lib\maths \tc\lib\cs

internal.obj: internal.c general.h ascii.h devices.h
	tcc -ms -c internal.c

#
# Statistical multiplexer (statmux.c - Chapter 9)
#

statmux.exe: statmux.obj commkit.obj srcalls.obj 
	tlink \tc\lib\c0s statmux commkit srcalls, statmux, , \
	\tc\lib\emu \tc\lib\maths \tc\lib\cs

statmux.obj: statmux.c general.h ascii.h devices.h
	tcc -ms -c statmux.c

#
# Wide area network software (Chapter 10):
#
#  wanlow.c   - physical and data link layers
#  wannet.c   - network layer
#  wanex.c    - interactive message entry
#  wandef.h   - wide area network definitions
#  wanstrct.h - state information for wanlow.c
#

wanex.exe: wanex.obj wannet.obj wanlow.obj commkit.obj srcalls.obj crcsr.obj
	tlink \tc\lib\c0s wanex wannet wanlow commkit srcalls crcsr, wanex,,\
	\tc\lib\emu \tc\lib\maths \tc\lib\cs

wanex.obj: wanex.c general.h ascii.h devices.h
	tcc -ms -c wanex.c

wannet.obj: wannet.c wandef.h general.h devices.h
	tcc -ms -c wannet.c

wanlow.obj: wanlow.c wanstrct.h wandef.h commkit.h general.h ascii.h devices.h
	tcc -ms -c wanlow.c

#
# Bus network software (Chapter 11):
#
#  busex.c  - example of sending single messages from the keyboard
#  buslow.c - low level routines to handle packet i/o
#

busex.exe: busex.obj buslow.obj commkit.obj srcalls.obj crcsr.obj
	tlink \tc\lib\c0s busex buslow commkit srcalls crcsr, busex, , \
	\tc\lib\emu \tc\lib\maths \tc\lib\cs

busex.obj: busex.c
	tcc -ms -c busex.c

buslow.obj: buslow.c
	tcc -ms -c buslow.c

#
# Ring network software (Chapter 12):
#
#  ringlow.c - low-level ring network emulation software
#  ringex.c  - single message from keyboard software
#

ringex.exe: ringex.obj ringlow.obj commkit.obj srcalls.obj crcsr.obj 
	tlink \tc\lib\c0s ringex ringlow commkit srcalls crcsr, ringex, , \
	\tc\lib\emu \tc\lib\maths \tc\lib\cs

ringex.obj: ringex.c
	tcc -ms -c ringex.c

ringlow.obj: ringlow.c
	tcc -ms -c ringlow.c

#
# Sockette software (Chapter 13):
#
#  sockette.c  - sockette support code
#  sockex.c    - sample sockette applications
#  ringsox.exe - sockettes on a ring
#  bussox.exe  - sockettes on a bus
#  wansox.exe  - sockettes on a wan
#
# Sockette.c is compiled with one of RING, BUS, or WAN defined to ensure that
# network specific code is included in the network layer.
#

ringsox.exe: ringlow.obj sockex.obj ringsox.obj commkit.obj srcalls.obj crcsr.obj
	tlink \tc\lib\c0s ringlow sockex ringsox commkit srcalls crcsr, ringsox, , \
	\tc\lib\emu \tc\lib\maths \tc\lib\cs

bussox.exe: buslow.obj sockex.obj bussox.obj commkit.obj srcalls.obj crcsr.obj
	tlink \tc\lib\c0s buslow sockex bussox commkit srcalls crcsr, bussox, , \
	\tc\lib\emu \tc\lib\maths \tc\lib\cs

wansox.exe: buslow.obj sockex.obj wansox.obj commkit.obj srcalls.obj crcsr.obj
	tlink \tc\lib\c0s wanlow sockex wansox commkit srcalls crcsr, wansox, , \
	\tc\lib\emu \tc\lib\maths \tc\lib\cs

ringsox.obj: sockette.c sockette.h sockcode.h
	tcc -ms -c -DRING -oringsox sockette.c

bussox.obj: sockette.c sockette.h sockcode.h
	tcc -ms -c -DBUS -obussox sockette.c

wansox.obj: sockette.c sockette.h sockcode.h
	tcc -ms -c -DWAN -owansox sockette.c

sockex.obj: sockex.c sockcode.h
	tcc -ms -c sockex.c

#
# Bridge software (Chapter 14):
#
#  bridge.c   - the bridge software (works on either LAN)
#  parlport.c - the parallel port software
#  ringb.exe  - ring bridge
#  busb.exe   - bus bridge
#
# Note that ringlow.c and buslow.c are compiled with the token BRIDGE defined,
# this permits calls to the parallel port software.
#

ringb.exe: ringlo.obj bridger.obj parlport.obj commkit.obj srcalls.obj crcsr.obj
	tlink \tc\lib\c0s ringlo bridger parlport commkit srcalls crcsr, ringb, , \
	\tc\lib\emu \tc\lib\maths \tc\lib\cs

busb.exe: buslo.obj bridgeb.obj parlport.obj commkit.obj srcalls.obj crcsr.obj
	tlink \tc\lib\c0s buslo bridgeb parlport commkit srcalls crcsr, busb, , \
	\tc\lib\emu \tc\lib\maths \tc\lib\cs

ringlo.obj: ringlow.c
	tcc -ms -c -DBRIDGE -oringlo ringlow.c

buslo.obj: buslow.c
	tcc -ms -c -DBRIDGE -obuslo buslow.c

bridger.obj: bridge.c
	tcc -ms -c -DRING -obridger bridge.c

bridgeb.obj: bridge.c
	tcc -ms -c -DBUS -obridgeb bridge.c

parlport.obj: parlport.c
	tcc -ms -c parlport.c
