ifeq ($(OS),Windows_NT)
    DETECTED_OS := windows
else
    UNAME_S := $(shell uname -s)

    ifeq ($(UNAME_S),Darwin)
        DETECTED_OS := macos
    else ifeq ($(UNAME_S),Linux)
        DETECTED_OS := linux
    else
        DETECTED_OS := unknown
	endif
endif

CC = clang

UFLAGS =
FLAGS = -Wall -Wextra -ggdb -fno-caret-diagnostics -fno-show-column -Wno-missing-field-initializers -Wno-unused-function -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable
		#-std=c99 -pedantic

ifeq ($(DETECTED_OS),macos)
	INCLUDE = -I./raylib/include/ 
	LIBS = ./raylib/lib/arm_macos/libraylib.a -lm
	FRAMEWORKS = -framework IOKit -framework Cocoa -framework OpenGL
else ifeq ($(DETECTED_OS),linux)
	INCLUDE = -I./raylib/include/
	LIBS = ./raylib/lib/x86_64-linux/libraylib.a -lm -lX11
	FRAMEWORKS = 
else ifeq ($(DETECTED_OS),windows)
	INCLUDE = 
	LIBS = 
	FRAMEWORKS = 
else
	INCLUDE = 
	LIBS = 
	FRAMEWORKS = 
endif

EXE=timetracker

$(EXE): $(EXE).c
	$(CC) $(FLAGS) $(UFLAGS) $(INCLUDE) $^ $(LIBS) $(FRAMEWORKS) -o $@

tags: $(OBJS)
	ctags -R *.h *.c

clean:
	rm -rf $(EXE) $(EXE).dSYM
