# 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.

#  HOW TO MAKE IT WORK:
#
# Uncomment the "MODEL" and "CURSES" lines for the operating system you are
# using.  If yours isn't listed, try various ones until you find one that
# works.
# 
#  WHAT THE VARIOUS FLAGS MEAN:
# 
# USE_NCURSES		- Use the "ncurses" library (mostly for Linux...)
# VISUAL_SETUP		- Compile the full-screen version of the "setup"
#			  program.  If you can't get the full-screen setup
#			  to work properly, see below for compiling a
#			  line-oriented version!
# HAVE_FLOCK		- Define this flag if your system supports the
#			  flock() system call for file locking.
#


# Use this one for Linux.  (Note that for curses-based programs, we use
# the "ncurses" package - it's more elaborate.  Get it if you don't have it.)
#
MODEL=-s -i
CURSES=-lncurses -DUSE_NCURSES -I/usr/include/ncurses

# Use this one for SCO UNIX or SCO Xenix.
#
# MODEL=-s -i
# CURSES=-DM_TERMINFO -ltinfo

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

# for Xenix 2.3.4 with termcap...
#
# MODEL=-s -i
# CURSES=-DM_TERMCAP -lcurses -ltermcap

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


########################################################################

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 sysdep.o
	cc $(MODEL) -O citadel.o rooms.o messages.o commands.o routines.o \
routines2.o config.o sysdep.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

sysdep.o: sysdep.c citadel.h
	cc -O $(MODEL) -c sysdep.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.o sysdep.o config.o citadel.h
	cc -O $(MODEL) netproc.o sysdep.o config.o -o netproc
	chmod 4755 netproc

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

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

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
#
# IMPORTANT: IF CURSES DOESN'T WORK ON YOUR SYSTEM, FEAR NOT!
#            YOU CAN COMPILE SETUP TO NOT USE IT!!
#
# the Makefile is set up to use the full-screen version of setup.
#
	cc -O -DVISUAL_SETUP $(MODEL) setup.c $(CURSES) -o setup
#
# If you can't get curses to work properly, uncomment the following command
# instead, and it will not use curses.
#
#	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
