CC = gcc
CFLAGS = -g -Wall -Wextra
CPPFLAGS = -I$(raylibfolder) -I$(unityfolder)
LDFLAGS =
LDLIBS = -lGL -lX11 -lm

BINARIES = ./linux
raylibfolder = ./raylib
unityfolder = ./unity

TARGET = wordsalad
TEST_BIN = runTests

OBJS = main.o input.o game.o graphicalGame.o

.PHONY: all clean test

all: $(TARGET)

wordsalad_ourversion: main.o $(BINARIES)/libwordsalad.a $(BINARIES)/libraylib.a
	$(CC) $(CFLAGS) -o $@ main.o $(BINARIES)/libwordsalad.a $(BINARIES)/libraylib.a $(LDLIBS)

$(TARGET): $(OBJS) $(BINARIES)/libraylib.a
	$(CC) $(CFLAGS) -o $@ $(OBJS) $(BINARIES)/libraylib.a $(LDLIBS)

main.o: main.c input.h game.h graphicalGame.h
	$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@

input.o: input.c input.h
	$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@

game.o: game.c game.h input.h
	$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@

graphicalGame.o: graphicalGame.c graphicalGame.h game.h
	$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@

test: input.o game.o unit_tests.c
	$(CC) $(CFLAGS) $(CPPFLAGS) -o $(TEST_BIN) input.o game.o unit_tests.c $(BINARIES)/libunity.a

clean:
	rm -f *.o $(TARGET) $(TEST_BIN) wordsalad_ourversion