CC=gcc

WARNING_FLAGS=-Wall -Wextra -Werror-implicit-function-declaration -Wshadow -Wstrict-prototypes -pedantic-errors
CFLAGS=-g -O2 -std=c99 $(WARNING_FLAGS)
LDFLAGS=-g -lGL -lglut -lGLU `libpng12-config --libs`

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

all: main
main: geometry.o main.o polys.o readpng.o bsp.o
	$(CC) $(LDFLAGS) -o main geometry.o main.o polys.o readpng.o bsp.o

readpng.o: readpng.c
		$(CC) -c $(CLFAGS) `libpng12-config --cflags` readpng.c

clean:
	rm -f *.o
	rm -f main

geometry.o  : geometry.h polys.h geometry.c
polys.o     : polys.h polys.c
main.o      : bsp.h geometry.h polys.h readpng.h main.c
readpng.o   : readpng.h readpng.c
bsp.o       : bsp.h bsp.c polys.h
