CC = gcc
CFLAGS = -g -Wall
LDFLAGS = -framework OpenGL -framework CoreFoundation -framework CoreGraphics -framework IOKit -framework Cocoa -framework CoreVideo
ARCH := $(shell uname -m)
BINARIES = ./macos-$(ARCH)
unityfolder = ./unity

RAYLIB_PATH = $(shell brew --prefix raylib)
RAYLIB_INCLUDE = -I$(RAYLIB_PATH)/include
RAYLIB_LIB = -L$(RAYLIB_PATH)/lib -lraylib

wordsalad_initial:
	$(CC) -o wordsalad_initial $(BINARIES)/libwordsalad_complete.a $(RAYLIB_LIB) $(LDFLAGS)

wordsalad: main.o input.o game.o graphicalGame.o
	$(CC) $(CFLAGS) -o wordsalad main.o input.o game.o graphicalGame.o $(RAYLIB_LIB) $(LDFLAGS)

main.o: main.c
	$(CC) -c $(CFLAGS) $(RAYLIB_INCLUDE) main.c

input.o: input.c
	$(CC) -c $(CFLAGS) input.c

game.o: game.c
	$(CC) -c $(CFLAGS) game.c

graphicalGame.o: graphicalGame.c
	$(CC) -c $(CFLAGS) $(RAYLIB_INCLUDE) graphicalGame.c

TEST_BIN = runTests
test: input.o game.o unit_tests.c $(BINARIES)/libunity.a
	$(CC) -Wall -I$(unityfolder) -o $(TEST_BIN) input.o game.o unit_tests.c $(BINARIES)/libunity.a

clean:
	rm -f *.o wordsalad wordsalad_initial $(TEST_BIN)