PROG = pyramid
OBJS = $(PROG).o math3d.o gltools.o glframe.o shader.o
CC = gcc
DBGFLAGS = -g -O0
ifdef DEBUG
    CFLAGS = $(DBGFLAGS) -Wall -std=c99
else
    CFLAGS = -Wall -std=c99 -O2 -march=native -mtune=native
endif
LDFLAGS = -lglew32 -lopengl32 -lglu32 -lm -lfreeglut -lmingw32 -lsdlmain -lsdl -lsdl_image -mwindows

$(PROG): $(OBJS)
	$(CC) -o $(PROG) $(OBJS) $(LDFLAGS)

$(PROG).o: $(PROG).c math3d.h gltools.h glframe.h
	$(CC) -c $(CFLAGS) $(PROG).c

math3d.o: math3d.c math3d.h
	$(CC) -c $(CFLAGS) math3d.c

gltools.o: gltools.c gltools.h math3d.h
	$(CC) -c $(CFLAGS) gltools.c

glframe.o: glframe.c glframe.h math3d.h
	$(CC) -c $(CFLAGS) glframe.c

shader.o: shader.c shader.h math3d.h
	$(CC) -c $(CFLAGS) shader.c

.PHONY: clean

clean:
	rm -f *.o ./$(PROG).exe