# Galactic Bloodshed (Robert Chansky, smq@b)
# Makefile	(modified by billr@saab.cna.tek.com)

# (the -pipe -g are for development.)
# $UV, if used, is generally defined in the top level makefile. It's set
# to -DBSD4_2 for BSD 4.2 derived systems (e.g. SunOS 3.X) that don't
# have tm_zone as a member of the "tm" struct (see <time.h>).
# $(HP) comes from top level makefile for host and port info.
CFLAGS = -O $(UV) $(HP)
#CFLAGS = -g $(HP)
#CFLAGS = -pipe -g 

# objects for shell
SHOBJS =  getplace.o	\
	read_teleg.o	\
	teleg_send.o	\
	autoreport.o	\
	order.o		\
	shootblast.o	\
	explore.o	\
	relation.o	\
	mobiliz.o	\
	shlmisc.o	\
	enslave.o	\
	capitol.o	\
	toggle.o	\
	survey.o	\
	files.o		\
	zoom.o		\
	perm.o		\
	prof.o		\
	GB_server.o	\
	name.o		\
	fire.o		\
	land.o		\
	tech.o		\
	map.o		\
	max.o		\
	move.o		\
	capture.o	\
	cs.o		\
	rst.o		\
	misc.o		\
	rand.o		\
	load.o		\
	scrap.o		\
	build.o		\
	orbit.o		\
	power.o		\
	launch.o	\
	declare.o	\
	examine.o	\
	toxicity.o	\
	get4args.o	\
	files_rw.o	\
	files_shl.o 	\
	moveplanet.o	\
	autoshoot.o	\
	doplanet.o	\
	doturn.o	\
	VN.o		\
	doship.o	\
	dosector.o	\
	moveship.o


# depend on vars.h and races.h
VROBJS = getplace.o	\
	autoreport.o	\
	order.o		\
	mobiliz.o	\
	shlmisc.o	\
	capitol.o	\
	toggle.o	\
	enrol.o		\
	max.o		\
	move.o		\
	capture.o	\
	zoom.o		\
	toxicity.o	\
	doplanet.o	\
	shootblast.o	\
	autoshoot.o	\
	moveship.o	\
	explore.o	\
	relation.o	\
	dosector.o	\
	declare.o	\
	survey.o	\
	prof.o		\
	perm.o		\
	rst.o		\
	GB_server.o	\
	VN.o		\
	cs.o		\
	max.o		\
	map.o		\
	scrap.o		\
	name.o		\
	fire.o		\
	power.o		\
	doturn.o	\
	doship.o	\
	makeuniv.o	\
	makeplanet.o


# depend on ships.h and vars.h
SHIPOBJS = autoreport.o	\
	order.o		\
	shootblast.o	\
	makeplanet.o	\
	enrol.o		\
	examine.o	\
	capitol.o	\
	enslave.o	\
	relation.o	\
	capital.o	\
	survey.o	\
	launch.o	\
	build.o		\
	enrol.o		\
	fire.o		\
	land.o		\
	map.o		\
	max.o		\
	move.o		\
	capture.o	\
	cs.o		\
	VN.o		\
	rst.o		\
	load.o		\
	name.o		\
	prof.o		\
	scrap.o		\
	orbit.o		\
	doturn.o	\
	doship.o	\
	doplanet.o	\
	moveship.o	\
	autoshoot.o	\
	moveplanet.o	\
	files_shl.o

# depend on files.h
FOBJS =	files_shl.o 	\
	files_rw.o	\
	makeuniv.o	\
	shlmisc.o 	\
	doturn.o 	\
	enrol.o 	\
	files.o		\
	GB.o 		\
	build.o		\
	power.o 	\
	daemon.o	\
	examine.o


# dont depend on anything
NOOBJS = get4args.o	\
	misc.o		\
	rand.o		\
	daemon.o	\
	files_rw.o

# objects for enrol
EOBJS = enrol.o		\
	files_shl.o	\
	files_rw.o	\
	files.o		\
	max.o		\
	perm.o		\
	rand.o		\
	shlmisc.o

# objects for fix
FIXOBJS = fix.o		\
	files_shl.o	\
	files_rw.o	\
	getplace.o	\
	shlmisc.o	\
	files.o

all: GB_server GB_enroll mor GB_daemon makeuniv fix trav

# the shell 
GB_server : ${SHOBJS}
	cc -o GB_server ${SHOBJS}  -lcurses -ltermcap -lm

${VROBJS}: races.h vars.h
${SHIPOBJS}: vars.h ships.h
${FOBJS}: files.h
build.o : vars.h ships.h races.h shipdata.h
power.o files_shl.o : power.h
doturn.o doship.o doplanet.o moveship.o moveplanet.o : doturn.h
moveship.o : vars.h ships.h shipdata.h
doturn.o doplanet.o doship.o : power.h

#fix it program
fix : ${FIXOBJS}
	cc -o fix ${FIXOBJS} -lcurses -ltermcap -lm

#sizes : vars.h ships.h races.h
#	 sizes.c

# make data files program
makeuniv : makeuniv.o makeplanet.o rand.o perm.o
	cc -o makeuniv makeuniv.o makeplanet.o rand.o perm.o files.o -lm
makeuniv.o : power.h


# the daemon (actually it calls the update)
GB_daemon : daemon.o
	cc -o GB_daemon daemon.o

# the enrollment program
GB_enroll : ${EOBJS}
	cc -o GB_enroll ${EOBJS} -lcurses -ltermcap -lm
enrol.o : vars.h ships.h shipdata.h races.h

# more clone
mor : more.c
	cc -g -o mor more.c

#trav
trav : traverse.o files_rw.o files_shl.o files.o
	cc -o trav traverse.o files_rw.o files_shl.o files.o

chmod:
	chmod ag+xs GB
	chmod g+rwx Data Data/* Data/Tele/*
	chmod a+rx Docs Docs/*
	chmod g+r *.dat*
	chmod a+x mor
#	chmod ga+rwx Data Data/* Data/Tele/*

start:
	/bin/rm -f Data/spitup
	GB_daemon 4 > /dev/null

clean:
	/bin/rm -rf GB_server GB_enroll makeuniv GB_daemon mor fix \
		trav *.o core a.out

clear:
	/bin/rm -rf *.o core a.out


# shar it up for transport.
shar:
	/bin/cp Docs/*.doc* .
#	-uncompress enroll.dat.Z *.doc*
	shar README Makefile *.script *.doc *.h *.c planet.list *.dat > GB.shar
#	-compress enroll.dat
#	compress GB.shar
	/bin/rm -f *.doc

# shar up the docs.
shardocs:
	uncompress Docs/*.doc*
	shar README *.doc* > GBdocs.shar
	compress Docs/*.doc*

# make the game ftpable by netters.
public:
	/bin/cp Docs/* .
	uncompress enroll.dat.Z 
	shar -c README Makefile *.doc *.h *.c planet.list *.dat > /tmp/GB.shar
	compress enroll.dat
	compress /tmp/GB.shar
	/bin/cp /tmp/GB.shar.Z /usr/ftp/pub/games
	/bin/rm -f /tmp/GB.shar.Z
	chmod a+r /usr/ftp/pub/games/GB.shar.Z
	/bin/rm -f *.doc

# install the game for public use.
install:
	make
	mkdir Docs
	mv *.doc Docs
	compress Docs/* enroll.dat
	makeuniv < planet.list
	make chmod

