From 22b7e9a76587d64ef504c3f718c3f604e5911fb3 Mon Sep 17 00:00:00 2001 From: Onyx and Iris Date: Tue, 28 Jan 2025 22:27:20 +0000 Subject: [PATCH] add comments to makefile --- makefile | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/makefile b/makefile index 9dbbe9a..4799e6e 100644 --- a/makefile +++ b/makefile @@ -1,38 +1,53 @@ +# Program name program = vmrcli +# Compiler CC = gcc + +# Directories SRC_DIR := src OBJ_DIR := obj BIN_DIR := bin +# Executable and source/object files EXE := $(BIN_DIR)/$(program).exe SRC := $(wildcard $(SRC_DIR)/*.c) OBJ := $(SRC:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o) +# Conditional compilation flags for logging LOG_USE_COLOR ?= yes ifeq ($(LOG_USE_COLOR), yes) CPPFLAGS := -Iinclude -MMD -MP -DLOG_USE_COLOR else CPPFLAGS := -Iinclude -MMD -MP endif + +# Compiler and linker flags CFLAGS = -O -Wall -W -pedantic -ansi -std=c2x LDFLAGS := -Llib LDLIBS := -lm +# Phony targets .PHONY: all clean +# Default target all: $(EXE) +# Link the executable $(EXE): $(OBJ) | $(BIN_DIR) $(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@ +# Compile source files to object files $(OBJ_DIR)/%.o: $(SRC_DIR)/%.c | $(OBJ_DIR) $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ +# Create necessary directories $(BIN_DIR) $(OBJ_DIR): pwsh -Command New-Item -Path $@ -ItemType Directory +# Clean up generated files clean: pwsh -Command Remove-Item -Recurse $(EXE), $(OBJ_DIR) -force +# Include dependency files -include $(OBJ:.o=.d)