| 
									
										
										
										
											2021-01-02 18:10:00 +00:00
										 |  |  | PROJECT = tildefriends | 
					
						
							|  |  |  | BUILD_DIR ?= out | 
					
						
							| 
									
										
										
										
											2022-05-26 00:47:36 +00:00
										 |  |  | BUILD_TYPES := debug release windebug winrelease | 
					
						
							| 
									
										
										
										
											2022-01-22 20:20:21 +00:00
										 |  |  | UNAME_M := $(shell uname -m) | 
					
						
							| 
									
										
										
										
											2021-01-02 18:10:00 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-03 22:14:06 +00:00
										 |  |  | CFLAGS += \
 | 
					
						
							| 
									
										
										
										
											2021-01-02 18:10:00 +00:00
										 |  |  | 	-Wall \
 | 
					
						
							|  |  |  | 	-Wextra \
 | 
					
						
							|  |  |  | 	-Wno-unused-parameter \
 | 
					
						
							|  |  |  | 	-Wno-cast-function-type \
 | 
					
						
							|  |  |  | 	-MMD \
 | 
					
						
							|  |  |  | 	-ffunction-sections \
 | 
					
						
							|  |  |  | 	-fdata-sections | 
					
						
							| 
									
										
										
										
											2021-10-03 22:14:06 +00:00
										 |  |  | LDFLAGS += -Wl,-gc-sections | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-30 17:24:42 +00:00
										 |  |  | debug windebug: CFLAGS += -Og -g | 
					
						
							|  |  |  | release winrelease: CFLAGS += -DNDEBUG -O3 -g | 
					
						
							| 
									
										
										
										
											2022-05-26 00:47:36 +00:00
										 |  |  | windebug winrelease: CC = i686-w64-mingw32-gcc-win32 | 
					
						
							|  |  |  | windebug winrelease: AS = $(CC) | 
					
						
							|  |  |  | windebug winrelease: CFLAGS += -D_WIN32_WINNT=0x0A00 -DWINVER=0x0A00 -DNTDDI_VERSION=NTDDI_WIN10 | 
					
						
							|  |  |  | windebug winrelease: LDFLAGS += -static | 
					
						
							| 
									
										
										
										
											2021-10-03 22:14:06 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-22 20:20:21 +00:00
										 |  |  | ifeq ($(UNAME_M),x86_64) | 
					
						
							| 
									
										
										
										
											2022-07-24 21:05:23 +00:00
										 |  |  | debug: CFLAGS += -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer -fno-common | 
					
						
							| 
									
										
										
										
											2022-01-22 20:20:21 +00:00
										 |  |  | debug: LDFLAGS += -fsanitize=address -fsanitize=undefined | 
					
						
							| 
									
										
										
										
											2022-01-22 20:13:14 +00:00
										 |  |  | endif | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-26 00:47:36 +00:00
										 |  |  | get_objs = \
 | 
					
						
							| 
									
										
										
										
											2022-05-30 17:24:42 +00:00
										 |  |  | 	$(foreach build_type,$(BUILD_TYPES),$(addprefix $(BUILD_DIR)/$(build_type)/,$(addsuffix .o,$(basename $(value $(1)))))) \
 | 
					
						
							|  |  |  | 	$(foreach build_type,debug release,$(addprefix $(BUILD_DIR)/$(build_type)/,$(addsuffix .o,$(basename $(value $(1)_unix))))) \
 | 
					
						
							|  |  |  | 	$(foreach build_type,windebug winrelease,$(addprefix $(BUILD_DIR)/$(build_type)/,$(addsuffix .o,$(basename $(value $(1)_win))))) | 
					
						
							| 
									
										
										
										
											2022-05-26 00:47:36 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | APP_SOURCES := $(wildcard src/*.c) | 
					
						
							|  |  |  | APP_OBJS := $(call get_objs,APP_SOURCES) | 
					
						
							| 
									
										
										
										
											2021-01-02 18:10:00 +00:00
										 |  |  | $(APP_OBJS): CFLAGS += \ | 
					
						
							|  |  |  | 	-Ideps/base64c/include \
 | 
					
						
							|  |  |  | 	-Ideps/crypt_blowfish \
 | 
					
						
							|  |  |  | 	-Ideps/quickjs \
 | 
					
						
							|  |  |  | 	-Ideps/sqlite \
 | 
					
						
							|  |  |  | 	-Ideps/libuv/include \
 | 
					
						
							| 
									
										
										
										
											2021-01-04 01:58:50 +00:00
										 |  |  | 	-Ideps/xopt \
 | 
					
						
							| 
									
										
										
										
											2022-03-08 03:42:47 +00:00
										 |  |  | 	-Ideps/libsodium \
 | 
					
						
							| 
									
										
										
										
											2022-05-16 22:30:14 +00:00
										 |  |  | 	-Ideps/libsodium/src/libsodium/include \
 | 
					
						
							| 
									
										
										
										
											2022-07-09 14:50:27 +00:00
										 |  |  | 	-Ideps/valgrind \
 | 
					
						
							| 
									
										
										
										
											2021-01-04 01:58:50 +00:00
										 |  |  | 	-Werror | 
					
						
							| 
									
										
										
										
											2021-01-02 18:10:00 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-26 00:47:36 +00:00
										 |  |  | BASE64C_SOURCES := deps/base64c/src/base64c.c | 
					
						
							|  |  |  | BASE64C_OBJS := $(call get_objs,BASE64C_SOURCES) | 
					
						
							| 
									
										
										
										
											2021-01-02 18:10:00 +00:00
										 |  |  | $(BASE64C_OBJS): CFLAGS += \ | 
					
						
							|  |  |  | 	-Wno-sign-compare | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-26 00:47:36 +00:00
										 |  |  | BLOWFISH_SOURCES := \
 | 
					
						
							| 
									
										
										
										
											2021-01-02 18:10:00 +00:00
										 |  |  | 	deps/crypt_blowfish/crypt_blowfish.c \
 | 
					
						
							|  |  |  | 	deps/crypt_blowfish/crypt_gensalt.c \
 | 
					
						
							|  |  |  | 	deps/crypt_blowfish/wrapper.c | 
					
						
							| 
									
										
										
										
											2022-05-26 00:47:36 +00:00
										 |  |  | BLOWFISH_SOURCES_win = \
 | 
					
						
							| 
									
										
										
										
											2022-05-16 22:30:14 +00:00
										 |  |  | 	deps/crypt_blowfish/x86.S | 
					
						
							| 
									
										
										
										
											2022-05-26 00:47:36 +00:00
										 |  |  | BLOWFISH_OBJS := $(call get_objs,BLOWFISH_SOURCES) | 
					
						
							| 
									
										
										
										
											2021-01-02 18:10:00 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-26 00:47:36 +00:00
										 |  |  | UV_SOURCES := \
 | 
					
						
							| 
									
										
										
										
											2021-01-02 18:10:00 +00:00
										 |  |  | 	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 \
 | 
					
						
							| 
									
										
										
										
											2022-05-16 22:30:14 +00:00
										 |  |  | 	deps/libuv/src/uv-common.c \
 | 
					
						
							|  |  |  | 	deps/libuv/src/uv-data-getter-setters.c \
 | 
					
						
							|  |  |  | 	deps/libuv/src/version.c | 
					
						
							| 
									
										
										
										
											2022-05-26 00:47:36 +00:00
										 |  |  | UV_SOURCES_unix := \
 | 
					
						
							| 
									
										
										
										
											2021-01-02 18:10:00 +00:00
										 |  |  | 	deps/libuv/src/unix/async.c \
 | 
					
						
							|  |  |  | 	deps/libuv/src/unix/core.c \
 | 
					
						
							|  |  |  | 	deps/libuv/src/unix/dl.c \
 | 
					
						
							| 
									
										
										
										
											2021-07-27 22:08:18 +00:00
										 |  |  | 	deps/libuv/src/unix/epoll.c \
 | 
					
						
							| 
									
										
										
										
											2021-01-02 18:10:00 +00:00
										 |  |  | 	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 \
 | 
					
						
							| 
									
										
										
										
											2022-05-16 22:30:14 +00:00
										 |  |  | 	deps/libuv/src/unix/udp.c | 
					
						
							| 
									
										
										
										
											2022-05-26 00:47:36 +00:00
										 |  |  | UV_SOURCES_win := \
 | 
					
						
							| 
									
										
										
										
											2022-05-16 22:30:14 +00:00
										 |  |  | 	deps/libuv/src/win/async.c \
 | 
					
						
							|  |  |  | 	deps/libuv/src/win/core.c \
 | 
					
						
							|  |  |  | 	deps/libuv/src/win/detect-wakeup.c \
 | 
					
						
							|  |  |  | 	deps/libuv/src/win/dl.c \
 | 
					
						
							|  |  |  | 	deps/libuv/src/win/error.c \
 | 
					
						
							|  |  |  | 	deps/libuv/src/win/fs-event.c \
 | 
					
						
							|  |  |  | 	deps/libuv/src/win/fs.c \
 | 
					
						
							|  |  |  | 	deps/libuv/src/win/getaddrinfo.c \
 | 
					
						
							|  |  |  | 	deps/libuv/src/win/getnameinfo.c \
 | 
					
						
							|  |  |  | 	deps/libuv/src/win/handle.c \
 | 
					
						
							|  |  |  | 	deps/libuv/src/win/loop-watcher.c \
 | 
					
						
							|  |  |  | 	deps/libuv/src/win/pipe.c \
 | 
					
						
							|  |  |  | 	deps/libuv/src/win/poll.c \
 | 
					
						
							|  |  |  | 	deps/libuv/src/win/process-stdio.c \
 | 
					
						
							|  |  |  | 	deps/libuv/src/win/process.c \
 | 
					
						
							|  |  |  | 	deps/libuv/src/win/signal.c \
 | 
					
						
							|  |  |  | 	deps/libuv/src/win/snprintf.c \
 | 
					
						
							|  |  |  | 	deps/libuv/src/win/stream.c \
 | 
					
						
							|  |  |  | 	deps/libuv/src/win/tcp.c \
 | 
					
						
							|  |  |  | 	deps/libuv/src/win/thread.c \
 | 
					
						
							|  |  |  | 	deps/libuv/src/win/tty.c \
 | 
					
						
							|  |  |  | 	deps/libuv/src/win/udp.c \
 | 
					
						
							|  |  |  | 	deps/libuv/src/win/util.c \
 | 
					
						
							|  |  |  | 	deps/libuv/src/win/winapi.c \
 | 
					
						
							|  |  |  | 	deps/libuv/src/win/winsock.c | 
					
						
							| 
									
										
										
										
											2022-05-26 00:47:36 +00:00
										 |  |  | UV_OBJS := $(call get_objs,UV_SOURCES) | 
					
						
							| 
									
										
										
										
											2021-01-02 18:10:00 +00:00
										 |  |  | $(UV_OBJS): CFLAGS += \ | 
					
						
							|  |  |  | 	-Ideps/libuv/include \
 | 
					
						
							|  |  |  | 	-Ideps/libuv/src \
 | 
					
						
							|  |  |  | 	-Wno-unused-but-set-variable \
 | 
					
						
							|  |  |  | 	-Wno-incompatible-pointer-types \
 | 
					
						
							|  |  |  | 	-Wno-sign-compare \
 | 
					
						
							| 
									
										
										
										
											2022-06-04 17:22:55 +00:00
										 |  |  | 	-Wno-maybe-uninitialized \
 | 
					
						
							|  |  |  | 	-Wno-unused-variable \
 | 
					
						
							| 
									
										
										
										
											2021-01-02 18:10:00 +00:00
										 |  |  | 	-D_GNU_SOURCE \
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-26 00:47:36 +00:00
										 |  |  | SODIUM_SOURCES := \
 | 
					
						
							| 
									
										
										
										
											2022-03-08 03:42:47 +00:00
										 |  |  | 	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 \
 | 
					
						
							| 
									
										
										
										
											2022-05-30 17:24:42 +00:00
										 |  |  | 	deps/libsodium/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-ref.c \
 | 
					
						
							|  |  |  | 	deps/libsodium/src/libsodium/crypto_generichash/blake2b/ref/blake2b-ref.c \
 | 
					
						
							| 
									
										
										
										
											2022-05-16 22:30:14 +00:00
										 |  |  | 	deps/libsodium/src/libsodium/crypto_generichash/blake2b/ref/generichash_blake2b.c \
 | 
					
						
							| 
									
										
										
										
											2022-03-08 03:42:47 +00:00
										 |  |  | 	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 \
 | 
					
						
							| 
									
										
										
										
											2022-05-16 22:30:14 +00:00
										 |  |  | 	deps/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-core.c \
 | 
					
						
							|  |  |  | 	deps/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-fill-block-ref.c \
 | 
					
						
							|  |  |  | 	deps/libsodium/src/libsodium/crypto_pwhash/argon2/blake2b-long.c \
 | 
					
						
							| 
									
										
										
										
											2022-03-08 03:42:47 +00:00
										 |  |  | 	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 \
 | 
					
						
							| 
									
										
										
										
											2022-05-30 17:24:42 +00:00
										 |  |  | 	deps/libsodium/src/libsodium/crypto_secretbox/xsalsa20poly1305/secretbox_xsalsa20poly1305.c \
 | 
					
						
							| 
									
										
										
										
											2022-03-08 03:42:47 +00:00
										 |  |  | 	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 \
 | 
					
						
							| 
									
										
										
										
											2022-05-30 17:24:42 +00:00
										 |  |  | 	deps/libsodium/src/libsodium/crypto_sign/ed25519/sign_ed25519.c \
 | 
					
						
							|  |  |  | 	deps/libsodium/src/libsodium/crypto_stream/chacha20/ref/chacha20_ref.c \
 | 
					
						
							|  |  |  | 	deps/libsodium/src/libsodium/crypto_stream/chacha20/stream_chacha20.c \
 | 
					
						
							| 
									
										
										
										
											2022-03-08 03:42:47 +00:00
										 |  |  | 	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 \
 | 
					
						
							| 
									
										
										
										
											2022-05-16 22:30:14 +00:00
										 |  |  | 	deps/libsodium/src/libsodium/sodium/runtime.c \
 | 
					
						
							| 
									
										
										
										
											2022-03-08 03:42:47 +00:00
										 |  |  | 	deps/libsodium/src/libsodium/sodium/utils.c | 
					
						
							| 
									
										
										
										
											2022-05-26 00:47:36 +00:00
										 |  |  | SODIUM_OBJS := $(call get_objs,SODIUM_SOURCES) | 
					
						
							| 
									
										
										
										
											2022-03-08 03:42:47 +00:00
										 |  |  | $(SODIUM_OBJS): CFLAGS += \ | 
					
						
							|  |  |  | 	-DCONFIGURED=1 \
 | 
					
						
							|  |  |  | 	-DMINIMAL=1 \
 | 
					
						
							|  |  |  | 	-Wno-unused-function \
 | 
					
						
							|  |  |  | 	-Wno-unused-variable \
 | 
					
						
							| 
									
										
										
										
											2022-06-04 17:22:55 +00:00
										 |  |  | 	-Wno-type-limits \
 | 
					
						
							|  |  |  | 	-Wno-unknown-pragmas \
 | 
					
						
							| 
									
										
										
										
											2022-03-08 03:42:47 +00:00
										 |  |  | 	-Ideps/libsodium/src/libsodium/include/sodium | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-26 00:47:36 +00:00
										 |  |  | SQLITE_SOURCES := deps/sqlite/sqlite3.c | 
					
						
							|  |  |  | SQLITE_OBJS := $(call get_objs,SQLITE_SOURCES) | 
					
						
							| 
									
										
										
										
											2021-01-02 18:10:00 +00:00
										 |  |  | $(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 \
 | 
					
						
							| 
									
										
										
										
											2021-01-02 19:27:41 +00:00
										 |  |  | 	-DSQLITE_SECURE_DELETE \
 | 
					
						
							| 
									
										
										
										
											2022-06-04 17:22:55 +00:00
										 |  |  | 	-Wno-implicit-fallthrough \
 | 
					
						
							|  |  |  | 	-Wno-unused-but-set-variable | 
					
						
							| 
									
										
										
										
											2021-01-02 18:10:00 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-26 00:47:36 +00:00
										 |  |  | XOPT_SOURCES := deps/xopt/xopt.c | 
					
						
							|  |  |  | XOPT_OBJS := $(call get_objs,XOPT_SOURCES) | 
					
						
							| 
									
										
										
										
											2022-05-30 17:24:42 +00:00
										 |  |  | $(filter $(BUILD_DIR)/win%,$(XOPT_OBJS)): CFLAGS += \ | 
					
						
							| 
									
										
										
										
											2022-05-16 22:30:14 +00:00
										 |  |  | 	-DHAVE_SNPRINTF \
 | 
					
						
							|  |  |  | 	-DHAVE_VSNPRINTF \
 | 
					
						
							|  |  |  | 	-DHAVE_VASNPRINTF \
 | 
					
						
							|  |  |  | 	-DHAVE_VASPRINTF \
 | 
					
						
							|  |  |  | 	-Dvsnprintf=rpl_vsnprintf | 
					
						
							| 
									
										
										
										
											2021-01-02 18:10:00 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-26 00:47:36 +00:00
										 |  |  | QUICKJS_SOURCES := \
 | 
					
						
							| 
									
										
										
										
											2021-01-02 18:10:00 +00:00
										 |  |  | 	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 | 
					
						
							| 
									
										
										
										
											2022-05-26 00:47:36 +00:00
										 |  |  | QUICKJS_OBJS := $(call get_objs,QUICKJS_SOURCES) | 
					
						
							| 
									
										
										
										
											2021-01-02 18:10:00 +00:00
										 |  |  | $(QUICKJS_OBJS): CFLAGS += \ | 
					
						
							|  |  |  | 	-DCONFIG_VERSION=\"$(shell cat deps/quickjs/VERSION)\" \
 | 
					
						
							|  |  |  | 	-DDUMP_LEAKS \
 | 
					
						
							|  |  |  | 	-D_GNU_SOURCE \
 | 
					
						
							|  |  |  | 	-Wno-sign-compare \
 | 
					
						
							|  |  |  | 	-Wno-implicit-fallthrough \
 | 
					
						
							|  |  |  | 	-Wno-unused-variable \
 | 
					
						
							| 
									
										
										
										
											2021-10-03 22:14:06 +00:00
										 |  |  | 	-Wno-unused-but-set-variable \
 | 
					
						
							|  |  |  | 	-Wno-enum-conversion | 
					
						
							| 
									
										
										
										
											2021-01-02 18:10:00 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-03 22:14:06 +00:00
										 |  |  | LDFLAGS += \
 | 
					
						
							| 
									
										
										
										
											2021-01-02 18:10:00 +00:00
										 |  |  | 	-pthread \
 | 
					
						
							| 
									
										
										
										
											2022-05-16 22:30:14 +00:00
										 |  |  | 	-lm | 
					
						
							| 
									
										
										
										
											2022-05-30 17:24:42 +00:00
										 |  |  | debug release: LDFLAGS += \ | 
					
						
							| 
									
										
										
										
											2022-05-16 22:30:14 +00:00
										 |  |  | 	-ldl \
 | 
					
						
							|  |  |  | 	-lssl \
 | 
					
						
							|  |  |  | 	-lcrypto | 
					
						
							| 
									
										
										
										
											2022-05-30 17:24:42 +00:00
										 |  |  | windebug winrelease: LDFLAGS += \ | 
					
						
							| 
									
										
										
										
											2022-05-16 22:30:14 +00:00
										 |  |  | 	-lwsock32 \
 | 
					
						
							|  |  |  | 	-lws2_32 \
 | 
					
						
							|  |  |  | 	-lkernel32 \
 | 
					
						
							|  |  |  | 	-liphlpapi \
 | 
					
						
							|  |  |  | 	-luserenv | 
					
						
							| 
									
										
										
										
											2021-01-02 18:10:00 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-26 00:47:36 +00:00
										 |  |  | unix: debug release | 
					
						
							|  |  |  | win: windebug winrelease | 
					
						
							|  |  |  | all: $(BUILD_TYPES) | 
					
						
							| 
									
										
										
										
											2022-05-30 17:24:42 +00:00
										 |  |  | .PHONY: all win unix | 
					
						
							| 
									
										
										
										
											2021-10-03 22:14:06 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-26 00:47:36 +00:00
										 |  |  | ALL_APP_OBJS := \
 | 
					
						
							|  |  |  | 	$(APP_OBJS) \
 | 
					
						
							|  |  |  | 	$(BASE64C_OBJS) \
 | 
					
						
							|  |  |  | 	$(BLOWFISH_OBJS) \
 | 
					
						
							|  |  |  | 	$(QUICKJS_OBJS) \
 | 
					
						
							|  |  |  | 	$(SODIUM_OBJS) \
 | 
					
						
							|  |  |  | 	$(SQLITE_OBJS) \
 | 
					
						
							|  |  |  | 	$(UV_OBJS) \
 | 
					
						
							|  |  |  | 	$(XOPT_OBJS) | 
					
						
							| 
									
										
										
										
											2021-01-02 18:10:00 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | DEPS = $(ALL_APP_OBJS:.o=.d) | 
					
						
							|  |  |  | -include $(DEPS) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-30 17:24:42 +00:00
										 |  |  | define build_rules | 
					
						
							|  |  |  | $(1): $(BUILD_DIR)/$(1)/$(PROJECT)$(if $(filter win%,$(1)),.exe) | 
					
						
							|  |  |  | .PHONY: $(1) | 
					
						
							| 
									
										
										
										
											2021-01-02 18:10:00 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-30 17:24:42 +00:00
										 |  |  | $(BUILD_DIR)/$(1)/$(PROJECT)$(if $(filter win%,$(1)),.exe): $(filter $(BUILD_DIR)/$(1)/%,$(ALL_APP_OBJS)) | 
					
						
							|  |  |  | 	@echo [link] $$@ | 
					
						
							|  |  |  | 	@$$(CC) -o $$@ $$^ $$(LDFLAGS) | 
					
						
							| 
									
										
										
										
											2022-05-26 00:47:36 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-30 17:24:42 +00:00
										 |  |  | $(BUILD_DIR)/$(1)/%.o: %.c | 
					
						
							|  |  |  | 	@mkdir -p $$(dir $$@) | 
					
						
							|  |  |  | 	@echo [c] $$@ | 
					
						
							|  |  |  | 	@$$(CC) $$(CFLAGS) -c $$< -o $$@ | 
					
						
							| 
									
										
										
										
											2022-05-26 00:47:36 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-30 17:24:42 +00:00
										 |  |  | $(BUILD_DIR)/$(1)/%.o: %.S | 
					
						
							|  |  |  | 	@mkdir -p $$(dir $$@) | 
					
						
							|  |  |  | 	@echo [as] $$@ | 
					
						
							|  |  |  | 	@$$(AS) -c $$< -o $$@ | 
					
						
							|  |  |  | endef | 
					
						
							| 
									
										
										
										
											2022-05-16 22:30:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-30 17:24:42 +00:00
										 |  |  | $(foreach build_type,$(BUILD_TYPES),$(eval $(call build_rules,$(build_type)))) | 
					
						
							| 
									
										
										
										
											2022-05-16 22:30:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-02 18:10:00 +00:00
										 |  |  | clean: | 
					
						
							|  |  |  | 	rm -rf $(BUILD_DIR) | 
					
						
							|  |  |  | .PHONY: clean |