mirror of
https://github.com/onyx-and-iris/vmrcli.git
synced 2025-02-22 01:35:26 +00:00
add comments to makefile
This commit is contained in:
parent
9388844acb
commit
22b7e9a765
15
makefile
15
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)
|
||||
|
Loading…
Reference in New Issue
Block a user