# Makefile for Citadel/UX
# If programs seem to crash for no reason, try increasing the stack size!
# Anything that seems to be missing probably isn't critical.

# This is the model I use under SCO Xenix 386.
MODEL=-s -i

# This works for SCO Xenix 286.
#MODEL=-Ms2 -LARGE -F 4096 -s -i

# This should work for Microport System V.
#MODEL=-i

# add termcap, termlib, or whatever your system requires for curses
#
# for old Xenix and Sys III with termcap...
# CURSES=-lcurses -ltermcap
#
# for Xenix 2.3.4 with termcap...
CURSES=-DM_TERMCAP -lcurses -ltermcap

all: citadel aidepost netmailer netproc setup userlist \
whobbs useradmin msgform msgstats mailutil readlog rnews \
stats sysoputil

citadel: citadel.o rooms.o messages.o commands.o routines.o \
routines2.o config.o
	cc $(MODEL) -O citadel.o rooms.o messages.o commands.o routines.o \
routines2.o config.o -o citadel
	chmod 4755 citadel

config.o: config.c citadel.h axdefs.h
	cc -O $(MODEL) -c config.c

citadel.o: citadel.c citadel.h axdefs.h
	cc -O $(MODEL) -c citadel.c

rooms.o: rooms.c citadel.h
	cc -O $(MODEL) -c rooms.c

messages.o: messages.c citadel.h
	cc -O $(MODEL) -c messages.c

commands.o: commands.c citadel.h
	cc -O $(MODEL) -c commands.c

routines.o: routines.c citadel.h
	cc -O $(MODEL) -c routines.c

routines2.o: routines2.c citadel.h
	cc -O $(MODEL) -c routines2.c

aidepost: aidepost.c config.o citadel.h
	cc -O $(MODEL) aidepost.c config.o -o aidepost
	chmod 4755 aidepost

netmailer: netmailer.c config.o citadel.h
	cc -O $(MODEL) netmailer.c config.o -o netmailer
	chmod 4755 netmailer

netproc: netproc.c config.o citadel.h
	cc -O $(MODEL) netproc.c config.o -o netproc
	chmod 4755 netproc

rmail: rmail.c config.o citadel.h
	#
	#                 ###### IMPORTANT ######
	# TO ALLOW CITADEL USERS TO RECEIVE INTERNET MAIL, YOU MUST
	# INSTALL THIS PROGRAM USING THE INSTRUCTIONS IN RMAIL.C
	#
	cc -O $(MODEL) rmail.c config.o -o rmail
	chmod 4755 rmail
	ln rmail lmail

setup: setup.c citadel.h
	cc -O $(MODEL) setup.c -o setup
	chmod 4755 setup

userlist: userlist.c config.o citadel.h
	cc -O $(MODEL) userlist.c config.o -o userlist
	chmod 4755 userlist

whobbs: whobbs.c config.o citadel.h
	cc -O $(MODEL) whobbs.c config.o -o whobbs
	chmod 4755 whobbs

useradmin: useradmin.c config.o citadel.h axdefs.h
	cc -O $(MODEL) useradmin.c config.o $(CURSES) -o useradmin
	chmod 4750 useradmin

msgform: msgform.c
	cc -O $(MODEL) msgform.c -o msgform

msgstats: msgstats.c config.o citadel.h
	cc -O $(MODEL) msgstats.c config.o -o msgstats
	chmod 4755 msgstats

mailutil: mailutil.c config.o citadel.h
	cc -O $(MODEL) mailutil.c config.o -o mailutil
	chmod 4750 mailutil

readlog: readlog.c config.o citadel.h
	cc -O $(MODEL) readlog.c config.o -o readlog
	chmod 4750 readlog

rnews: rnews.c config.o citadel.h
	cc -O $(MODEL) rnews.c config.o -o rnews
	chmod 4755 rnews
	rm -f /usr/bin/rnews /bin/rnews
	ln rnews /usr/bin/rnews

stats: stats.c config.o citadel.h
	cc -O $(MODEL) stats.c config.o $(CURSES) -o stats
	chmod 4755 stats

sysoputil: sysoputil.c config.o citadel.h
	cc -O $(MODEL) sysoputil.c config.o -o sysoputil
	chmod 4750 sysoputil

citadel.h: sysconfig.h
	touch citadel.h
