CC = gcc
CFLAGS = -g -Wall

ifeq ($(OS),Windows_NT)
	include makefile_windows.variables
else
	UNAME = $(shell uname)
	ifeq ($(UNAME),Linux)
		include makefile_linux.variables
	else
		include makefile_mac.variables
	endif
endif

raylibfolder = ./raylib
unityfolder = ./unity

# --------------------------
# Initiales Programm bauen (zum ausprobieren)
# --------------------------
doble_initial:
	$(CC) -o doble_initial $(BINARIES)/libdoble_complete.a

# --------------------------
# Selbst implementiertes Programm bauen
# --------------------------
program_obj_files = stack.o bintree.o numbers.o timer.o highscore.o

doble : main.o $(program_obj_files)
	$(CC) $(CFLAGS) $(LDFLAGS) $^ -o doble

$(program_obj_files): %.o: %.c
	$(CC) -c $(CFLAGS) $^ -o $@

# --------------------------
# Unit Tests
# --------------------------
unity_src = $(unityfolder)/unity.c

unitTests: numbersTest stackTest bintreeTest
	./runNumbersTest
	./runStackTest
	./runBintreeTest

numbersTest: numbers.o bintree.o stack.o numbersTest.c $(unity_src) stack.o
	$(CC) $(CFLAGS) $(LDFLAGS) -I$(unityfolder) $^ -o runNumbersTest

stackTest: stack.o stackTest.c $(unity_src)
	$(CC) $(CFLAGS) $(LDFLAGS) -I$(unityfolder) $^ -o runStackTest

bintreeTest: bintree.o bintreeTest.c $(unity_src) stack.o
	$(CC) $(CFLAGS) $(LDFLAGS) -I$(unityfolder) $^ -o runBintreeTest
%.o: %.c
	$(CC) -c $(CFLAGS) $< -o $@

# --------------------------
# Clean
# --------------------------
clean:
ifeq ($(OS),Windows_NT)
	del /f *.o doble  doble_initial runNumbersTest runStackTest runBintreeTest
else
	rm -f *.o doble doble_initial runNumbersTest runStackTest runBintreeTest
endif