CFLAGS=-g -fsanitize=address -fno-omit-frame-pointer -Wall -Wextra -pedantic -O0
CC=gcc

.PHONY: build clean run all

all: main dod boids_main

main: main.c lib.h sprites.o sprites.h game_data.h ./lib/libraylib.a
	$(CC) $(CFLAGS) -Iinclude/ -lm main.c -o main sprites.o ./lib/libraylib.a

sprites.o: sprites.c sprites.h lib.h
	$(CC) $(CFLAGS) -c sprites.c -o sprites.o

dod: dod.c ./lib/libraylib.a
	$(CC) $(CFLAGS) -Iinclude/ -lm dod.c -o dod ./lib/libraylib.a

boids_main: boids_main.c lib.h libboids.so
	$(CC) $(CFLAGS) -Iinclude/ -ldl -lm -lraylib $< -o $@ -L./lib -Wl,-rpath,./lib/

libboids.so: boids_game.c boids_game.h lib.h
	$(CC) $(CFLAGS) -shared -fPIC -Iinclude/ -lm $< -o $@

run: all
	./main

clean:
	rm -vf *.so *.o main boids_main dod
