# Makefile for Phantasia 3.2 (1.2 2.11BSD - 1997/9/22)
#
# MODIFIED TO COMPILE WITHOUT 'XSTR'.
#
# To create game:
#
# 1)  Set up a directory where the game and its support files will live.
#        (It is suggested that the source be kept somewhere else.)
# 2)  Set up the variables in Makefile to reflect your particular situation.
# 3)  Check out ok_to_play() at the end of main.c if you want to include
#        code to restrict access at certain times.
# 4)  'make install' and watch it fly.

LIBS =		-lm -lcurses -ltermcap

# DEST is where the program and its support files reside
#   If this changes then the symbolic link in the 'install' target must change.
DEST =		/games/lib/phantasia

# The following are program constants which are implementation dependent.
#
# PATH is the same as $DEST.
# WIZARD is the login of the one who will clean up things.
# UID is the uid of game wizard.
# RAND is one more than the largest number generated by rand().
#	Possible values for this are:
#		32768.0		(for 15 bit rand())
#		65536.0		(for 16 bit rand())
#		2147483648.0	(for 31 bit rand())
# ACCESS is fopen() access to open a file for writing, but no
#	clearing the file,  e.g. "a", or "r+".  (Use "r+" if you have it.)
# define OK_TO_PLAY to restrict playing access.  Also see function ok_to_play()
#	in main.c, and tailor to your own needs.
# define ENEMY to include code for checking of a 'hit list' of resricted
#	accounts.  The list of logins goes in the file 'enemy'.
# define BSD41 for 4.1bsd
# define BSD42 for 4.2bsd
# define USG3 for System III, or similar
# define USG5 for System V
CFLAGS = 	-DPATH=\"${DEST}\" \
		-DWIZARD=\"daemon\" \
		-DUID=1 \
		-DRAND=32768.0 \
		-DACCESS=\"r+\" \
		-DENEMY \
		-DBSD42 -O -Werror

OFILES          = main.o func0.o func1.o func2.o fight.o

all:		phantasia setfiles phant.help phantasia.0

phantasia:	${OFILES}
		${CC} ${OFILES} ${LIBS} -o phantasia

setfiles:	phant.h setfiles.c
		${CC} ${CFLAGS} setfiles.c -o setfiles -lm

# the flags below on tbl and nroff are to make a line printable version
phant.help:	phant.nr
		tbl -TX phant.nr | nroff -man -Ttn300 > phant.help

# DO NOT use an absolute pathname in the symbolic link below.  Figure out
#   what the relative path is.

install:	all phantasia.0
	rm -f ${DESTDIR}/usr/games/phantasia
	ln -s lib/phantasia/phantasia ${DESTDIR}/usr/games/phantasia
	-mkdir ${DESTDIR}${DEST}
	cp phantasia monsters phant.help ${DESTDIR}${DEST}
	chmod 755 ${DESTDIR}${DEST}
	chmod 4711 ${DESTDIR}${DEST}/phantasia
	chmod 644 ${DESTDIR}${DEST}/phant.help
	./setfiles
	install -m 444 -o bin -g bin  phantasia.0 ${DESTDIR}/usr/man/cat6

phantasia.0: phant.nr
	tbl -TX phant.nr | nroff -man -h -Tascii > phantasia.0

clean:
	rm -f *.o phantasia phant.help setfiles phantasia.0
