GLEW_LIBS = $(shell pkgconf glew --libs)
GLFW_LIBS = $(shell pkgconf glfw3 --libs)
OTHER_LIBS = -lm

ALL_LIBS = $(GLEW_LIBS) $(GLFW_LIBS) $(OTHER_LIBS)

OBJ = matrixMath.o transformation.o wavefrontobj.o sceneGraph.o objectHandler.o shader.o
SHADERS = fragmentShader.c vertexShader.c

cg1.out: test.out main.o $(OBJ) $(SHADERS)
	./test.out
	gcc -o $@ main.o $(OBJ) $(ALL_LIBS) 

test.out: test.o $(OBJ)
	gcc -o $@ test.o $(OBJ) $(ALL_LIBS)

%Shader.c: %Shader.glsl
	xxd -i $? | tac | sed "3s/$$/, 0x00/" | tac > $@

main.o: $(SHADERS) matrixMath.h transformation.h wavefrontobj.h sceneGraph.h objectHandler.h shader.h

test.o: matrixMath.h transformation.h wavefrontobj.h

%.o: %.c
	gcc -c $<

run: cg1.out
	./cg1.out

test: test.out
	./test.out

clean:
	rm $(SHADERS) main.o test.o $(OBJ) cg1.out test.out