From 85294e168a68d0ad5921966111f164cac5c1ea91 Mon Sep 17 00:00:00 2001 From: FoxyHunter7 <80623140+FoxyHunter7@users.noreply.github.com> Date: Sat, 30 May 2026 09:30:35 +0200 Subject: [PATCH] Feat: add Makefile --- Makefile | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5dca275 --- /dev/null +++ b/Makefile @@ -0,0 +1,34 @@ +TARGET := dns-keeper +SRC_DIR := src +BUILD_DIR := build + +CC := gcc +CFLAGS := -O2 -Wall -Wextra -ffunction-sections -fdata-sections -flto +CFLAGS += $(shell pkg-config --cflags libcurl) + +ifeq ($(STATIC),1) +LDFLAGS := -Wl,--gc-sections -Wl,-s -flto -static \ + $(shell pkg-config --static --libs libcurl) -lcjson -lpthread +else +LDFLAGS := -Wl,--gc-sections -Wl,-s -flto \ + $(shell pkg-config --libs libcurl) -lcjson -lpthread +endif + +SRCS := $(wildcard $(SRC_DIR)/*.c) +OBJS := $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o, $(SRCS)) + +.PHONY: all clean + +all: $(BUILD_DIR)/$(TARGET) + +$(BUILD_DIR)/$(TARGET): $(OBJS) + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) + +$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c | $(BUILD_DIR) + $(CC) $(CFLAGS) -c $< -o $@ + +$(BUILD_DIR): + mkdir -p $(BUILD_DIR) + +clean: + rm -rf $(BUILD_DIR)