Files

35 lines
808 B
Makefile

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)