# 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)/spheral.sco
PIECEFILE = $(DESTLIBDIR)/spheral.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 = spheral.o disp.o game.o rots.o intro.o   \
   deco.o score.o gcgrey.o errdi.o

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

all: spheral

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

spheral.o: spheral.c spheral.h
disp.o: disp.c spheral.h
game.o: game.c spheral.h
rots.o: rots.c spheral.h
intro.o: intro.c spheral.h
deco.o: deco.c spheral.h
gcgrey.o: gcgrey.c spheral.h
errdi.o: errdi.c spheral.h
score.o: score.c spheral.h

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

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

clean: 
	rm -f *.o spheral

