tildefriends/Makefile

171 lines
4.2 KiB
Makefile
Raw Normal View History

PROJECT = tildefriends
BUILD_DIR ?= out
COMMON_CFLAGS = \
-Wall \
-Wextra \
-Wno-unused-parameter \
-Wno-cast-function-type \
-MMD \
-ffunction-sections \
-fdata-sections
COMMON_LDFLAGS += -Wl,-gc-sections
ifneq ($(UNUSED),)
COMMON_LDFLAGS += -Wl,-print-gc-sections
endif
ifneq ($(DEBUG),)
COMMON_CFLAGS += -g -fsanitize=address -fsanitize=undefined
COMMON_LDFLAGS += -fsanitize=address -fsanitize=undefined
BUILD_DIR := $(BUILD_DIR)/debug
else
COMMON_CFLAGS += -DNDEBUG -O3
BUILD_DIR := $(BUILD_DIR)/release
endif
APP_BIN = $(BUILD_DIR)/$(PROJECT)
APP_SOURCES = $(wildcard src/*.c)
APP_OBJS = $(patsubst %.c,$(BUILD_DIR)/%.o,$(APP_SOURCES))
$(APP_OBJS): CFLAGS += \
-Ideps/base64c/include \
-Ideps/crypt_blowfish \
-Ideps/quickjs \
-Ideps/sqlite \
-Ideps/libuv/include \
-Ideps/xopt \
-Werror
BASE64C_SOURCES = deps/base64c/src/base64c.c
BASE64C_OBJS = $(patsubst %.c,$(BUILD_DIR)/%.o,$(BASE64C_SOURCES))
$(BASE64C_OBJS): CFLAGS += \
-Wno-sign-compare
BLOWFISH_SOURCES = \
deps/crypt_blowfish/crypt_blowfish.c \
deps/crypt_blowfish/crypt_gensalt.c \
deps/crypt_blowfish/wrapper.c
BLOWFISH_OBJS = $(patsubst %.c,$(BUILD_DIR)/%.o,$(BLOWFISH_SOURCES))
UV_SOURCES = \
deps/libuv/src/fs-poll.c \
deps/libuv/src/idna.c \
deps/libuv/src/inet.c \
deps/libuv/src/random.c \
deps/libuv/src/strscpy.c \
deps/libuv/src/threadpool.c \
deps/libuv/src/timer.c \
deps/libuv/src/unix/async.c \
deps/libuv/src/unix/core.c \
deps/libuv/src/unix/dl.c \
deps/libuv/src/unix/fs.c \
deps/libuv/src/unix/getaddrinfo.c \
deps/libuv/src/unix/getnameinfo.c \
deps/libuv/src/unix/linux-core.c \
deps/libuv/src/unix/linux-inotify.c \
deps/libuv/src/unix/linux-syscalls.c \
deps/libuv/src/unix/loop-watcher.c \
deps/libuv/src/unix/loop.c \
deps/libuv/src/unix/pipe.c \
deps/libuv/src/unix/poll.c \
deps/libuv/src/unix/process.c \
deps/libuv/src/unix/procfs-exepath.c \
deps/libuv/src/unix/proctitle.c \
deps/libuv/src/unix/random-devurandom.c \
deps/libuv/src/unix/random-getrandom.c \
deps/libuv/src/unix/random-sysctl-linux.c \
deps/libuv/src/unix/signal.c \
deps/libuv/src/unix/stream.c \
deps/libuv/src/unix/tcp.c \
deps/libuv/src/unix/thread.c \
deps/libuv/src/unix/tty.c \
deps/libuv/src/unix/udp.c \
deps/libuv/src/uv-common.c \
deps/libuv/src/uv-data-getter-setters.c \
deps/libuv/src/version.c
UV_OBJS = $(patsubst %.c,$(BUILD_DIR)/%.o,$(UV_SOURCES))
$(UV_OBJS): CFLAGS += \
-Ideps/libuv/include \
-Ideps/libuv/src \
-Wno-unused-but-set-variable \
-Wno-incompatible-pointer-types \
-Wno-sign-compare \
-D_GNU_SOURCE \
SQLITE_SOURCES = deps/sqlite/sqlite3.c
SQLITE_OBJS = $(patsubst %.c,$(BUILD_DIR)/%.o,$(SQLITE_SOURCES))
$(SQLITE_OBJS): CFLAGS += \
-DSQLITE_DBCONFIG_DEFAULT_DEFENSIVE \
-DSQLITE_ENABLE_JSON1 \
-DSQLITE_MAX_LENGTH=5242880 \
-DSQLITE_MAX_SQL_LENGTH=100000 \
-DSQLITE_MAX_COLUMN=100 \
-DSQLITE_MAX_EXPR_DEPTH=20 \
-DSQLITE_MAX_COMPOUND_SELECT=3 \
-DSQLITE_MAX_VDBE_OP=25000 \
-DSQLITE_MAX_FUNCTION_ARG=8 \
-DSQLITE_MAX_ATTACHED=0 \
-DSQLITE_MAX_LIKE_PATTERN_LENGTH=50 \
-DSQLITE_MAX_VARIABLE_NUMBER=100 \
-DSQLITE_MAX_TRIGGER_DEPTH=10 \
-DSQLITE_SECURE_DELETE \
-Wno-implicit-fallthrough
XOPT_SOURCES = deps/xopt/xopt.c
XOPT_OBJS = $(patsubst %.c,$(BUILD_DIR)/%.o,$(XOPT_SOURCES))
QUICKJS_SOURCES = \
deps/quickjs/cutils.c \
deps/quickjs/libbf.c \
deps/quickjs/libregexp.c \
deps/quickjs/libunicode.c \
deps/quickjs/quickjs-libc.c \
deps/quickjs/quickjs.c
QUICKJS_OBJS = $(patsubst %.c,$(BUILD_DIR)/%.o,$(QUICKJS_SOURCES))
$(QUICKJS_OBJS): CFLAGS += \
-DCONFIG_VERSION=\"$(shell cat deps/quickjs/VERSION)\" \
-DDUMP_LEAKS \
-D_GNU_SOURCE \
-Wno-sign-compare \
-Wno-implicit-fallthrough \
-Wno-unused-variable \
-Wno-unused-but-set-variable
APP_LDFLAGS = \
$(COMMON_LDFLAGS) \
$(LDFLAGS) \
-pthread \
-ldl \
-lm \
-lssl \
-lcrypto \
-lsodium
DEFAULT_TARGET = $(APP_BIN)
all: $(DEFAULT_TARGET)
.PHONY: all
ALL_APP_OBJS = \
$(APP_OBJS) \
$(BASE64C_OBJS) \
$(BLOWFISH_OBJS) \
$(UV_OBJS) \
$(SQLITE_OBJS) \
$(QUICKJS_OBJS) \
$(XOPT_OBJS)
DEPS = $(ALL_APP_OBJS:.o=.d)
-include $(DEPS)
$(APP_BIN): $(ALL_APP_OBJS)
$(CC) -o $@ $^ $(APP_LDFLAGS)
$(BUILD_DIR)/%.o: %.c
@mkdir -p $(dir $@)
@echo [c] $@
@$(CC) $(COMMON_CFLAGS) $(CFLAGS) -c $< -o $@
clean:
rm -rf $(BUILD_DIR)
.PHONY: clean