#
# Makefile for U/Toronto games.
#
# HP-UX:
#
#CFLAGS = -g $$FLOAT
#FFLAGS = -g -C $$FLOAT
#
CFLAGS = -O $$FLOAT
FFLAGS = -O $$FLOAT
#
SAVEOPT = -K
LDFLAGS = -lutchem
#
# HP/Apollo Domain/OS:
#
#CFLAGS = -g $$FLOAT
#FFLAGS = -g -C $$FLOAT
#
#CFLAGS = -O $$FLOAT
#FFLAGS = -O $$FLOAT
#
#SAVEOPT = -W0,-save
#LDFLAGS = -lutchem
#
# List of objects to be put into the library:
#
OBJS = adds.o adm.o clear.o delay.o display.o hazel.o\
igetbuffer1.o isetbuffer1.o ishft.o pe550.o putline.o\
random.o readch.o setfcb.o termset.o transp.o\
tvi914.o vt100.o writch.o
#
# Make everything - note that bzone and stwar only work on Apollo
# Domain/OS systems with GPR graphics, and dtrek only works on X11.
#
all:
	make libgames.a
	make adventure
	make chess
	make fireworks
	make keno
	make master
	make minefield
	make party
	make slogro
	make startrek
	make tictac
	make zombies
	(cd scrabble ; make install)
	(cd dtrek ; make install)
	#(cd bzone ; make bzone)
	#(cd stwar ; make stwar)
	make install
#
# Install everything in /usr/local/bin.
#
install:
	-if [ -f adventure ]; then \
	 cp adventure /usr/local/bin ;\
	 echo "adventure copied to /usr/local/bin" ; fi
	-if [ -f chess ]; then \
	 cp chess /usr/local/bin ;\
	 echo "chess copied to /usr/local/bin" ; fi
	-if [ -f fireworks ]; then \
	 cp fireworks /usr/local/bin ;\
	 echo "fireworks copied to /usr/local/bin" ; fi
	-if [ -f keno ]; then \
	 cp keno /usr/local/bin ;\
	 echo "keno copied to /usr/local/bin" ; fi
	-if [ -f master ]; then \
	 cp master /usr/local/bin ;\
	 echo "master copied to /usr/local/bin" ; fi
	-if [ -f minefield ]; then \
	 cp minefield /usr/local/lib ;\
	 echo "minefield copied to /usr/local/lib" ; fi
	-if [ -f party ]; then \
	 cp party /usr/local/bin ;\
	 echo "party copied to /usr/local/bin" ; fi
	-if [ -f slogro ]; then \
	 cp slogro /usr/local/bin ;\
	 echo "slogro copied to /usr/local/bin" ; fi
	-if [ -f startrek ]; then \
	 cp startrek /usr/local/bin ;\
	 echo "startrek copied to /usr/local/bin" ; fi
	-if [ -f tictac ]; then \
	 cp tictac /usr/local/bin ;\
	 echo "tictac copied to /usr/local/bin" ; fi
	-if [ -f zombies ]; then \
	 cp zombies /usr/local/lib ;\
	 echo "zombies copied to /usr/local/lib" ; fi
	-if [ -f bzone/bzone ]; then \
	 (cd bzone ; make install) ;\
	 echo "bzone copied to /usr/local/bin" ; fi
	-if [ -f stwar/stwar ]; then \
	 (cd stwar ; make install) ;\
	 echo "stwar copied to /usr/local/bin" ; fi
#
# Make libgames.a.
#
libgames.a: $(OBJS)
	ar -rv ./libgames.a $(OBJS)
	ranlib ./libgames.a
#
# Make adventure.
# Never attempt to use '-C' on adventure.f due to some "illegal" array
# subscripting used in routine 'IO'.
#
adventure: adventure.f libgames.a
	f77 $(FFLAGS) adventure.f libgames.a $(LDFLAGS) -o adventure
	-rm -r adventure.o
#
# Make chess.
# Always set the 'save' flag for compiling chess.
# For the DSP10000 set the 'iso' flag for compiling chess.
#
chess: chess.f
	f77 $(FFLAGS) $(SAVEOPT) chess.f $(LDFLAGS) -o chess
	-rm -r chess.o
#
# Make fireworks.
#
fireworks: fireworks.c
	cc $(CFLAGS) fireworks.c -lcurses -ltermcap $(LDFLAGS) -o fireworks
#
# Make keno.
#
keno: keno.f libgames.a
	f77 $(FFLAGS) keno.f libgames.a $(LDFLAGS) -o keno
	-rm -r keno.o
#
# Make master.
# Always set the 'save' flag for compiling master.
#
master: master.f libgames.a
	f77 $(FFLAGS) $(SAVEOPT)  master.f libgames.a $(LDFLAGS) -o master
	-rm -r master.o
#
# Make minefield.
#
minefield: minefield.f libgames.a
	f77 $(FFLAGS) minefield.f libgames.a $(LDFLAGS) -o minefield
	-rm -r minefield.o
#
# Make party.
#
party: party.f libgames.a
	f77 $(FFLAGS) party.f libgames.a $(LDFLAGS) -o party
	-rm -r party.o
#
# Make slogro.
#
slogro: slogro.f libgames.a
	f77 $(FFLAGS) slogro.f libgames.a $(LDFLAGS) -o slogro
	-rm -r slogro.o
#
# Make startrek.
# Always set the 'save' flag for compiling startrek.
#
startrek: startrek.f libgames.a
	f77 $(FFLAGS) $(SAVEOPT) startrek.f libgames.a $(LDFLAGS) -o startrek
	-rm -r startrek.o
#
# Make tictac.
#
tictac: tictac.f
	f77 $(FFLAGS) tictac.f $(LDFLAGS) -o tictac
	-rm -r tictac.o
#
# Make zombies.
#
zombies: zombies.f libgames.a
	f77 $(FFLAGS) zombies.f libgames.a $(LDFLAGS) -o zombies
	-rm -r zombies.o
#
# Clean *.o and core files from the current directory.
# Usage: make clean.
#
clean:
	-rm -f *.o core
	-rm -f libgames.a adventure chess fireworks keno master minefield
	-rm -f party slogro startrek tictac zombies
	-(cd scrabble ; make clean)
	-(cd dtrek ; make clean)
	-(cd bzone ; make clean)
	-(cd stwar ; make clean)
