# This program was written by Alexander Siegel in September of 1989   
# at Cornell University.  It may may copied freely for private use or 
# public dispersion provided that this comment is not removed.  This  
# program, any portion of this program, or any derivative of this     
# program may not be sold or traded for financial gain.

# Name of game executable
GAME = golddig
# Name of level editor executable
EDITOR = gdedit
# Directory where games binaries are stored
BIN = ${PREFIX}/bin
# Directory where the library for this game will be stored
LIB = ${PREFIX}/share/${GAME}
#LIB = levs
# Directory where manual pages are kept
MANEXT = 6
MAN = ${PREFIX}/man/man${MANEXT}
# Add vms.c and vms.o to these lists if the operating system is VMS
SRCS = golddig.c shared.c badguy.c movement.c scores.c moveall.c
OBJS = golddig.o shared.o badguy.o movement.o scores.o moveall.o

# Common compilers
#CC = cc
#CC = gcc

# Some common choices for CFLAGS.
#CFLAGS = -O2 -I/usr/X11R6/include
CFLAGS+= -I${X11BASE}/include
#CFLAGS = -O
#CFLAGS = -O -W -Wreturn-type -Wunused -g -finline-functions
#CFLAGS = -g
#LDFLAGS = -g

all: ${GAME} ${EDITOR}

install: ${GAME} ${EDITOR}
	-mkdir -p ${LIB}
	install -c -s -o bin -g games -m 2755 ${GAME} ${BIN}
	install -c -s -o bin -g games -m 755 ${EDITOR} ${BIN}
	touch /var/games/golddig.scores
	chown bin:games /var/games/golddig.scores
	chmod 664 /var/games/golddig.scores
	install -c -o bin -g bin -m 0644 levs/goldlev* levs/default ${LIB}
	install -c -o root -g wheel -m 0644 golddig.6 ${MAN}/golddig.${MANEXT}
	install -c -o root -g wheel -m 0644 gdedit.6 ${MAN}/

update: ${GAME} ${EDITOR}
	cp ${GAME} ${EDITOR} ${BIN}
# The next line sets up the level files so that anyone can edit all of
# the levels.  Remove this line to have better security.
	chmod 4755 ${BIN}/${EDITOR}

clean:
	rm -f *.o *~ bitmap/*~ bitmaps.h core ${GAME} ${EDITOR}

lint:
	lint -DLIB=\"${LIB}\" ${SRCS}

${GAME}: ${OBJS}
	${CC} ${LDFLAGS} -o ${GAME} ${OBJS} -lX11

${EDITOR}: makelev.o shared.o
	${CC} ${LDFLAGS} -o ${EDITOR} makelev.o shared.o -lX11

shared.o: shared.c bitmaps.h

bitmaps.h: bitmap/*.bits
	cat bitmap/*.bits > bitmaps.h

.c.o:
	${CC} ${CFLAGS} -c -I. -DLIB=\"${LIB}\" $<
