# To compile/install, type 'make' as root.


# uncomment this line to have joystick support (must have joystick kernel
# patches and devices installed)
#FEATURES = -DJOYSTICK


# This is where the high score list will be stored
SCOREDIR = /var/games


# Where the executable will be placed
BINDIR   = /usr/games


##############################################################################
#************  Probably don't need to edit anything after this ***************
##############################################################################


PACKAGE  = sasteroids1.1

# the .xpm to c translator
XPM2BIT = ./xpm2bit

CC	 = g++
INC      = -I/usr/local/include
OPTIMIZE = -Wall -fomit-frame-pointer -O2 -s
OPTS	 = -m486 -pipe

DEFINES  = $(FEATURES) -DSCOREDIR=\"$(SCOREDIR)/\"
CFLAGS	 = $(DEFINES) $(INC) $(OPTIMIZE) $(OPTS)

# for debugging
#CFLAGS	 = $(DEFINES) $(INC) $(OPTS) -g

LFLAGS   = 

PROG    = sasteroids
PROG_O  = sasteroids.o bitmaps.o titleScn.o HiScore.o Bitmap.o str.o \
	  Timer.o Ui.o backScn.o ObjTools.o Obj.o FastMath.o Explosion.o \
	  Joystick.o

LIBS     = -lvgagl -lvga -lm

all:	install

$(PROG): $(PROG_O)
	$(CC) $(LFLAGS) $(PROG_O) -o $(PROG) $(LIBS)

install: $(PROG)
	install -d $(SCOREDIR)
	install -d $(BINDIR)
	install --strip --mode=4755 $(PROG) $(BINDIR)

cleanbin: clean
	rm -f $(PROG)

clean:
	rm -f *.o *~

depend:
	makedepend -- $(INC) -- *.c

.c.o:
	$(CC) $(CFLAGS) -c -o $*.o $<

.c.s:
	$(CC) $(CFLAGS) -S -o $*.s $<


# this creates the .tar.gz distribution.
distrib: clean
	rm -rf $(PACKAGE).tar.gz
	( cd .. ; tar zcvvf $(PACKAGE)/$(PACKAGE).tar.gz $(PACKAGE)/*.[ch] \
		  $(PACKAGE)/?akefile $(PACKAGE)/1-* \
		  $(PACKAGE)/*xpm $(PACKAGE)/$(XPM2BIT) )

# do a 'make bitmaps' if you change any of the '.xpm' files.
newbitmaps: rm-old-bitmaps bitmaps.c titleScn.c backScn.c

rm-old-bitmaps:
	rm -rf bitmaps.c titleScn.c backScn.c

bitmaps.c: medast.xpm bigast.xpm bullet.xpm enemy.xpm ship0.xpm ship1.xpm
	$(XPM2BIT) -p bitmaps medast.xpm bigast.xpm bullet.xpm enemy.xpm \
		   ship0.xpm ship1.xpm
	
titleScn.c: title.xpm
	$(XPM2BIT) -p titleScn title.xpm

backScn.c: back.xpm
	$(XPM2BIT) -p backScn back.xpm



# hand-made since 'makedepend' acts a little weird anyway.
Bitmap.o:	Bitmap.h FastMath.h
FastMath.o:	FastMath.h
ObjTools.o:	ObjTools.h FastMath.h
Obj.o:		Obj.h ObjTools.h bitmaps.h Bitmap.h 
Explosion.o:	Bitmap.h bitmaps.h ObjTools.h PtrList.h FastMath.h Explosion.h
HiScore.o:	HiScore.h str.h 
Timer.o:	Timer.h 
Ui.o: 		Ui.h str.h
Joystick.o:	Joystick.h
sasteroids.o: 	bitmaps.h Bitmap.h titleScn.h backScn.h Timer.h FastMath.h
sasteroids.o: 	sasteroids.h HiScore.h str.h Obj.h Ui.h ObjTools.h Joystick.h
titleScn.o: 	titleScn.h Bitmap.h 
backScn.o: 	backScn.h Bitmap.h 
bitmaps.o: 	bitmaps.h Bitmap.h 
str.o: 		str.h
