#
#	Makefile for KA9Q TCP/IP package, PE1CHL version
#
#	(un)comment one of the sets below to select machine/compiler
#	some compilers use a different makefile (because of "make" limitations)
#

#
# CFLAGS/AFLAGS/rules for IBM-PC (Turbo C, MEDIUM model)
#
#CFLAGS= -DMSDOS -d -f- -k- -O -Z -mm
#AFLAGS= -DTURBO=1 -DLARGECODE=1 -mx
#O=obj
#all:	mtcnet.exe
#.c.obj:
#	tcc -c $(CFLAGS) $*.c

#.asm.obj:
#	tasm $(AFLAGS) $*.asm

#
# CFLAGS/AFLAGS/rules for IBM-PC (Turbo C, LARGE model)
#
#CFLAGS= -DMSDOS -d -f- -k- -O -Z -ml
#AFLAGS= -DTURBO=1 -DLARGECODE=1 -DLARGEDATA=1 -mx
#O=obj
#all:	tcnet.exe
#.c.obj:
#	tcc -c $(CFLAGS) $*.c

#.asm.obj:
#	tasm $(AFLAGS) $*.asm

#
# CFLAGS/AFLAGS/rules for IBM-PC (Aztec C)
#
#CFLAGS= -DMSDOS -DNOSTRUCTASSIGN +LC
#AFLAGS= -DAZTEC=1 -DLARGECODE=1
#O=o
#all:	net.exe
#.c.o:
#	cc -c $(CFLAGS) -o $@ $*.c

#.asm.o:
#	as $(AFLAGS) -o $@ $*.asm

#
# CFLAGS for Atari ST (Mark Williams C)
#
CFLAGS= -DATARI_ST -DMWC=309 -VPEEP -VSCCON -VSLCON -VSPVAL -VSUREG
O=o
all:	net.acc ..\net.tos
	echo 'we made it!'

#
# CFLAGS/ASFLAGS for Atari ST (Turbo C)
# Use Mark Williams "make", edit /lib/mactions to insert "=" after "-o"
#
#CFLAGS= -DATARI_ST -A -I=C:\TC\INCLUDE\ -P -W-pro -W-rvl -W-stu
#ASFLAGS= -S -V
#CC=c:\tc\tcc
#AS=c:\tc\mas
#O=o
#all:	net.tos
#	echo 'we made it!'

#
# CFLAGS/AFLAGS/rules for UNIX
#
#CFLAGS= -DUNIX -DSYS5 -O
#O=o
#all:	net

#
# CFLAGS/AFLAGS/rules for XENIX 286
#
#CFLAGS= -DUNIX -DSYS5 -Ols -Gs -M2m
#O=o
#all:	net286

#
# CFLAGS/AFLAGS/rules for XENIX 386
#
#CFLAGS= -DUNIX -DSYS5 -Ols -Gs
#O=o
#all:	net386

#
# CFLAGS for Commodore Amiga
#
#CFLAGS= -DAMIGA
#O=o
#all:	net.amiga

#
# CFLAGS/rules for typical CPM installation (using Aztec CCI)
#
#CFLAGS= -DCPM
#O=o
#.c.o:
#	cci $(CFLAGS) -DNODEFINED -D__NOPROTO__ -DNOSTRUCTASSIGN -I/OD/AZTEC80/INCLUDE	-o $@ $*.c
#all:	net.com


# special rules to switch between "minimum" and "maximum" configuration

# move 'minimum' configuration file into config.h

min:	config.min
	mv config.h config.max
	mv config.min config.h
	rm atari.$(O) atariacc.$(O) atariprg.$(O) ax25serv.$(O) main.$(O) pc.$(O) session.$(O) smtpcli.$(O)

# move 'maximum' configuration file into config.h

max:	config.max
	mv config.h config.min
	mv config.max config.h
	rm atari.$(O) atariacc.$(O) atariprg.$(O) ax25serv.$(O) main.$(O) pc.$(O) session.$(O) smtpcli.$(O)

# library definitions

NETOBJS1= session.$(O) telnet.$(O) tnserv.$(O) smisc.$(O) rcmd.$(O) \
	fingserv.$(O) fingcli.$(O) ftpserv.$(O) ftpcli.$(O) ftp.$(O) \
	smtpserv.$(O) smtpcli.$(O) tcpcmd.$(O) tcpuser.$(O) tcptimer.$(O) \
	tcpout.$(O) tcpin.$(O) tcpsubr.$(O) \
	udpcmd.$(O) udp.$(O) udpsubr.$(O) \
	ipcmd.$(O) ip.$(O) iproute.$(O) ipsubr.$(O) \
	icmpcmd.$(O) icmp.$(O) icmpsubr.$(O) \
	arpcmd.$(O) arp.$(O) arpsubr.$(O) arptypes.$(O) at.$(O)

NETOBJS2= ax25serv.$(O) ax25cmd.$(O) ax25user.$(O) ax25.$(O) ax25subr.$(O) \
	tnc2.$(O) ax_mbx.$(O) \
	lapbtime.$(O) lapb.$(O) persist.$(O) \
	slip.$(O) kiss.$(O) \
	nr3.$(O) nr4.$(O) nr7.$(O) nrcmd.$(O) nrsubr.$(O) nrs.$(O) \
	iface.$(O) timer.$(O) ttydriv.$(O) cmdparse.$(O) mbuf.$(O) \
	netuser.$(O) environ.$(O) misc.$(O) pathname.$(O) password.$(O) \
	audit.$(O) files.$(O) icmpmsg.$(O) buffers.$(O)

NETDUMP= trace.$(O) enetdump.$(O) \
	ax25dump.$(O) arpdump.$(O) ipdump.$(O) icmpdump.$(O) udpdump.$(O) \
	tcpdump.$(O)

PCOBJS= pc.$(O) dirutil.$(O) scc.$(O) eccmd.$(O) ec.$(O) ecvec.$(O) \
	pktdrvr.$(O) pkvec.$(O) enet.$(O) pc_tnc2.$(O) combios.$(O) \
	8250.$(O) asyvec.$(O) sccvec.$(O) tnc2vec.$(O) comvec.$(O) \
	pcgen.$(O) pcint.$(O) pcirq.$(O) alloc.$(O) lcsum.$(O)

ATOBJS= atari_io.$(O) atari_tn.$(O) atari_ut.$(O) atari_il.$(O) \
	dirutil.$(O) scc.$(O) lcsum.$(O)

MWOBJS= atari_fn.$(O) sccvec.$(O) scroll.$(O) setlevel.$(O)

SCREEN= termcap.$(O) tparam.$(O) ansi.$(O) screen.$(O)

# Atari ST version (Mark Williams C compiler)

..\net.tos: makefile main.o version.o atari.o net1.a net2.a atari.a mwc.a dump.a
	cc main.o version.o atari.o dump.a net1.a net2.a atari.a mwc.a -o ..\net.tos
	makefast ..\net.tos

..\net_prg.prg: makefile main.o version.o atariprg.o atari_rf.o net1.a net2.a atari.a mwc.a dump.a
	cc -VGEM main.o version.o atariprg.o atari_rf.o dump.a net1.a net2.a atari.a mwc.a -lmylib -o ..\net_prg.prg
	makefast ..\net.tos

net.acc: makefile crtspec.o main.o version.o atariacc.o net1.a net2.a atari.a mwc.a dump.a
	cc -Nrcrtspec.o main.o version.o atariacc.o dump.a net1.a net2.a atari.a mwc.a -laes -lvdi -o net.acc

atari.a: $(ATOBJS)
	ar r atari.a $?

dump.a: $(NETDUMP)
	ar r dump.a $?

mwc.a:	$(MWOBJS)
	ar r mwc.a $?

net1.a: $(NETOBJS1)
	ar r net1.a $?

net2.a: $(NETOBJS2)
	ar r net2.a $?

screen.a: $(SCREEN)
	ar r screen.a $?

atariacc.o: atari.c
	cc -DGEM -DGEMACC $(CFLAGS) -c atari.c
	mv atari.o atariacc.o

atariprg.o: atari.c
	cc -DGEM -DGEMPRG $(CFLAGS) -c atari.c
	mv atari.o atariprg.o

# Atari ST version (Turbo C)

net.tos: makefile main.o version.o atari.o net1.lib net2.lib atari.lib dump.lib
	c:\tc\tlink -S=4096 -O=net.tos -C=net.lnk
	makefast net.tos

atari.lib: $(ATOBJS)
	lb atari.lib $?

# UNIX and XENIX versions

net: makefile main.o version.o net1.a net2.a dump.a unix.a
	cc $(CFLAGS) main.o version.o dump.a net1.a net2.a unix.a -o net

net286: makefile main.o version.o net1.a net2.a dump.a unix.a
	cc $(CFLAGS) main.o version.o dump.a net1.a net2.a unix.a -lx -F 1000 -o net286

net386: makefile main.o version.o net1.a net2.a dump.a unix.a
	cc $(CFLAGS) main.o version.o dump.a net1.a net2.a unix.a -lx -o net386

unix.a: unix.o wildmat.o lcsum.o alloc.o
	ar r unix.a $?

# Commodore Amiga version

net.amiga: makefile main.$(O) version.$(O) amiga.$(O) amiga_ut.$(O) net1.lib net2.lib dump.lib
	link-command for amiga...

# PC version (Aztec C)

net.exe: pc.lib net1.lib net2.lib dump.lib makefile main.o version.o session.o
	ln -t -o net.exe main.o version.o dump.lib net1.lib net2.lib pc.lib -lclc

# PC version (Turbo C)

mtcnet.exe: net.lib makefile main.obj version.obj session.obj
	tcc -mm -emtcnet main.obj version.obj session.obj files.obj alloc.obj net.lib

tcnet.exe: net.lib makefile main.obj version.obj session.obj
	tcc -ml -etcnet main.obj version.obj session.obj files.obj alloc.obj net.lib

# CP/M version

net.com: net1.lib net2.lib dump.lib makefile main.o version.o cpm.o lcsum.o
	ln80 -t -o net.com main.o version.o cpm.o lcsum.o dump.lib net1.lib net2.lib -lczcpm

objects: $(NETOBJS1) $(NETOBJS2) $(PCOBJS)

net1.lib: $(NETOBJS1)
	lb net1.lib $(NETOBJS1)

net2.lib: $(NETOBJS2)
	lb net2.lib $(NETOBJS2)

dump.lib: $(NETDUMP)
	lb dump.lib $(NETDUMP)

pc.lib: $(PCOBJS)
	lb pc.lib $(PCOBJS)

net.lib: $(NETOBJS1) $(NETOBJS2) $(NETDUMP) $(PCOBJS)
	del net.lib
	tlib net.lib @net.arf

clean:
	del *.lib
	del *.$(O)
	del *.exe
	del *.sym

# objectfiles and their dependencies

8250.$(O):	8250.c global.h asy.h 8250.h iface.h
alloc.$(O):	alloc.c alloc.h
amiga.$(O):	amiga.c amiga.h global.h iface.h smtp.h
amiga_ut.$(O):	amiga_ut.c
arp.$(O):	arp.c global.h mbuf.h timer.h iface.h enet.h ax25.h arp.h
arpcmd.$(O):	arpcmd.c global.h mbuf.h timer.h enet.h ax25.h arp.h iface.h netuser.h cmdparse.h
arpdump.$(O):	arpdump.c global.h mbuf.h timer.h arp.h ax25.h netuser.h
arpsubr.$(O):	arpsubr.c global.h mbuf.h timer.h iface.h enet.h ax25.h arp.h
arptypes.$(O):	arptypes.c global.h mbuf.h timer.h iface.h arp.h
asyvec.$(O):	asyvec.asm pmacros.h
at.$(O):	at.c global.h timer.h cmdparse.h
atari.$(O):	atari.c global.h config.h mbuf.h internet.h iface.h atari.h timer.h environ.h
atari_fn.$(O):	atari_fn.c global.h
atari_il.$(O):	atari_il.s
atari_io.$(O):	atari_io.c global.h mbuf.h internet.h iface.h asy.h atari.h
atari_rf.$(O):	atari_rf.c atari_rs.c
atari_rs.$(O):	atari_rs.c
atari_tn.$(O):	atari_tn.c global.h ax25.h timer.h slip.h tnc2.h
atari_ut.$(O):	atari_ut.c global.h atari.h
atdump.$(O):	atdump.c global.h mbuf.h mac_AT.h trace.h
audit.$(O):	audit.c global.h mbuf.h
ax25.$(O):	ax25.c global.h mbuf.h iface.h timer.h arp.h slip.h ax25.h lapb.h
ax25cmd.$(O):	ax25cmd.c global.h mbuf.h ax25.h timer.h iface.h lapb.h cmdparse.h session.h
ax25dump.$(O):	ax25dump.c global.h mbuf.h ax25.h timer.h lapb.h ip.h trace.h
ax25serv.$(O):	ax25serv.c global.h config.h mbuf.h iface.h timer.h ax25.h lapb.h cmdparse.h session.h slip.h tnc2.h
ax25subr.$(O):	ax25subr.c global.h mbuf.h timer.h ax25.h lapb.h
ax25user.$(O):	ax25user.c global.h mbuf.h timer.h iface.h ax25.h lapb.h
ax_mbx.$(O):	ax_mbx.c global.h mbuf.h ax25.h timer.h iface.h lapb.h smtp.h ax_mbx.h cmdparse.h
buffers.$(O):	buffers.c global.h mbuf.h buffers.h
cmdparse.$(O):	cmdparse.c global.h cmdparse.h
combios.$(O):	combios.c global.h asy.h combios.h slip.h iface.h
comdebug.$(O):	comdebug.c
comvec.$(O):	comvec.asm pmacros.h
crtspec.$(O):	crtspec.s
dirutil.$(O):	dirutil.c global.h
ec.$(O):	ec.c global.h mbuf.h enet.h iface.h ec.h timer.h arp.h trace.h
eccmd.$(O):	eccmd.c global.h mbuf.h iface.h ec.h
ecvec.$(O):	ecvec.asm pmacros.h
enet.$(O):	enet.c global.h mbuf.h iface.h timer.h arp.h enet.h
enetdump.$(O):	enetdump.c global.h mbuf.h enet.h trace.h
environ.$(O):	environ.c global.h environ.h
files.$(O):	files.c global.h
fingcli.$(O):	fingcli.c global.h mbuf.h timer.h internet.h icmp.h netuser.h tcp.h finger.h session.h
fingserv.$(O):	fingserv.c global.h mbuf.h timer.h internet.h icmp.h netuser.h tcp.h finger.h session.h
ftp.$(O):	ftp.c global.h mbuf.h netuser.h timer.h tcp.h ftp.h session.h
ftpcli.$(O):	ftpcli.c global.h mbuf.h netuser.h icmp.h timer.h tcp.h ftp.h session.h cmdparse.h
ftpserv.$(O):	ftpserv.c global.h mbuf.h netuser.h timer.h tcp.h ftp.h
icmp.$(O):	icmp.c global.h mbuf.h internet.h timer.h iface.h ip.h icmp.h
icmpcmd.$(O):	icmpcmd.c global.h icmp.h mbuf.h netuser.h internet.h timer.h ping.h
icmpdump.$(O):	icmpdump.c global.h mbuf.h internet.h icmp.h trace.h
icmpmsg.$(O):	icmpmsg.c global.h
icmpsubr.$(O):	icmpsubr.c global.h mbuf.h internet.h icmp.h
iface.$(O):	iface.c global.h iface.h
ip.$(O):	ip.c global.h mbuf.h timer.h internet.h iface.h ip.h icmp.h
ipcmd.$(O):	ipcmd.c global.h mbuf.h internet.h timer.h netuser.h iface.h ip.h cmdparse.h
ipdump.$(O):	ipdump.c global.h mbuf.h internet.h timer.h iface.h ip.h trace.h netuser.h
iproute.$(O):	iproute.c global.h mbuf.h internet.h timer.h netuser.h ip.h icmp.h iface.h trace.h
ipsubr.$(O):	ipsubr.c global.h mbuf.h internet.h timer.h netuser.h ip.h
kiss.$(O):	kiss.c global.h mbuf.h iface.h kiss.h trace.h
lapb.$(O):	lapb.c global.h mbuf.h timer.h ax25.h lapb.h
lapbtime.$(O):	lapbtime.c global.h mbuf.h ax25.h timer.h lapb.h
lcsum.$(O):	lcsum.c global.h
main.$(O):	main.c global.h config.h mbuf.h buffers.h netuser.h timer.h icmp.h iface.h ip.h tcp.h ax25.h lapb.h ftp.h telnet.h remote.h session.h cmdparse.h kiss.h slip.h tnc2.h asy.h nrs.h trace.h
mbuf.$(O):	mbuf.c global.h mbuf.h
misc.$(O):	misc.c global.h
netuser.$(O):	netuser.c global.h netuser.h internet.h
nr3.$(O):	nr3.c global.h mbuf.h iface.h trace.h timer.h arp.h slip.h ax25.h netrom.h lapb.h ip.h
nr4.$(O):	nr4.c global.h mbuf.h iface.h trace.h timer.h arp.h ax25.h netrom.h
nr7.$(O):	nr7.c global.h mbuf.h iface.h timer.h ax25.h lapb.h netrom.h cmdparse.h netuser.h
nrcmd.$(O):	nrcmd.c global.h mbuf.h ax25.h timer.h netrom.h iface.h lapb.h cmdparse.h
nrs.$(O):	nrs.c global.h mbuf.h iface.h ax25.h nrs.h asy.h combios.h trace.h
nrsubr.$(O):	nrsubr.c global.h mbuf.h timer.h ax25.h netrom.h lapb.h
password.$(O):	password.c global.h password.h
pathname.$(O):	pathname.c global.h
pc.$(O):	pc.c global.h config.h mbuf.h internet.h iface.h cmdparse.h timer.h environ.h
pc_tnc2.$(O):	pc_tnc2.c global.h asy.h ax25.h timer.h slip.h tnc2.h
pcgen.$(O):	pcgen.asm pmacros.h
pcint.$(O):	pcint.asm pmacros.h
pcirq.$(O):	pcirq.c global.h
persist.$(O):	persist.c global.h ax25.h iface.h persist.h timer.h
pktdrvr.$(O):	pktdrvr.c global.h mbuf.h enet.h iface.h ec.h timer.h arp.h trace.h regs.h pktdrvr.h
pkvec.$(O):	pkvec.asm pmacros.h
rcmd.$(O):	rcmd.c global.h mbuf.h netuser.h timer.h tcp.h password.h rcmd.h cmdparse.h
scc.$(O):	scc.c global.h mbuf.h buffers.h iface.h slip.h scc.h 8530.h 8536.h ax25.h trace.h
sccvec.$(O):	sccvec.asm pmacros.h
scroll.$(O):	scroll.s
scrollt.$(O):	scrollt.s
session.$(O):	session.c config.h global.h mbuf.h netuser.h timer.h tcp.h ax25.h lapb.h ftp.h telnet.h finger.h session.h cmdparse.h
setlevel.$(O):	setlevel.s
slip.$(O):	slip.c global.h mbuf.h iface.h ax25.h slip.h asy.h combios.h trace.h
smisc.$(O):	smisc.c global.h mbuf.h netuser.h timer.h tcp.h remote.h
smtpcli.$(O):	smtpcli.c global.h config.h netuser.h mbuf.h timer.h tcp.h smtp.h trace.h cmdparse.h
smtpserv.$(O):	smtpserv.c global.h mbuf.h netuser.h timer.h tcp.h smtp.h
spl.$(O):	spl.s
tcpcmd.$(O):	tcpcmd.c global.h timer.h mbuf.h netuser.h internet.h tcp.h cmdparse.h
tcpdump.$(O):	tcpdump.c global.h mbuf.h netuser.h internet.h timer.h tcp.h trace.h
tcpin.$(O):	tcpin.c global.h timer.h mbuf.h netuser.h internet.h tcp.h icmp.h iface.h ip.h
tcpout.$(O):	tcpout.c global.h timer.h mbuf.h netuser.h internet.h tcp.h
tcpsubr.$(O):	tcpsubr.c global.h timer.h mbuf.h netuser.h internet.h tcp.h
tcptimer.$(O):	tcptimer.c global.h mbuf.h timer.h netuser.h internet.h tcp.h
tcpuser.$(O):	tcpuser.c global.h timer.h mbuf.h netuser.h internet.h tcp.h
telnet.$(O):	telnet.c global.h mbuf.h timer.h icmp.h netuser.h tcp.h telnet.h session.h
timer.$(O):	timer.c global.h timer.h
tnc2.$(O):	tnc2.c global.h mbuf.h iface.h timer.h ax25.h lapb.h kiss.h slip.h tnc2.h
tnc2vec.$(O):	tnc2vec.asm pmacros.h
tnserv.$(O):	tnserv.c global.h mbuf.h timer.h icmp.h netuser.h tcp.h telnet.h session.h
trace.$(O):	trace.c global.h mbuf.h iface.h trace.h
ttydriv.$(O):	ttydriv.c global.h
udp.$(O):	udp.c global.h mbuf.h netuser.h udp.h internet.h
udpcmd.$(O):	udpcmd.c global.h mbuf.h netuser.h udp.h internet.h cmdparse.h
udpdump.$(O):	udpdump.c global.h mbuf.h netuser.h internet.h udp.h
udpsubr.$(O):	udpsubr.c global.h mbuf.h internet.h netuser.h udp.h
unix.$(O):	unix.c global.h config.h mbuf.h internet.h iface.h cmdparse.h timer.h environ.h
version.$(O):	version.c global.h
wildmat.$(O):	wildmat.c
