CC = clang MODE ?= debug BACKEND ?= cli TARGET = sw1nek23per LFLAGS ?= ifeq ($(MODE), debug) CFLAGS = -ggdb -Wall -O0 else ifeq ($(MODE), release) CFLAGS = -Wall -O2 else $(error Unknown MODE: $(MODE). Use 'debug' or 'release') endif ifeq ($(BACKEND), raylib) LFLAGS += -lraylib -lm endif SRC_DIR = sw1nek23per BACKEND_DIR = $(SRC_DIR)/backend/$(BACKEND) BUILD_DIR = build SRCS = $(wildcard $(SRC_DIR)/*.c) SRCS += $(wildcard $(BACKEND_DIR)/*.c) .PHONY: clean build all run all: build run: ./$(BUILD_DIR)/$(TARGET) build: .build_dir $(SRCS) $(CC) $(CFLAGS) -o $(BUILD_DIR)/$(TARGET) $(LFLAGS) $(SRCS) clean: @rm -rf $(BUILD_DIR) .build_dir: @mkdir -p $(BUILD_DIR)