# The next lines define the directories where the executable, piece file,
# and score file are installed. Change them to whatever is appropriate.
DESTDIR = /tmp/dest
DESTLIBDIR = $(DESTDIR)/lib
DESTBINDIR = $(DESTDIR)/bin
DESTMANDIR = $(DESTDIR)/man

SCOREFILE = $(DESTLIBDIR)/spatial.sco
PIECEFILE = $(DESTLIBDIR)/spatial.shp

DEFINES =

# uncomment the next line if your system doesn't have
# random() and srandom()
#DEFINES = -Drandom=lrand48 -Dsrandom=srand48

# uncomment the next line for Solaris, which has neither
# flock() nor random().
#DEFINES = -DUSELOCKF -Drandom=lrand48 -Dsrandom=srand48

INCLUDES = -I/usr/local/include
XLIBS = -L/usr/local/lib -lX11

OBJS = spatial.o disp.o game.o rots.o intro.o deco.o score.o

CFLAGS= -O $(DEFINES) $(INCLUDES)  \
   -DSCOREFILENAME=\"$(SCOREFILE)\"  \
   -DPIECEFILENAME=\"$(PIECEFILE)\"

all: spatial

spatial: $(OBJS)
	$(CC) $(CFLAGS) $(OBJS) -o spatial $(XLIBS) -lm 

spatial.o: spatial.c spatial.h
disp.o: disp.c spatial.h
game.o: game.c spatial.h
rots.o: rots.c spatial.h
intro.o: intro.c spatial.h
deco.o: deco.c spatial.h
score.o: score.c spatial.h

targetdirs:
	-mkdir $(DESTLIBDIR)
	-mkdir $(DESTBINDIR)
	-mkdir $(DESTMANDIR)
	-mkdir $(DESTMANDIR)/man6

install: spatial  targetdirs
	install -c -s spatial $(DESTBINDIR)
	install -c spatial.shp  $(PIECEFILE)
	install -c spatial.6 $(DESTMANDIR)/man6

clean: 
	rm -f *.o spatial

