aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorforever2k38 <forever2k38@noreply.codeberg.org>2026-08-31 14:00:12 +0200
committerforever2k38 <forever2k38@noreply.codeberg.org>2026-08-31 14:00:12 +0200
commit9480e6d50d0ea549f894d9375c9be47f17db7f6b (patch)
tree318762c2fb8830ae9450f0ee0a8d3d21860f163d /Makefile
parent0334d0060c17f57d7a9b64677e3ca199a6029019 (diff)
use makefile
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile45
1 files changed, 45 insertions, 0 deletions
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)
+