CC = gcc
FLAGS = -Wall -Wextra -g
LFLAGS = -lSDL2 -lSDL2_image -lm

all: bin/back

testL: bin/back
	bin/back levels/long.txt bots/dumb bots/dumb2 bots/dumb3 bots/dumb4 bots/dumb5 bots/dumb6

test: bin/back
	bin/back levels/test.txt bots/follow1 bots/follow2 bots/follow3 bots/dumb4

test2: bin/back
	bin/back levels/long.txt bots/follow1 bots/follow2 bots/follow3 bots/dumb4

ez: bin/back
	bin/back levels/simple.txt bots/dumb bots/dumb2 bots/dumb3 bots/dumb4

spin: bin/back
	bin/back levels/turning.txt bots/dumb bots/dumb2 bots/dumb3 bots/dumb4

road: bin/back
	bin/back levels/straight.txt bots/dumb bots/dumb2 bots/dumb3 bots/dumb4

mem: bin/back
	valgrind --leak-check=full ./bin/back levels/simple.txt bots/follow1 bots/follow2 bots/dumb4

bin/back: obj/main.o obj/display.o obj/base.o obj/collisions.o obj/music.o obj/cars.o obj/rooms.o obj/structure.o
	mkdir -p bin
	$(CC) $(FLAGS) $^ $(LFLAGS) -o $@

obj/%.o: src/%.c
	@mkdir -p obj
	$(CC) -o $@ -c $(FLAGS) $<

obj/main.o: src/main.c
obj/display.o: src/display.c
obj/base.o: src/base.c
obj/cars.o: src/cars.c
obj/music.o: src/music.c
obj/rooms.o: src/rooms.c
obj/collisions.o: src/collisions.c
obj/structure.o: src/structure.c

.PHONY: clean mrproper

clean:
	rm -rf obj/

mrproper: clean
	rm -rf bin/
