From 9480e6d50d0ea549f894d9375c9be47f17db7f6b Mon Sep 17 00:00:00 2001 From: forever2k38 Date: Mon, 31 Aug 2026 14:00:12 +0200 Subject: use makefile --- Makefile | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Makefile (limited to 'Makefile') diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4d60105 --- /dev/null +++ b/Makefile @@ -0,0 +1,45 @@ +CC=cc + +BIN_EXT = +MKDIR = mkdir -p $(OUT_DIR) $(dir $@) +RM = rm -rf + +CFLAGS=-Wall -Wpedantic + +LIBFLAGS=$(shell pkg-config --cflags --libs lua55) +DEBUG_CFLAGS=-g + +SRC_DIR=src +OUT_DIR=out +TARGET=pow +CFLAGS+=$(LIBFLAGS) + +ifeq ($(wildcard $(SRC_DIR)),) +$(error Source directory '$(SRC_DIR)' not found. Please specify the source directory using 'make SRC_DIR=path/to/source' or edit the makefile) +endif + +SRC_FILES := $(wildcard $(SRC_DIR)/**/*.c) $(wildcard $(SRC_DIR)/*.c) + +OBJ_FILES := $(patsubst $(SRC_DIR)/%.c,$(OUT_DIR)/%.o,$(SRC_FILES)) + +DEP_FILES := $(OBJ_FILES:.o=.d) + +$(OUT_DIR)/%.o: $(SRC_DIR)/%.c + $(MKDIR) + $(CC) -c -o $@ $< $(CFLAGS) + +-include $(DEP_FILES) + +all: $(TARGET) + +debug: CFLAGS += $(DEBUG_CFLAGS) +debug: $(TARGET) + +$(TARGET): $(OBJ_FILES) + $(CC) -o $@$(BIN_EXT) $^ $(CFLAGS) + +.PHONY: clean + +clean: + $(RM) $(OUT_DIR) $(TARGET)$(BIN_EXT) + -- cgit v1.3