forked from cory/tildefriends
Cory McWilliams
352f33f5a1
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3859 ed5197a5-7fde-0310-b194-c3ffbd925b24
242 lines
7.9 KiB
Makefile
242 lines
7.9 KiB
Makefile
PROJECT = tildefriends
|
|
BUILD_DIR ?= out
|
|
BUILD_DIR_DBG := $(BUILD_DIR)/debug
|
|
BUILD_DIR_REL := $(BUILD_DIR)/release
|
|
UNAME_M := $(shell uname -m)
|
|
|
|
CFLAGS += \
|
|
-Wall \
|
|
-Wextra \
|
|
-Wno-unused-parameter \
|
|
-Wno-cast-function-type \
|
|
-MMD \
|
|
-ffunction-sections \
|
|
-fdata-sections
|
|
LDFLAGS += -Wl,-gc-sections
|
|
|
|
debug: CFLAGS += -Og -g
|
|
release: CFLAGS += -DNDEBUG -O3
|
|
|
|
ifeq ($(UNAME_M),x86_64)
|
|
debug: CFLAGS += -fsanitize=address -fsanitize=undefined
|
|
debug: LDFLAGS += -fsanitize=address -fsanitize=undefined
|
|
endif
|
|
|
|
APP_SOURCES = $(wildcard src/*.c)
|
|
APP_OBJS_DBG = $(patsubst %.c,$(BUILD_DIR_DBG)/%.o,$(APP_SOURCES))
|
|
APP_OBJS_REL = $(patsubst %.c,$(BUILD_DIR_REL)/%.o,$(APP_SOURCES))
|
|
APP_OBJS := $(APP_OBJS_DBG) $(APP_OBJS_REL)
|
|
$(APP_OBJS): CFLAGS += \
|
|
-Ideps/base64c/include \
|
|
-Ideps/crypt_blowfish \
|
|
-Ideps/quickjs \
|
|
-Ideps/sqlite \
|
|
-Ideps/libuv/include \
|
|
-Ideps/xopt \
|
|
-Ideps/libsodium \
|
|
-Werror
|
|
|
|
BASE64C_SOURCES = deps/base64c/src/base64c.c
|
|
BASE64C_OBJS_DBG = $(patsubst %.c,$(BUILD_DIR_DBG)/%.o,$(BASE64C_SOURCES))
|
|
BASE64C_OBJS_REL = $(patsubst %.c,$(BUILD_DIR_REL)/%.o,$(BASE64C_SOURCES))
|
|
BASE64C_OBJS := $(BASE64C_OBJS_DBG) $(BASE64C_OBJS_REL)
|
|
$(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_DBG = $(patsubst %.c,$(BUILD_DIR_DBG)/%.o,$(BLOWFISH_SOURCES))
|
|
BLOWFISH_OBJS_REL = $(patsubst %.c,$(BUILD_DIR_REL)/%.o,$(BLOWFISH_SOURCES))
|
|
BLOWFISH_OBJS := $(BLOWFISH_OBJS_DBG) $(BLOWFISH_OBJS_REL)
|
|
|
|
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/epoll.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_DBG = $(patsubst %.c,$(BUILD_DIR_DBG)/%.o,$(UV_SOURCES))
|
|
UV_OBJS_REL = $(patsubst %.c,$(BUILD_DIR_REL)/%.o,$(UV_SOURCES))
|
|
UV_OBJS := $(UV_OBJS_DBG) $(UV_OBJS_REL)
|
|
$(UV_OBJS): CFLAGS += \
|
|
-Ideps/libuv/include \
|
|
-Ideps/libuv/src \
|
|
-Wno-unused-but-set-variable \
|
|
-Wno-incompatible-pointer-types \
|
|
-Wno-sign-compare \
|
|
-D_GNU_SOURCE \
|
|
|
|
SODIUM_SOURCES = \
|
|
deps/libsodium/src/libsodium/crypto_auth/hmacsha512/auth_hmacsha512.c \
|
|
deps/libsodium/src/libsodium/crypto_auth/hmacsha512256/auth_hmacsha512256.c \
|
|
deps/libsodium/src/libsodium/crypto_box/crypto_box.c \
|
|
deps/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/box_curve25519xsalsa20poly1305.c \
|
|
deps/libsodium/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c \
|
|
deps/libsodium/src/libsodium/crypto_core/hsalsa20/ref2/core_hsalsa20_ref2.c \
|
|
deps/libsodium/src/libsodium/crypto_core/salsa/ref/core_salsa_ref.c \
|
|
deps/libsodium/src/libsodium/crypto_hash/sha256/cp/hash_sha256_cp.c \
|
|
deps/libsodium/src/libsodium/crypto_hash/sha256/hash_sha256.c \
|
|
deps/libsodium/src/libsodium/crypto_hash/sha512/cp/hash_sha512_cp.c \
|
|
deps/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna.c \
|
|
deps/libsodium/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305.c \
|
|
deps/libsodium/src/libsodium/crypto_scalarmult/crypto_scalarmult.c \
|
|
deps/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/x25519_ref10.c \
|
|
deps/libsodium/src/libsodium/crypto_scalarmult/curve25519/scalarmult_curve25519.c \
|
|
deps/libsodium/src/libsodium/crypto_secretbox/crypto_secretbox_easy.c \
|
|
deps/libsodium/src/libsodium/crypto_sign/crypto_sign.c \
|
|
deps/libsodium/src/libsodium/crypto_sign/ed25519/ref10/keypair.c \
|
|
deps/libsodium/src/libsodium/crypto_sign/ed25519/ref10/open.c \
|
|
deps/libsodium/src/libsodium/crypto_sign/ed25519/ref10/sign.c \
|
|
deps/libsodium/src/libsodium/crypto_stream/salsa20/ref/salsa20_ref.c \
|
|
deps/libsodium/src/libsodium/crypto_stream/salsa20/stream_salsa20.c \
|
|
deps/libsodium/src/libsodium/crypto_stream/xsalsa20/stream_xsalsa20.c \
|
|
deps/libsodium/src/libsodium/crypto_verify/sodium/verify.c \
|
|
deps/libsodium/src/libsodium/randombytes/randombytes.c \
|
|
deps/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c \
|
|
deps/libsodium/src/libsodium/sodium/core.c \
|
|
deps/libsodium/src/libsodium/sodium/utils.c
|
|
SODIUM_OBJS_DBG = $(patsubst %.c,$(BUILD_DIR_DBG)/%.o,$(SODIUM_SOURCES))
|
|
SODIUM_OBJS_REL = $(patsubst %.c,$(BUILD_DIR_REL)/%.o,$(SODIUM_SOURCES))
|
|
SODIUM_OBJS := $(SODIUM_OBJS_DBG) $(SODIUM_OBJS_REL)
|
|
$(SODIUM_OBJS): CFLAGS += \
|
|
-DCONFIGURED=1 \
|
|
-DMINIMAL=1 \
|
|
-Wno-unused-function \
|
|
-Wno-unused-variable \
|
|
-Ideps/libsodium/src/libsodium/include/sodium
|
|
|
|
SQLITE_SOURCES = deps/sqlite/sqlite3.c
|
|
SQLITE_OBJS_DBG = $(patsubst %.c,$(BUILD_DIR_DBG)/%.o,$(SQLITE_SOURCES))
|
|
SQLITE_OBJS_REL = $(patsubst %.c,$(BUILD_DIR_REL)/%.o,$(SQLITE_SOURCES))
|
|
SQLITE_OBJS := $(SQLITE_OBJS_DBG) $(SQLITE_OBJS_REL)
|
|
$(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_DBG = $(patsubst %.c,$(BUILD_DIR_DBG)/%.o,$(XOPT_SOURCES))
|
|
XOPT_OBJS_REL = $(patsubst %.c,$(BUILD_DIR_REL)/%.o,$(XOPT_SOURCES))
|
|
XOPT_OBJS := $(XOPT_OBJS_DBG) $(XOPT_OBJS_REL)
|
|
|
|
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_DBG = $(patsubst %.c,$(BUILD_DIR_DBG)/%.o,$(QUICKJS_SOURCES))
|
|
QUICKJS_OBJS_REL = $(patsubst %.c,$(BUILD_DIR_REL)/%.o,$(QUICKJS_SOURCES))
|
|
QUICKJS_OBJS := $(QUICKJS_OBJS_DBG) $(QUICKJS_OBJS_REL)
|
|
$(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 \
|
|
-Wno-enum-conversion
|
|
|
|
LDFLAGS += \
|
|
-pthread \
|
|
-ldl \
|
|
-lm \
|
|
-lssl \
|
|
-lcrypto #\
|
|
#-lsodium
|
|
|
|
debug: $(BUILD_DIR_DBG)/$(PROJECT)
|
|
release: $(BUILD_DIR_REL)/$(PROJECT)
|
|
all: debug release
|
|
.PHONY: all debug release
|
|
|
|
ALL_APP_OBJS_DBG = \
|
|
$(APP_OBJS_DBG) \
|
|
$(BASE64C_OBJS_DBG) \
|
|
$(BLOWFISH_OBJS_DBG) \
|
|
$(UV_OBJS_DBG) \
|
|
$(SODIUM_OBJS_DBG) \
|
|
$(SQLITE_OBJS_DBG) \
|
|
$(QUICKJS_OBJS_DBG) \
|
|
$(XOPT_OBJS_DBG)
|
|
ALL_APP_OBJS_REL = \
|
|
$(APP_OBJS_REL) \
|
|
$(BASE64C_OBJS_REL) \
|
|
$(BLOWFISH_OBJS_REL) \
|
|
$(UV_OBJS_REL) \
|
|
$(SODIUM_OBJS_REL) \
|
|
$(SQLITE_OBJS_REL) \
|
|
$(QUICKJS_OBJS_REL) \
|
|
$(XOPT_OBJS_REL)
|
|
ALL_APP_OBJS := $(ALL_APP_OBJS_DBG) $(ALL_APP_OBJS_REL)
|
|
|
|
DEPS = $(ALL_APP_OBJS:.o=.d)
|
|
-include $(DEPS)
|
|
|
|
$(BUILD_DIR_DBG)/$(PROJECT): $(ALL_APP_OBJS_DBG)
|
|
$(CC) -o $@ $^ $(LDFLAGS)
|
|
|
|
$(BUILD_DIR_REL)/$(PROJECT): $(ALL_APP_OBJS_REL)
|
|
$(CC) -o $@ $^ $(LDFLAGS)
|
|
|
|
$(BUILD_DIR_DBG)/%.o: %.c
|
|
@mkdir -p $(dir $@)
|
|
@echo [c] $@
|
|
@$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
$(BUILD_DIR_REL)/%.o: %.c
|
|
@mkdir -p $(dir $@)
|
|
@echo [c] $@
|
|
@$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
clean:
|
|
rm -rf $(BUILD_DIR)
|
|
.PHONY: clean
|