# Compiler settings CC=gcc CFLAGS=-std=c11 -Wall -Wextra -O2 -Iinclude SHELL=/bin/sh # Directories SRCDIR=src INCDIR=include OBJDIR=build DISTDIR=dist TESTDIR=tests # Platform-specific sources ifeq ($(OS),Windows_NT) PLATFORM_SRC=$(SRCDIR)/win32_platform.c OBJEXT=obj LIBEXT=dll RM=del /Q MKDIR=if not exist "$(1)" mkdir "$(1)" else PLATFORM_SRC=$(SRCDIR)/linux_platform.c OBJEXT=o LIBEXT=so RM=rm -f MKDIR=mkdir -p $(1) endif # Sources and objects SRC=$(PLATFORM_SRC) $(TESTDIR)/main.c OBJ=$(patsubst %.c,$(OBJDIR)/%.$(OBJEXT),$(SRC)) # Targets .PHONY: all clean run all: $(DISTDIR)/app # Build main executable $(DISTDIR)/app: $(OBJ) @$(call MKDIR,$(DISTDIR)) $(CC) $(CFLAGS) $(OBJ) -o $@ # Compile object files $(OBJDIR)/%.$(OBJEXT): %.c @$(call MKDIR,$(dir $@)) $(CC) $(CFLAGS) -c $< -o $@ # Run the app run: $(DISTDIR)/app $(DISTDIR)/app # Clean clean: -$(RM) $(OBJ) -$(RM) $(DISTDIR)/* @echo "Cleaned build and dist directories"