#edit this for your architekture!
#ARCH=-m386
#ARCH=-m486
#ARCH=-mpentium
#uncoment one of the following modes to select resolution
#DEFINES = -D G320x200 	#run on all machines
DEFINES = -D G640x480 	#better run slowly on 386 and / or trident vga card
			#on 486dx/2 with S3 chip works OK 
#uncoment following for joystick support
#JOYSTICK = -D JOYSTICK	#requires joystick toolkit installed!
#don`t add / and spaces at end of path! 
SOUNDDIR = /usr/games/kouleslib
BINDIR = /usr/games/
MANDIR = /usr/man/man6









CC	 = gcc
#OPTIMIZE = -Wall
OPTIMIZE = -fomit-frame-pointer -O6  -ffast-math   -s
OPTIMIZE1 = -fomit-frame-pointer -O6  -ffast-math -funroll-loops -finline-functions   -s
#OPTIMIZE =  -O2 -g -p
#OPTIMIZE1 =  -O2 -g  -p
CFLAGS	 = $(DEFINES) $(ARCH) $(JOYSTICK) -DSOUNDDIR="\"$(SOUNDDIR)\""
LFLAGS   = -N

PROGS    = koules
PROGS_O  = koules.o soundIt.o menu.o gameplan.o font.o
LIBS     = -lvgagl -lvga


all:	progs

progs : $(PROGS)

objs:	$(PROGS_O)

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

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

.o:
	$(CC) $(CFLAGS) $(OPTIMIZE1) $(LFLAGS) -o $* $*.o $(LIBS)
	chmod a+rs,go-w $*

font.o: font.c
	@echo please be patient.
	@echo the font.c is big and ugly i ripped it from zgv. 
	@echo do you know about better one?
	$(CC) $(OPTIMIZE1) $(CFLAGS) -c  $< 

koules.o: koules.c
	$(CC) $(OPTIMIZE1) $(CFLAGS) -Wall -c  $< 

koules: $(PROGS_O)
	$(CC) $(OPTIMIZE1) $(CFLAGS) $(LFLAGS) -o koules $(PROGS_O) $(LIBS) -lm
install: $(PROG)
	install -o root -m 4511 koules $(BINDIR)
	@-mkdir $(SOUNDDIR)
	chmod 555 $(SOUNDDIR)
	install -m 444 *.raw $(SOUNDDIR)
	install -m 444 koules.6 $(MANDIR)

clean:
	rm *.o koules *~ .depend

indent:
	indent -di16 *.c *.h

dep:
	rm -f .depend
	make .depend

.depend:
	echo '# Program dependencies' >.depend
	gcc $(DEFINES) -MM $(patsubst %.o,%.c,$(PROGS_O)) >>.depend

include .depend
