OUTPUT=src/blockracer
FILES=blockracer.o mainloop.o graphics.o input.o gamepad.o\
player.o world.o blocks.o textures.o math.o text.o archive.o\
compression.o random.o clouds.o
ARGS=-c $< -o $@
CC=g++

all: $(OUTPUT)

$(OUTPUT): src $(FILES)# $(RESOURCES)
	$(CC) $(FILES) -o $@ -lglut -lGL -lGLU -lX11 -lm -ludev -lz

src/resources:
	mkdir src/resources

src:
	mkdir src

blockracer.o: blockracer.cpp graphics.h input.h player.h world.h text.h archive.h clouds.h
	$(CC) $(ARGS)

mainloop.o: libs/mainloop-api/mainloop.cpp
	$(CC) $(ARGS)

graphics.o: graphics.cpp graphics.h player.h world.h textures.h clouds.h
	$(CC) $(ARGS)

input.o: input.cpp input.h gamepad.h
	$(CC) $(ARGS)

gamepad.o: gamepad.c gamepad.h
	gcc $(ARGS) -Wall -Werror

player.o: player.cpp player.h input.h world.h textures.h blocks.h
	$(CC) $(ARGS)

world.o: world.cpp world.h graphics.h blocks.h math.h player.h random.h
	$(CC) $(ARGS)

blocks.o: blocks.cpp blocks.h textures.h archive.h
	$(CC) $(ARGS)

textures.o: textures.cpp textures.h archive.h
	$(CC) $(ARGS)

math.o: math.cpp math.h
	$(CC) $(ARGS)

text.o: text.cpp textures.h
	$(CC) $(ARGS)

archive.o: archive.cpp archive.h compression.h
	$(CC) $(ARGS)

compression.o: compression.cpp compression.h zlib.h
	$(CC) $(ARGS)

random.o: random.cpp random.h
	$(CC) $(ARGS)

clouds.o: clouds.cpp clouds.h math.h textures.h random.h
	$(CC) $(ARGS)

clean:
	rm -r src *.o

run:
	cd src && ./blockracer

backup:
	cd .. && ./backup.sh

archive: resources
	cd .. && ./make-archive.sh