# 
#  Makefile for the rocat BBS System
#  Copyright C 1994-1995 by Gregory Shaw
# 
#  Don't look here!  The docs are in the doc directory.
#

CC=gcc
CFLAGS= -g -m486 
DEFINES= -D_POSIX_SOURCE -Wall
INCLUDES = -I/usr/include/ncurses
LIBS= -lm -lncurses -lc


HDRS= bbs.h bbsint.h errlog.h menu.h user.h bbshdr.h bbsipc.h filelock.h ports.h bbsinfo.h socket.h sysexec.h lang.h chat.h

.SUFFIXES: .C .o

.C.o:
	$(CC) -c $(CFLAGS) $(DEFINES) $(INCLUDES) $<




all: bbs daemons utilities 

anu: anu.o
	$(CC) -c $(CFLAGS) $(DEFINES) $(INCLUDES) -D_SERVER_ anu.C
	$(CC) -c $(CFLAGS) $(DEFINES) $(INCLUDES) -D_SERVER_ bbsipc.C
	$(CC) -c $(CFLAGS) $(DEFINES) $(INCLUDES) -D_SERVER_ errlog.C
	$(CC) -c $(CFLAGS) $(DEFINES) $(INCLUDES) -D_SERVER_ bbsinfo.C
	$(CC) -o anu anu.o bbsipc.o errlog.o bbsinfo.o $(LIBS)

anu.install:
	chown root /bbs/bin/anu
	chgrp bbs /bbs/bin/anu
	chmod 4750 /bbs/bin/anu

backup:	clean
	cd ../..;tar cvfz /dev/fd0H1440 rocat
	@echo Backup complete!

bbs:	bbs.o user.o bbsint.o bbsipc.o bbsinfo.o errlog.o filelock.o \
	menu.o files.o dllist.o moncon.o sysexec.o lang.o color.o chat.o
	$(CC) $(CFLAGS) -o bbs bbs.o user.o filelock.o bbsint.o bbsipc.o menu.o \
	bbsinfo.o errlog.o dllist.o files.o moncon.o sysexec.o lang.o \
	color.o chat.o $(LIBS)

bbsipc: bbsipc.o

chatest:	chatest.o bbsipc.o
	$(CC) -o chatest chatest.o bbsipc.o


clean:
	rm -f *.o
	rm -f core
	rm -f bbs
	rm -f *test
	rm -f errlogd
	rm -f monitor
	rm -f fileutil
	rm -f rochatd
	rm -f ropchatd
	rm -f robcastd
	rm -f anu
	rm -f userupdate

chsh: chsh.o
	$(CC) -g -o chsh chsh.c

daemons: rochatd errlogd robcastd ropchatd

depend:	
	gccmakedep $(INCLUDES) *.C 

dltest:	dltest.o dllist.o
	$(CC) -o dltest dltest.o dllist.o

errlogd:  errlogd.o
	$(CC) -c $(CFLAGS) $(DEFINES) $(INCLUDES) -D_SERVER_ errlogd.C
	$(CC) -c $(CFLAGS) $(DEFINES) $(INCLUDES) -D_SERVER_ bbsipc.C
	$(CC) -o errlogd errlogd.o bbsipc.o $(LIBS)

fileutil:	lang.o files.o dllist.o fileutil.o user.o bbsint.o bbsipc.o bbsinfo.o errlog.o filelock.o moncon.o sysexec.o color.o chat.o
	$(CC) -o  fileutil lang.o files.o fileutil.o dllist.o user.o \
		filelock.o bbsint.o bbsipc.o bbsinfo.o errlog.o \
		moncon.o sysexec.o color.o chat.o $(LIBS)

filesupdate:	filesupdate.o
	$(CC) -o filesupdate filesupdate.o

install.bbs:	bbs
	strip bbs 
	chmod 775 bbs
	rm -f $(BBSDIR)/rocat
	cp bbs $(BBSDIR)/rocat
	chgrp bbs $(BBSDIR)/rocat
	chmod g+s $(BBSDIR)/rocat

install.daemons:	errlogd rochatd robcastd ropchatd
	strip errlogd rochatd robcastd ropchatd
	cp rochatd robcastd ropchatd $(BBSDIR)/bin
	chmod 775 errlogd
	chgrp bbs errlogd
	chmod g+s errlogd
	cp errlogd $(BBSDIR)/bin

install-manwe.bbs: bbs
	strip bbs 
	chmod 775 bbs
	rm -f /bbs/rocat
	rcp bbs manwe:/bbs/rocat
	chgrp bbs /bbs/rocat
	chmod g+s /bbs/rocat

install-manwe.daemons:	errlogd rochatd robcastd ropchatd
	strip errlogd rochatd robcastd ropchatd
	rcp rochatd robcastd ropchatd manwe:/bbs/bin
	chmod 775 errlogd
	chgrp bbs errlogd
	chmod g+s errlogd
	rcp errlogd manwe:/bbs/bin

install-manwe: bbs fileutil monitor userupdate daemons install-manwe.bbs install-manwe.daemons
	rcp lang/english manwe:/bbs/lang
	rcp userupdate manwe:/bbs/bin
	strip anu fileutil monitor 
	rcp anu fileutil manwe:/bbs/bin
	chmod 775 monitor
	chgrp bbs monitor
	rcp monitor manwe:/bbs/bin

install: bbs fileutil monitor userupdate daemons install.bbs install.daemons
	cp lang/english $(BBSDIR)/lang
	cp userupdate $(BBSDIR)/bin
	strip anu fileutil monitor 
	cp anu fileutil $(BBSDIR)/bin
	chmod 775 monitor
	chgrp bbs monitor
	cp monitor $(BBSDIR)/bin
	@echo BBS Installed!
	@echo Now you must install the 'anu' program
	@echo see the documentation for more information

menutest:	menutest.o user.o bbsint.o bbsipc.o bbsinfo.o errlog.o filelock.o menu.o
	$(CC) -g -o menutest menutest.o user.o filelock.o bbsint.o bbsipc.o menu.o bbsinfo.o errlog.o $(LIBS)

monitor: bbsint.o monitor.o
	$(CC) -c $(CFLAGS) $(DEFINES) $(INCLUDES) -D_SERVER_ bbsipc.C
	$(CC) -c $(CFLAGS) $(DEFINES) $(INCLUDES) -D_SERVER_ monitor.C
	$(CC) -g -o monitor monitor.o bbsipc.o $(LIBS)

pretty:	
	./makepretty

robcastd:  robcastd.o
	$(CC) -c $(CFLAGS) $(DEFINES) $(INCLUDES) -D_SERVER_ robcastd.C
	$(CC) -c $(CFLAGS) $(DEFINES) $(INCLUDES) -D_SERVER_ bbsipc.C
	$(CC) -c $(CFLAGS) $(DEFINES) $(INCLUDES) -D_SERVER_ errlog.C
	$(CC) -c $(CFLAGS) $(DEFINES) $(INCLUDES) -D_SERVER_ bbsinfo.C
	$(CC) -o robcastd robcastd.o bbsipc.o errlog.o bbsinfo.o $(LIBS)

rochatd:  rochatd.o
	$(CC) -c $(CFLAGS) $(DEFINES) $(INCLUDES) -D_SERVER_ rochatd.C
	$(CC) -c $(CFLAGS) $(DEFINES) $(INCLUDES) -D_SERVER_ bbsipc.C
	$(CC) -c $(CFLAGS) $(DEFINES) $(INCLUDES) -D_SERVER_ errlog.C
	$(CC) -c $(CFLAGS) $(DEFINES) $(INCLUDES) -D_SERVER_ bbsinfo.C
	$(CC) -o rochatd rochatd.o bbsipc.o errlog.o bbsinfo.o $(LIBS)

ropchatd:  ropchatd.o
	$(CC) -c $(CFLAGS) $(DEFINES) $(INCLUDES) -D_SERVER_ ropchatd.C
	$(CC) -c $(CFLAGS) $(DEFINES) $(INCLUDES) -D_SERVER_ bbsipc.C
	$(CC) -c $(CFLAGS) $(DEFINES) $(INCLUDES) -D_SERVER_ errlog.C
	$(CC) -c $(CFLAGS) $(DEFINES) $(INCLUDES) -D_SERVER_ bbsinfo.C
	$(CC) -o ropchatd ropchatd.o bbsipc.o errlog.o bbsinfo.o $(LIBS)

	

test:	test.o 
	$(CC) -o test $(CFLAGS) $(DEFINES) $(INCLUDES) test.o -ldcurses 

testipc: testipc.o bbsipc
	$(CC) -g -o testipc testipc.o bbsipc.o $(LIBS)

testinfo:	testinfo.o	bbsinfo.o
	$(CC) -g -o testinfo testinfo.o bbsinfo.o $(LIBS)

user: user.o bbsint.o 

usertest:	usertest.o user.o bbsint.o bbsipc.o bbsinfo.o errlog.o filelock.o 
	$(CC) -g -o usertest usertest.o user.o filelock.o bbsint.o bbsipc.o bbsinfo.o errlog.o $(LIBS)

userupdate:	userupdate.o

utilities: fileutil monitor userupdate anu


# dependancies

# DO NOT DELETE
