CC = gcc
FLAGS = -g -Wall -lm

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) $(FLAGS) $^ -o doble

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

# --------------------------
# Unit Tests
# --------------------------
unitTests:
	echo "needs to be implemented"

# --------------------------
# Test: test_numbers
# --------------------------
test_numbers: stack.o bintree.o numbers.o unity.o
	$(CC) $(FLAGS) -Iunity test_numbers.c $^ -o runTest_numbers

unity.o:
	$(CC) -c $(FLAGS) -Iunity unity/unity.c -o unity.o

# --------------------------
# Test: test_bintree
# --------------------------
test_bintree: stack.o bintree.o unity.o
	$(CC) $(FLAGS) -Iunity test_bintree.c $^ -o runTest_bintree

# --------------------------
#Test: test_push_pop
# --------------------------
test_push_pop: stack.o unity.o
	$(CC) $(FLAGS) -Iunity test_push_pop.c $^ -o runTest_push_pop

# --------------------------
# Clean
# --------------------------
clean:
ifeq ($(OS),Windows_NT)
	del /f *.o doble runTest_numbers runTest_bintree runTest_push_pop
else
	rm -f *.o doble runTest_numbers runTest_bintree runTest_push_pop
endif