.ONESHELL: .DELETE_ON_ERROR: MAKEFLAGS += --warn-undefined-variables MAKEFLAGS += --no-builtin-rules VERSION_CODE := 28 VERSION_NUMBER := 0.0.24-wip VERSION_NAME := Honey bunches of boats. SQLITE_URL := https://www.sqlite.org/2024/sqlite-amalgamation-3470000.zip BUNDLETOOL_URL := https://github.com/google/bundletool/releases/download/1.17.0/bundletool-all-1.17.0.jar APPIMAGETOOL_URL := https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage APPIMAGETOOL_MD5 := e989fadfc4d685fd3d6aeeb9b525d74d out/appimagetool PROJECT = tildefriends BUILD_DIR ?= out UNAME_S := $(shell uname -s) UNAME_M := $(shell uname -m) ANDROID_SDK ?= ~/Android/Sdk BUNDLETOOL = out/bundletool.jar HAVE_WIN := 0 export SOURCE_DATE_EPOCH=1 export TZ=UTC ifeq ($(UNAME_S),Darwin) BUILD_TYPES := macosdebug macosrelease iosdebug iosrelease iossimdebug iossimrelease else ifeq ($(UNAME_S),Linux) BUILD_TYPES := debug release HAVE_ANDROID = $(if $(shell which $(ANDROID_SDK)/platform-tools/adb),1,0) HAVE_LINUX_IOS = $(if $(shell which deps/ios_toolchain/target/bin deps/ios_toolchain/target/bin/arm-apple-darwin11-clang),1,0) HAVE_WIN = $(if $(shell which x86_64-w64-mingw32-gcc-win32),1,0) else ifeq ($(UNAME_S),Haiku) BUILD_TYPES := debug release CFLAGS += -Dstatic_assert=_Static_assert LDFLAGS += \ -lbsd \ -lnetwork \ -Wno-stringop-overflow else ifeq ($(UNAME_S),OpenBSD) BUILD_TYPES := debug release CFLAGS += \ -Wno-unknown-warning-option LDFLAGS += \ -lexecinfo \ -lc++abi HAVE_ANDROID := 0 HAVE_LINUX_IOS := 0 else $(error Unexpected host platform $(UNAME_S).) endif CFLAGS += \ -std=gnu11 \ -Wall \ -Wextra \ -Wno-unused-parameter \ -Wno-unknown-warning-option \ -MMD \ -MP \ -ffunction-sections \ -fdata-sections \ -fno-exceptions \ -g LDFLAGS += \ -Wno-attributes \ -Wno-aggressive-loop-optimizations \ -flto=auto ANDROID_MIN_SDK_VERSION := 24 ANDROID_TARGET_SDK_VERSION := 34 ANDROID_BUILD_TOOLS := $(ANDROID_SDK)/build-tools/34.0.0 ANDROID_PLATFORM := $(ANDROID_SDK)/platforms/android-$(ANDROID_TARGET_SDK_VERSION) ANDROID_NDK ?= $(ANDROID_SDK)/ndk/26.3.11579264 ANDROID_ARMV7A_TARGETS := \ out/androiddebug-armv7a/tildefriends \ out/androidrelease-armv7a/tildefriends ANDROID_ARM64_TARGETS := \ out/androiddebug/tildefriends \ out/androidrelease/tildefriends ANDROID_X86_TARGETS := \ out/androiddebug-x86/tildefriends \ out/androidrelease-x86/tildefriends ANDROID_X86_64_TARGETS := \ out/androiddebug-x86_64/tildefriends \ out/androidrelease-x86_64/tildefriends ANDROID_TARGETS := \ $(ANDROID_X86_TARGETS) \ $(ANDROID_X86_64_TARGETS) \ $(ANDROID_ARMV7A_TARGETS) \ $(ANDROID_ARM64_TARGETS) ifeq ($(HAVE_ANDROID),1) BUILD_TYPES += \ androiddebug \ androidrelease \ androiddebug-armv7a \ androidrelease-armv7a \ androiddebug-x86 \ androidrelease-x86 \ androiddebug-x86_64 \ androidrelease-x86_64 all: out/TildeFriends-arm-debug.apk out/TildeFriends-arm-release.apk out/TildeFriends-x86-debug.apk out/TildeFriends-x86-release.apk out/TildeFriends-release.fdroid.apk endif WINDOWS_TARGETS := \ out/windebug/tildefriends.exe \ out/winrelease/tildefriends.exe ifeq ($(HAVE_WIN),1) BUILD_TYPES += windebug winrelease endif LINUX_TARGETS := \ out/debug/tildefriends \ out/release/tildefriends MACOS_TARGETS := \ out/macosdebug/tildefriends \ out/macosrelease/tildefriends IOS_TARGETS := \ out/iosdebug/tildefriends \ out/iosrelease/tildefriends IOSSIM_TARGETS := \ out/iossimdebug/tildefriends \ out/iossimrelease/tildefriends IOS_APPS = \ out/tildefriends-iosdebug.app/tildefriends \ out/tildefriends-iosrelease.app/tildefriends ifeq ($(HAVE_LINUX_IOS),1) BUILD_TYPES += iosdebug iosrelease all: $(IOS_APPS) endif ifeq ($(UNAME_S),Darwin) all: $(IOS_APPS) \ out/tildefriends-iossimdebug.app/tildefriends \ out/tildefriends-iossimrelease.app/tildefriends endif DEBUG_TARGETS := \ out/debug/tildefriends \ out/windebug/tildefriends.exe \ out/iosdebug/tildefriends \ out/iossimdebug/tildefriends \ out/macosdebug/tildefriends \ out/androiddebug/tildefriends \ out/androiddebug-armv7a/tildefriends \ out/androiddebug-x86_64/tildefriends \ out/androiddebug-x86/tildefriends RELEASE_TARGETS := \ out/release/tildefriends \ out/winrelease/tildefriends.exe \ out/iosrelease/tildefriends \ out/iossimrelease/tildefriends \ out/macosrelease/tildefriends \ out/androidrelease/tildefriends \ out/androidrelease-armv7a/tildefriends \ out/androidrelease-x86_64/tildefriends \ out/androidrelease-x86/tildefriends ALL_TARGETS = $(DEBUG_TARGETS) $(RELEASE_TARGETS) ANDROID_RELEASE_TARGETS := $(filter-out $(DEBUG_TARGETS),$(ANDROID_TARGETS)) NONANDROID_RELEASE_TARGETS := $(filter-out $(ANDROID_ARM64_TARGETS),$(RELEASE_TARGETS)) NONANDROID_TARGETS := $(filter-out $(ANDROID_TARGETS),$(ALL_TARGETS)) NONMACOS_TARGETS := $(filter-out $(MACOS_TARGETS) $(IOS_TARGETS) $(IOSSIM_TARGETS),$(ALL_TARGETS)) DEADSTRIP_TARGETS := $(filter-out $(ANDROID_TARGETS),$(NONMACOS_TARGETS)) ifneq ($(UNAME_S),OpenBSD) $(NONMACOS_TARGETS): LDFLAGS += -static-libgcc endif $(NONANDROID_TARGETS): CFLAGS += -fno-omit-frame-pointer $(filter-out $(WINDOWS_TARGETS),$(ALL_TARGETS)): LDFLAGS += -rdynamic $(ANDROID_TARGETS): CFLAGS += \ --sysroot $(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/sysroot \ -fPIC \ -fdebug-compilation-dir . \ -fomit-frame-pointer \ -fno-asynchronous-unwind-tables \ -funwind-tables \ -Wno-unknown-warning-option $(ANDROID_TARGETS): LDFLAGS += --sysroot $(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/sysroot -fPIC $(DEBUG_TARGETS): CFLAGS += -DDEBUG -Og $(RELEASE_TARGETS): CFLAGS += \ -DNDEBUG \ -flto $(NONANDROID_RELEASE_TARGETS): CFLAGS += -O3 $(ANDROID_RELEASE_TARGETS): CFLAGS += -Oz $(WINDOWS_TARGETS): CC = x86_64-w64-mingw32-gcc-win32 $(WINDOWS_TARGETS): AS = $(CC) $(WINDOWS_TARGETS): CFLAGS += \ -D_WIN32_WINNT=0x0A00 \ -DWINVER=0x0A00 \ -DNTDDI_VERSION=NTDDI_WIN10 \ -Ideps/openssl/mingw64/usr/local/include $(WINDOWS_TARGETS): LDFLAGS += \ -static \ -lm \ -Ldeps/openssl/mingw64/usr/local/lib ifeq ($(UNAME_S),Darwin) $(MACOS_TARGETS): CC = xcrun clang $(IOS_TARGETS): IOS_SYSROOT := $(shell xcrun --sdk iphoneos --show-sdk-path) $(IOS_TARGETS): CC = xcrun --sdk iphoneos clang -isysroot $(IOS_SYSROOT) -arch arm64 $(IOSSIM_TARGETS): IOSSIM_SYSROOT := $(shell xcrun --sdk iphonesimulator --show-sdk-path) $(IOSSIM_TARGETS): CC = xcrun --sdk iphonesimulator clang -isysroot $(IOSSIM_SYSROOT) -arch x86_64 else ifeq ($(UNAME_S),Linux) $(IOS_TARGETS): IOS_SYSROOT := deps/iPhoneOS17.0.sdk $(IOS_TARGETS): CC = PATH=$$PATH:deps/ios_toolchain/target/bin deps/ios_toolchain/target/bin/arm-apple-darwin11-clang endif $(ANDROID_X86_64_TARGETS): ANDROID_NDK_TARGET_TRIPLE := x86_64-linux-android $(ANDROID_X86_TARGETS): ANDROID_NDK_TARGET_TRIPLE := i686-linux-android $(ANDROID_ARMV7A_TARGETS): ANDROID_NDK_TARGET_TRIPLE := armv7a-linux-androideabi $(ANDROID_ARM64_TARGETS): ANDROID_NDK_TARGET_TRIPLE := aarch64-linux-android $(ANDROID_TARGETS): CC = $(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/$(ANDROID_NDK_TARGET_TRIPLE)$(ANDROID_MIN_SDK_VERSION)-clang $(ANDROID_TARGETS): AS = $(CC) $(ANDROID_TARGETS): CFLAGS += \ -target $(ANDROID_NDK_TARGET_TRIPLE)$(ANDROID_MIN_SDK_VERSION) \ -Wno-unknown-warning-option $(ANDROID_ARMV7A_TARGETS): CFLAGS += -Ideps/openssl/android/armeabi-v7a/usr/local/include $(ANDROID_ARMV7A_TARGETS): LDFLAGS += -Ldeps/openssl/android/armeabi-v7a/usr/local/lib $(ANDROID_ARM64_TARGETS): CFLAGS += -Ideps/openssl/android/arm64-v8a/usr/local/include $(ANDROID_ARM64_TARGETS): LDFLAGS += -Ldeps/openssl/android/arm64-v8a/usr/local/lib $(ANDROID_X86_TARGETS): CFLAGS += -Ideps/openssl/android/x86/usr/local/include $(ANDROID_X86_TARGETS): CFLAGS += -Wno-atomic-alignment $(ANDROID_X86_TARGETS): LDFLAGS += -Ldeps/openssl/android/x86/usr/local/lib $(ANDROID_X86_64_TARGETS): CFLAGS += -Ideps/openssl/android/x86_64/usr/local/include $(ANDROID_X86_64_TARGETS): LDFLAGS += -Ldeps/openssl/android/x86_64/usr/local/lib $(NONMACOS_TARGETS): CFLAGS += -Wno-cast-function-type $(DEADSTRIP_TARGETS): LDFLAGS += -Wl,--gc-sections $(IOS_TARGETS): CFLAGS += -miphoneos-version-min=9.0 -Ideps/openssl/ios/ios64-xcrun/usr/local/include $(IOS_TARGETS): LDFLAGS += -miphoneos-version-min=9.0 -Ldeps/openssl/ios/ios64-xcrun/usr/local/lib $(IOSSIM_TARGETS): CFLAGS += -Ideps/openssl/ios/iossimulator-xcrun/usr/local/include $(IOSSIM_TARGETS): LDFLAGS += -Ldeps/openssl/ios/iossimulator-xcrun/usr/local/lib ifeq ($(UNAME_M),x86_64) ifeq ($(UNAME_S),Linux) all: appimage endif ifneq ($(UNAME_S),Haiku) out/debug/tildefriends: CFLAGS += -fsanitize=address -fsanitize=undefined -fno-common out/debug/tildefriends: LDFLAGS += -fsanitize=address -fsanitize=undefined endif endif ifeq ($(UNAME_M),aarch64) out/debug/tildefriends: CFLAGS += -fsanitize=address -fsanitize=undefined -fno-common out/debug/tildefriends: LDFLAGS += -fsanitize=address -fsanitize=undefined endif get_objs = \ $(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))))) \ $(foreach build_type,androiddebug androidrelease androiddebug-x86 androidrelease-x86 androiddebug-x86_64 androidrelease-x86_64 androiddebug-armv7a androiddebug-armv7a,$(addprefix $(BUILD_DIR)/$(build_type)/,$(addsuffix .o,$(basename $(value $(1)_android))))) \ $(foreach build_type,androiddebug androidrelease androiddebug-x86 androidrelease-x86 androiddebug-x86_64 androidrelease-x86_64 androiddebug-armv7a androidrelease-armv7a,$(addprefix $(BUILD_DIR)/$(build_type)/,$(addsuffix .o,$(basename $(value $(1)_unix))))) \ $(foreach build_type,macosdebug macosrelease iosdebug iosrelease iossimdebug iossimrelease,$(addprefix $(BUILD_DIR)/$(build_type)/,$(addsuffix .o,$(basename $(value $(1)_macos))))) \ $(foreach build_type,iosdebug iosrelease iossimdebug iossimrelease,$(addprefix $(BUILD_DIR)/$(build_type)/,$(addsuffix .o,$(basename $(value $(1)_ios))))) \ $(foreach build_type,androiddebug-x86 androidrelease-x86,$(addprefix $(BUILD_DIR)/$(build_type)/,$(addsuffix .o,$(basename $(value $(1)_x86))))) APP_SOURCES := $(wildcard src/*.c) APP_SOURCES_ios := $(wildcard src/*.m) APP_OBJS := $(call get_objs,APP_SOURCES) $(APP_OBJS): CFLAGS += \ -Ideps/base64c/include \ -Ideps/c-ares/include \ -Ideps/c-ares_config \ -Ideps/crypt_blowfish \ -Ideps/libbacktrace \ -Ideps/libsodium \ -Ideps/libsodium/src/libsodium/include \ -Ideps/libuv/include \ -Ideps/zlib \ -Ideps/zlib/contrib/minizip \ -Ideps/picohttpparser \ -Ideps/quickjs \ -Ideps/sqlite \ -Ideps/valgrind \ -Wdouble-promotion \ -Werror ifeq ($(UNAME_M),x86_64) $(filter-out $(BUILD_DIR)/android% $(BUILD_DIR)/macos% $(BUILD_DIR)/ios%,$(APP_OBJS)): CFLAGS += \ -fanalyzer endif ARES_SOURCES := \ deps/c-ares/src/lib/ares_addrinfo2hostent.c \ deps/c-ares/src/lib/ares_addrinfo_localhost.c \ deps/c-ares/src/lib/ares_android.c \ deps/c-ares/src/lib/ares_cancel.c \ deps/c-ares/src/lib/ares_close_sockets.c \ deps/c-ares/src/lib/ares_conn.c \ deps/c-ares/src/lib/ares_cookie.c \ deps/c-ares/src/lib/ares_data.c \ deps/c-ares/src/lib/ares_destroy.c \ deps/c-ares/src/lib/ares_free_hostent.c \ deps/c-ares/src/lib/ares_free_string.c \ deps/c-ares/src/lib/ares_freeaddrinfo.c \ deps/c-ares/src/lib/ares_getaddrinfo.c \ deps/c-ares/src/lib/ares_getenv.c \ deps/c-ares/src/lib/ares_gethostbyaddr.c \ deps/c-ares/src/lib/ares_gethostbyname.c \ deps/c-ares/src/lib/ares_getnameinfo.c \ deps/c-ares/src/lib/ares_hosts_file.c \ deps/c-ares/src/lib/ares_init.c \ deps/c-ares/src/lib/ares_library_init.c \ deps/c-ares/src/lib/ares_metrics.c \ deps/c-ares/src/lib/ares_options.c \ deps/c-ares/src/lib/ares_parse_into_addrinfo.c \ deps/c-ares/src/lib/ares_process.c \ deps/c-ares/src/lib/ares_qcache.c \ deps/c-ares/src/lib/ares_query.c \ deps/c-ares/src/lib/ares_search.c \ deps/c-ares/src/lib/ares_send.c \ deps/c-ares/src/lib/ares_set_socket_functions.c \ deps/c-ares/src/lib/ares_socket.c \ deps/c-ares/src/lib/ares_sortaddrinfo.c \ deps/c-ares/src/lib/ares_strerror.c \ deps/c-ares/src/lib/ares_sysconfig.c \ deps/c-ares/src/lib/ares_sysconfig_files.c \ deps/c-ares/src/lib/ares_sysconfig_mac.c \ deps/c-ares/src/lib/ares_sysconfig_win.c \ deps/c-ares/src/lib/ares_update_servers.c \ deps/c-ares/src/lib/ares_version.c \ deps/c-ares/src/lib/dsa/ares_array.c \ deps/c-ares/src/lib/dsa/ares_htable.c \ deps/c-ares/src/lib/dsa/ares_htable_asvp.c \ deps/c-ares/src/lib/dsa/ares_htable_dict.c \ deps/c-ares/src/lib/dsa/ares_htable_strvp.c \ deps/c-ares/src/lib/dsa/ares_htable_szvp.c \ deps/c-ares/src/lib/dsa/ares_htable_vpvp.c \ deps/c-ares/src/lib/dsa/ares_llist.c \ deps/c-ares/src/lib/dsa/ares_slist.c \ deps/c-ares/src/lib/event/ares_event_configchg.c \ deps/c-ares/src/lib/event/ares_event_epoll.c \ deps/c-ares/src/lib/event/ares_event_kqueue.c \ deps/c-ares/src/lib/event/ares_event_poll.c \ deps/c-ares/src/lib/event/ares_event_select.c \ deps/c-ares/src/lib/event/ares_event_thread.c \ deps/c-ares/src/lib/event/ares_event_wake_pipe.c \ deps/c-ares/src/lib/event/ares_event_win32.c \ deps/c-ares/src/lib/inet_net_pton.c \ deps/c-ares/src/lib/inet_ntop.c \ deps/c-ares/src/lib/legacy/ares_create_query.c \ deps/c-ares/src/lib/legacy/ares_expand_name.c \ deps/c-ares/src/lib/legacy/ares_expand_string.c \ deps/c-ares/src/lib/legacy/ares_fds.c \ deps/c-ares/src/lib/legacy/ares_getsock.c \ deps/c-ares/src/lib/legacy/ares_parse_a_reply.c \ deps/c-ares/src/lib/legacy/ares_parse_aaaa_reply.c \ deps/c-ares/src/lib/legacy/ares_parse_caa_reply.c \ deps/c-ares/src/lib/legacy/ares_parse_mx_reply.c \ deps/c-ares/src/lib/legacy/ares_parse_naptr_reply.c \ deps/c-ares/src/lib/legacy/ares_parse_ns_reply.c \ deps/c-ares/src/lib/legacy/ares_parse_ptr_reply.c \ deps/c-ares/src/lib/legacy/ares_parse_soa_reply.c \ deps/c-ares/src/lib/legacy/ares_parse_srv_reply.c \ deps/c-ares/src/lib/legacy/ares_parse_txt_reply.c \ deps/c-ares/src/lib/legacy/ares_parse_uri_reply.c \ deps/c-ares/src/lib/record/ares_dns_mapping.c \ deps/c-ares/src/lib/record/ares_dns_multistring.c \ deps/c-ares/src/lib/record/ares_dns_name.c \ deps/c-ares/src/lib/record/ares_dns_parse.c \ deps/c-ares/src/lib/record/ares_dns_record.c \ deps/c-ares/src/lib/record/ares_dns_write.c \ deps/c-ares/src/lib/str/ares_buf.c \ deps/c-ares/src/lib/str/ares_str.c \ deps/c-ares/src/lib/str/ares_strsplit.c \ deps/c-ares/src/lib/util/ares_iface_ips.c \ deps/c-ares/src/lib/util/ares_math.c \ deps/c-ares/src/lib/util/ares_rand.c \ deps/c-ares/src/lib/util/ares_threads.c \ deps/c-ares/src/lib/util/ares_timeval.c \ deps/c-ares/src/lib/util/ares_uri.c \ deps/c-ares/src/lib/windows_port.c \ deps/c-ares/src/lib/ares_timeout.c ARES_OBJS := $(call get_objs,ARES_SOURCES) $(ARES_OBJS): CFLAGS += \ -Ideps/c-ares/include \ -Ideps/c-ares/src/lib \ -Ideps/c-ares/src/lib/include \ -Ideps/c-ares_config/ \ -D_GNU_SOURCE \ -Wno-unused-function \ -Wno-deprecated-declarations \ -Wno-unused-result BLOWFISH_SOURCES := \ deps/crypt_blowfish/crypt_blowfish.c \ deps/crypt_blowfish/crypt_gensalt.c \ deps/crypt_blowfish/wrapper.c BLOWFISH_SOURCES_win := \ deps/crypt_blowfish/x86.S BLOWFISH_SOURCES_x86 := \ deps/crypt_blowfish/x86.S BLOWFISH_OBJS := $(call get_objs,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/strtok.c \ deps/libuv/src/threadpool.c \ deps/libuv/src/timer.c \ deps/libuv/src/uv-common.c \ deps/libuv/src/uv-data-getter-setters.c \ deps/libuv/src/version.c UV_SOURCES_unix := \ 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/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/random-devurandom.c \ deps/libuv/src/unix/random-getrandom.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 ifeq ($(UNAME_S),Linux) UV_SOURCES_unix += \ deps/libuv/src/unix/linux.c \ deps/libuv/src/unix/procfs-exepath.c \ deps/libuv/src/unix/proctitle.c \ deps/libuv/src/unix/random-sysctl-linux.c else ifeq ($(UNAME_S),Haiku) UV_SOURCES_unix += \ deps/libuv/src/unix/bsd-ifaddrs.c \ deps/libuv/src/unix/haiku.c \ deps/libuv/src/unix/no-fsevents.c \ deps/libuv/src/unix/no-proctitle.c \ deps/libuv/src/unix/posix-hrtime.c \ deps/libuv/src/unix/posix-poll.c else ifeq ($(UNAME_S),OpenBSD) UV_SOURCES_unix += \ deps/libuv/src/unix/bsd-ifaddrs.c \ deps/libuv/src/unix/kqueue.c \ deps/libuv/src/unix/no-proctitle.c \ deps/libuv/src/unix/openbsd.c \ deps/libuv/src/unix/posix-hrtime.c \ deps/libuv/src/unix/random-getentropy.c endif UV_SOURCES_android := \ deps/libuv/src/unix/random-getentropy.c UV_SOURCES_win := \ 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 UV_SOURCES_macos := \ deps/libuv/src/unix/async.c \ deps/libuv/src/unix/bsd-ifaddrs.c \ deps/libuv/src/unix/core.c \ deps/libuv/src/unix/darwin.c \ deps/libuv/src/unix/darwin-proctitle.c \ deps/libuv/src/unix/dl.c \ deps/libuv/src/unix/fs.c \ deps/libuv/src/unix/fsevents.c \ deps/libuv/src/unix/getaddrinfo.c \ deps/libuv/src/unix/getnameinfo.c \ deps/libuv/src/unix/kqueue.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/proctitle.c \ deps/libuv/src/unix/random-devurandom.c \ deps/libuv/src/unix/random-getentropy.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 UV_OBJS := $(call get_objs,UV_SOURCES) $(UV_OBJS): CFLAGS += \ -Ideps/libuv/include \ -Ideps/libuv/src \ -Wno-dangling-pointer \ -Wno-incompatible-pointer-types \ -Wno-maybe-uninitialized \ -Wno-sign-compare \ -Wno-unknown-attributes \ -Wno-unused-but-set-parameter \ -Wno-unused-but-set-variable \ -Wno-unused-result \ -Wno-unused-variable \ -Wno-nonnull $(UV_OBJS): CFLAGS += -fno-lto $(filter out/win%,$(UV_OBJS)): \ CFLAGS += \ -Wno-cast-function-type \ -Wno-missing-braces ifeq ($(UNAME_S),Linux) $(UV_OBJS): CFLAGS += \ -D_GNU_SOURCE else ifeq ($(UNAME_S),Haiku) $(UV_OBJS): CFLAGS += \ -D_BSD_SOURCE \ -Wno-format-truncation endif SODIUM_SOURCES := \ deps/libsodium/src/libsodium/crypto_aead/aegis128l/aead_aegis128l.c \ deps/libsodium/src/libsodium/crypto_aead/aegis128l/aegis128l_soft.c \ deps/libsodium/src/libsodium/crypto_aead/aegis256/aead_aegis256.c \ deps/libsodium/src/libsodium/crypto_aead/aegis256/aegis256_soft.c \ 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_core/softaes/softaes.c \ deps/libsodium/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-ref.c \ deps/libsodium/src/libsodium/crypto_generichash/blake2b/ref/blake2b-ref.c \ deps/libsodium/src/libsodium/crypto_generichash/blake2b/ref/generichash_blake2b.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_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 \ 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/sandy2x/curve25519_sandy2x.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_secretbox/xsalsa20poly1305/secretbox_xsalsa20poly1305.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_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 \ 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/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/codecs.c \ deps/libsodium/src/libsodium/sodium/runtime.c \ deps/libsodium/src/libsodium/sodium/utils.c \ deps/libsodium/src/libsodium/sodium/version.c SODIUM_OBJS := $(call get_objs,SODIUM_SOURCES) $(SODIUM_OBJS): CFLAGS += \ -DCONFIGURED=1 \ -DMINIMAL=1 \ -DHAVE_ALLOCA \ -DHAVE_CPUID_V \ -DHAVE_GCC_MEMORY_FENCES \ -Wno-unused-function \ -Wno-unused-variable \ -Wno-type-limits \ -Wno-unknown-pragmas \ -Wno-attributes \ -Ideps/libsodium/builds/msvc \ -Ideps/libsodium/src/libsodium/include/sodium ifneq ($(UNAME_S),OpenBSD) $(filter-out $(BUILD_DIR)/win%,$(SODIUM_OBJS)): CFLAGS += \ -DHAVE_ALLOCA_H endif SQLITE_SOURCES := deps/sqlite/sqlite3.c SQLITE_OBJS := $(call get_objs,SQLITE_SOURCES) $(SQLITE_OBJS): CFLAGS += \ -DSQLITE_DBCONFIG_DEFAULT_DEFENSIVE \ -DSQLITE_DEFAULT_MEMSTATUS=0 \ -DSQLITE_DQS=0 \ -DSQLITE_ENABLE_MEMSYS5 \ -DSQLITE_ENABLE_FTS5 \ -DSQLITE_ENABLE_JSON1 \ -DSQLITE_LIKE_DOESNT_MATCH_BLOBS \ -DSQLITE_MAX_ATTACHED=1 \ -DSQLITE_MAX_COLUMN=100 \ -DSQLITE_MAX_COMPOUND_SELECT=300 \ -DSQLITE_MAX_EXPR_DEPTH=40 \ -DSQLITE_MAX_FUNCTION_ARG=8 \ -DSQLITE_MAX_LENGTH=5242880 \ -DSQLITE_MAX_LIKE_PATTERN_LENGTH=50 \ -DSQLITE_MAX_SQL_LENGTH=100000 \ -DSQLITE_MAX_TRIGGER_DEPTH=10 \ -DSQLITE_MAX_VARIABLE_NUMBER=100 \ -DSQLITE_MAX_VDBE_OP=25000 \ -DSQLITE_OMIT_DEPRECATED \ -DSQLITE_OMIT_DESERIALIZE \ -DSQLITE_OMIT_LOAD_EXTENSION \ -DSQLITE_OMIT_TCL_VARIABLE \ -DSQLITE_PRAGMA_DEFAULT_WAL_SYNCHRONOUS=1 \ -DSQLITE_SECURE_DELETE \ -DSQLITE_THREADSAFE=2 \ -DSQLITE_UNTESTABLE \ -DSQLITE_USE_ALLOCA \ -DHAVE_ISNAN \ -DHAVE_GETHOSTUUID=0 \ -Wno-implicit-fallthrough \ -Wno-unused-but-set-variable \ -Wno-unused-function \ -Wno-unused-variable QUICKJS_SOURCES := \ deps/quickjs/cutils.c \ deps/quickjs/libbf.c \ deps/quickjs/libregexp.c \ deps/quickjs/libunicode.c \ deps/quickjs/quickjs.c QUICKJS_OBJS := $(call get_objs,QUICKJS_SOURCES) $(QUICKJS_OBJS): CFLAGS += \ -DCONFIG_VERSION=\"$(shell cat deps/quickjs/VERSION)\" \ -DCONFIG_BIGNUM \ -D_GNU_SOURCE \ -Wno-enum-conversion \ -Wno-implicit-const-int-float-conversion \ -Wno-implicit-fallthrough \ -Wno-sign-compare \ -Wno-unused-but-set-variable \ -Wno-unused-variable $(NONANDROID_TARGETS): CFLAGS += -DDUMP_LEAKS ifeq ($(UNAME_S),Haiku) $(QUICKJS_OBJS): CFLAGS += "-Dmalloc_usable_size(x)=0" else ifeq ($(UNAME_S),OpenBSD) $(QUICKJS_OBJS): CFLAGS += "-Dmalloc_usable_size(x)=0" endif LIBBACKTRACE_SOURCES := \ deps/libbacktrace/atomic.c \ deps/libbacktrace/backtrace.c \ deps/libbacktrace/dwarf.c \ deps/libbacktrace/fileline.c \ deps/libbacktrace/print.c \ deps/libbacktrace/simple.c \ deps/libbacktrace/sort.c \ deps/libbacktrace/state.c LIBBACKTRACE_SOURCES_unix := \ deps/libbacktrace/elf.c \ deps/libbacktrace/mmap.c \ deps/libbacktrace/mmapio.c \ deps/libbacktrace/posix.c LIBBACKTRACE_SOURCES_win := \ deps/libbacktrace/alloc.c \ deps/libbacktrace/pecoff.c \ deps/libbacktrace/posix.c \ deps/libbacktrace/read.c LIBBACKTRACE_SOURCES_macos := \ deps/libbacktrace/dwarf.c \ deps/libbacktrace/macho.c \ deps/libbacktrace/mmap.c \ deps/libbacktrace/mmapio.c \ deps/libbacktrace/posix.c LIBBACKTRACE_OBJS := $(call get_objs,LIBBACKTRACE_SOURCES) $(LIBBACKTRACE_OBJS): CFLAGS += \ -Ideps/libbacktrace_config \ -Wno-unused-but-set-variable \ -Wno-maybe-initialized \ -Wno-unused-function \ -DBACKTRACE_ELF_SIZE=64 PICOHTTPPARSER_SOURCES := \ deps/picohttpparser/picohttpparser.c PICOHTTPPARSER_OBJS := $(call get_objs,PICOHTTPPARSER_SOURCES) MINIUNZIP_SOURCES := \ deps/zlib/contrib/minizip/unzip.c \ deps/zlib/contrib/minizip/ioapi.c \ deps/zlib/adler32.c \ deps/zlib/crc32.c \ deps/zlib/inffast.c \ deps/zlib/inflate.c \ deps/zlib/inftrees.c \ deps/zlib/zutil.c MINIUNZIP_OBJS := $(call get_objs,MINIUNZIP_SOURCES) $(MINIUNZIP_OBJS): CFLAGS += \ -Ideps/zlib \ -Wno-maybe-uninitialized LDFLAGS += \ -pthread \ -lm $(LINUX_TARGETS) $(MACOS_TARGETS) $(IOS_TARGETS) $(IOSSIM_TARGETS): LDFLAGS += \ -lssl \ -lcrypto ifneq ($(UNAME_S),Haiku) ifneq ($(UNAME_S),OpenBSD) debug release $(MACOS_TARGETS) $(IOS_TARGETS) $(IOSSIM_TARGETS): LDFLAGS += \ -ldl endif endif $(WINDOWS_TARGETS): LDFLAGS += \ -lssl \ -lcrypto \ -lcrypt32 \ -ldbghelp \ -liphlpapi \ -lkernel32 \ -lole32 \ -luserenv \ -luuid \ -lws2_32 \ -lwsock32 $(ANDROID_TARGETS): LDFLAGS += \ -target $(ANDROID_NDK_TARGET_TRIPLE)$(ANDROID_MIN_SDK_VERSION) \ -ldl \ -llog \ -lssl \ -lcrypto $(MACOS_TARGETS) $(IOS_TARGETS) $(IOSSIM_TARGETS): CFLAGS += \ -Wno-unknown-warning-option $(IOS_TARGETS) $(IOSSIM_TARGETS): LDFLAGS += \ -framework Foundation \ -framework CoreFoundation \ -framework UIKit \ -framework WebKit unix: debug release win: windebug winrelease all: $(BUILD_TYPES) .PHONY: all win unix ALL_APP_OBJS := \ $(APP_OBJS) \ $(ARES_OBJS) \ $(BLOWFISH_OBJS) \ $(LIBBACKTRACE_OBJS) \ $(MINIUNZIP_OBJS) \ $(PICOHTTPPARSER_OBJS) \ $(QUICKJS_OBJS) \ $(SODIUM_OBJS) \ $(SQLITE_OBJS) \ $(UV_OBJS) DEPS = $(ALL_APP_OBJS:.o=.d) -include $(DEPS) define build_rules $(1): $(BUILD_DIR)/$(1)/$(PROJECT)$(if $(filter win%,$(1)),.exe) .PHONY: $(1) $(BUILD_DIR)/$(1)/$(PROJECT)$(if $(filter win%,$(1)),.exe): $(filter $(BUILD_DIR)/$(1)/%,$(ALL_APP_OBJS)) @echo "[link] $$@" @$$(CC) -o $$@ $$^ $$(LDFLAGS) $(BUILD_DIR)/$(1)/%.o: %.c @mkdir -p $$(dir $$@) @echo "[c] $$@" @$$(CC) $$(CFLAGS) -c $$< -o $$@ $(BUILD_DIR)/$(1)/%.o: %.m @mkdir -p $$(dir $$@) @echo "[m] $$@" @$$(CC) $$(CFLAGS) -c $$< -o $$@ $(BUILD_DIR)/$(1)/%.o: %.S @mkdir -p $$(dir $$@) @echo "[as] $$@" @$$(AS) -c $$< -o $$@ endef $(foreach build_type,$(BUILD_TYPES),$(eval $(call build_rules,$(build_type)))) src/version.h : $(firstword $(MAKEFILE_LIST)) @echo "[version] $@" @echo "#define VERSION_NUMBER \"$(VERSION_NUMBER)\"" > $@ @echo "#define VERSION_NAME \"$(VERSION_NAME)\"" >> $@ src/android/AndroidManifest.xml : $(firstword $(MAKEFILE_LIST)) @echo "[android_version] $@" @sed -i \ -e 's/versionCode=".*"/versionCode="$(VERSION_CODE)"/' \ -e 's/versionName=".*"/versionName="$(VERSION_NUMBER)"/' \ -e 's/android:minSdkVersion="[[:digit:]]*"/android:minSdkVersion="$(ANDROID_MIN_SDK_VERSION)"/' \ -e 's/android:targetSdkVersion="[[:digit:]]*"/android:targetSdkVersion="$(ANDROID_TARGET_SDK_VERSION)"/' \ $@ # Android support. out/res/layout_activity_main.xml.flat: src/android/res/layout/activity_main.xml @mkdir -p $(dir $@) @echo "[aapt2] $@" @$(ANDROID_BUILD_TOOLS)/aapt2 compile -o out/res/ src/android/res/layout/activity_main.xml out/res/drawable_icon.xml.flat: src/android/res/drawable/icon.xml @mkdir -p $(dir $@) @echo "[aapt2] $@" @$(ANDROID_BUILD_TOOLS)/aapt2 compile -o out/res/ src/android/res/drawable/icon.xml out/apk/res.apk out/gen/com/unprompted/tildefriends/R.java: out/res/layout_activity_main.xml.flat out/res/drawable_icon.xml.flat src/android/AndroidManifest.xml @echo [aapt2 link] res.apk @mkdir -p out/apk/ @$(ANDROID_BUILD_TOOLS)/aapt2 link -I $(ANDROID_PLATFORM)/android.jar out/res/layout_activity_main.xml.flat out/res/drawable_icon.xml.flat \ --min-sdk-version $(ANDROID_MIN_SDK_VERSION) \ --target-sdk-version $(ANDROID_TARGET_SDK_VERSION) \ --manifest src/android/AndroidManifest.xml \ -o out/apk/res.apk \ --java out/gen/ out/apk/res.fdroid.apk out/gen_fdroid/com/unprompted/tildefriends/R.java: out/res/layout_activity_main.xml.flat out/res/drawable_icon.xml.flat src/android/AndroidManifest.xml @echo [aapt2 link] res.fdroid.apk @mkdir -p out/apk/ @$(ANDROID_BUILD_TOOLS)/aapt2 link -I $(ANDROID_PLATFORM)/android.jar out/res/layout_activity_main.xml.flat out/res/drawable_icon.xml.flat \ --min-sdk-version $(ANDROID_MIN_SDK_VERSION) \ --target-sdk-version $(ANDROID_TARGET_SDK_VERSION) \ --rename-manifest-package com.unprompted.tildefriends.fdroid \ --manifest src/android/AndroidManifest.xml \ -o out/apk/res.fdroid.apk \ --java out/gen_fdroid/ JAVA_FILES := out/gen/com/unprompted/tildefriends/R.java $(wildcard src/android/com/unprompted/tildefriends/*.java) CLASS_FILES := $(foreach src,$(JAVA_FILES),out/classes/com/unprompted/tildefriends/$(notdir $(src:.java=.class))) $(CLASS_FILES) &: $(JAVA_FILES) @echo "[javac] $(CLASS_FILES)" @javac --release 8 -encoding UTF-8 -Xlint:deprecation -XDuseUnsharedTable=true -classpath $(ANDROID_PLATFORM)/android.jar:$(ANDROID_BUILD_TOOLS)/core-lambda-stubs.jar -d out/classes $(JAVA_FILES) out/apk/classes.dex: $(CLASS_FILES) @mkdir -p $(dir $@) @echo "[d8] $@" @$(ANDROID_BUILD_TOOLS)/d8 --lib $(ANDROID_PLATFORM)/android.jar --output $(dir $@) out/classes/com/unprompted/tildefriends/*.class PACKAGE_DIRS := \ apps/ \ core/ \ deps/codemirror/ \ deps/prettier/ \ deps/lit/ RAW_FILES := $(sort $(filter-out apps/blog% apps/issues% apps/welcome% apps/journal% %.map, $(shell find $(PACKAGE_DIRS) -type f -not -name '.*'))) out/apk/TildeFriends-arm-debug.unsigned.apk: BUILD_TYPE := debug out/apk/TildeFriends-arm-release.unsigned.apk: BUILD_TYPE := release out/apk/TildeFriends-x86-debug.unsigned.apk: BUILD_TYPE := debug out/apk/TildeFriends-x86-release.unsigned.apk: BUILD_TYPE := release out/apk/TildeFriends-release.fdroid.unsigned.apk: BUILD_TYPE := release out/apk/TildeFriends-arm-debug.unsigned.apk: out/apk/classes.dex out/androiddebug/tildefriends out/androiddebug-armv7a/tildefriends $(RAW_FILES) out/apk/res.apk out/apk/TildeFriends-arm-release.unsigned.apk: out/apk/classes.dex out/androidrelease/tildefriends out/androidrelease-armv7a/tildefriends $(RAW_FILES) out/apk/res.apk out/apk/TildeFriends-x86-debug.unsigned.apk: out/apk/classes.dex out/androiddebug-x86_64/tildefriends out/androiddebug-x86/tildefriends $(RAW_FILES) out/apk/res.apk out/apk/TildeFriends-x86-release.unsigned.apk: out/apk/classes.dex out/androidrelease-x86_64/tildefriends out/androidrelease-x86/tildefriends $(RAW_FILES) out/apk/res.apk out/apk/TildeFriends-release.fdroid.unsigned.apk: out/apk/classes.dex out/androidrelease/tildefriends out/androidrelease-armv7a/tildefriends out/androidrelease-x86_64/tildefriends out/androidrelease-x86/tildefriends $(RAW_FILES) out/apk/res.fdroid.apk $(BUNDLETOOL): @echo [curl] $(BUNDLETOOL_URL) TO $@ @curl -q -L --create-dirs -o $@ $(BUNDLETOOL_URL) out/TildeFriends.aab: out/apk/classes.dex $(filter-out %debug%, $(ANDROID_TARGETS)) $(RAW_FILES) out/apk/res.apk src/android/AndroidManifest.xml $(BUNDLETOOL) @rm -rf out/aab/staging/ @mkdir -p out/aab/staging @$(ANDROID_BUILD_TOOLS)/aapt2 link --proto-format -o out/aab/temporary.apk \ -I $(ANDROID_PLATFORM)/android.jar \ --min-sdk-version $(ANDROID_MIN_SDK_VERSION) \ --target-sdk-version $(ANDROID_TARGET_SDK_VERSION) \ --manifest src/android/AndroidManifest.xml \ -R out/res/layout_activity_main.xml.flat \ -R out/res/drawable_icon.xml.flat \ --auto-add-overlay @unzip out/aab/temporary.apk -d out/aab/staging/ @mkdir -p out/aab/staging/root/deps @mkdir -p out/aab/staging/classes @mkdir -p out/aab/staging/dex @mkdir -p out/aab/staging/manifest @mv out/aab/staging/AndroidManifest.xml out/aab/staging/manifest/AndroidManifest.xml @cp out/apk/classes.dex out/aab/staging/dex/ @rm -fv out/base.zip @mkdir -p out/aab/staging/lib/arm64-v8a out/aab/staging/lib/armeabi-v7a out/aab/staging/lib/x86_64 out/aab/staging/lib/x86 @cp out/androidrelease/tildefriends out/aab/staging/lib/arm64-v8a/libtildefriends.so @cp out/androidrelease-armv7a/tildefriends out/aab/staging/lib/armeabi-v7a/libtildefriends.so @cp out/androidrelease-x86_64/tildefriends out/aab/staging/lib/x86_64/libtildefriends.so @cp out/androidrelease-x86/tildefriends out/aab/staging/lib/x86/libtildefriends.so @$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/aab/staging/lib/arm64-v8a/libtildefriends.so @$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/aab/staging/lib/armeabi-v7a/libtildefriends.so @$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/aab/staging/lib/x86_64/libtildefriends.so @$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/aab/staging/lib/x86/libtildefriends.so @cp -r apps/ out/aab/staging/root/ @rm -rf out/aab/staging/root/apps/welcome* @cp -r core/ out/aab/staging/root/ @cp -r deps/prettier/ out/aab/staging/root/deps/ @cp -r deps/lit/ out/aab/staging/root/deps/ @cp -r deps/codemirror/ out/aab/staging/root/deps/ @cd out/aab/staging/; zip -r ../base.zip *; cd ../../../ @java -jar $(BUNDLETOOL) build-bundle --overwrite --config=src/android/BundleConfig.json --modules=out/aab/base.zip --output=$@ @jarsigner -keystore .keys/android.jks $@ androidKey -storepass android aab: out/TildeFriends.aab .PHONY: aab out/TildeFriends.apks: out/TildeFriends.aab $(BUNDLETOOL) @java -jar $(BUNDLETOOL) build-apks --bundle out/TildeFriends.aab --overwrite --output $@ --ks .keys/android.jks --ks-key-alias androidKey --ks-pass pass:android aabgo: out/TildeFriends.apks $(BUNDLETOOL) @java -jar $(BUNDLETOOL) install-apks --apks out/TildeFriends.apks @adb shell am start com.unprompted.tildefriends/.TildeFriendsActivity out/apk/TildeFriends-arm-%.unsigned.apk: @mkdir -p $(dir $@) out/apk-arm-$(BUILD_TYPE)/lib/arm64-v8a/ out/apk-arm-$(BUILD_TYPE)/lib/armeabi-v7a/ @echo "[aapt] $@" @cp out/android$(BUILD_TYPE)/tildefriends out/apk-arm-$(BUILD_TYPE)/lib/arm64-v8a/libtildefriends.so @cp out/android$(BUILD_TYPE)-armv7a/tildefriends out/apk-arm-$(BUILD_TYPE)/lib/armeabi-v7a/libtildefriends.so @$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk-arm-$(BUILD_TYPE)/lib/arm64-v8a/libtildefriends.so @$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk-arm-$(BUILD_TYPE)/lib/armeabi-v7a/libtildefriends.so @cp out/apk/res.apk $@.zip @cp out/apk/classes.dex out/apk-arm-$(BUILD_TYPE)/ @cd out/apk-arm-$(BUILD_TYPE) && zip -u ../../$@.zip -q -9 -r . && cd ../../ @zip -u $@.zip -q -9 $(RAW_FILES) @$(ANDROID_BUILD_TOOLS)/zipalign -f 4 $@.zip $@ out/apk/TildeFriends-x86-%.unsigned.apk: @mkdir -p $(dir $@) out/apk-x86-$(BUILD_TYPE)/lib/x86_64/ out/apk-x86-$(BUILD_TYPE)/lib/x86/ @echo "[aapt] $@" @cp out/android$(BUILD_TYPE)-x86_64/tildefriends out/apk-x86-$(BUILD_TYPE)/lib/x86_64/libtildefriends.so @cp out/android$(BUILD_TYPE)-x86/tildefriends out/apk-x86-$(BUILD_TYPE)/lib/x86/libtildefriends.so @$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk-x86-$(BUILD_TYPE)/lib/x86_64/libtildefriends.so @$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk-x86-$(BUILD_TYPE)/lib/x86/libtildefriends.so @cp out/apk/res.apk $@.zip @cp out/apk/classes.dex out/apk-x86-$(BUILD_TYPE)/ @cd out/apk-x86-$(BUILD_TYPE) && zip -u ../../$@.zip -q -9 -r . && cd ../../ @zip -u $@.zip -q -9 $(RAW_FILES) @$(ANDROID_BUILD_TOOLS)/zipalign -f 4 $@.zip $@ out/apk/TildeFriends-%.fdroid.unsigned.apk: @rm -rf out/apk-fdroid-$(BUILD_TYPE) out/apk-fdroid-$(BUILD_TYPE)-raw @mkdir -p $(dir $@) out/apk-fdroid-$(BUILD_TYPE)/lib/x86_64/ out/apk-fdroid-$(BUILD_TYPE)/lib/x86/ out/apk-fdroid-$(BUILD_TYPE)/lib/arm64-v8a/ out/apk-fdroid-$(BUILD_TYPE)/lib/armeabi-v7a/ @echo "[aapt] $@" @cp out/android$(BUILD_TYPE)-x86_64/tildefriends out/apk-fdroid-$(BUILD_TYPE)/lib/x86_64/libtildefriends.so @cp out/android$(BUILD_TYPE)-x86/tildefriends out/apk-fdroid-$(BUILD_TYPE)/lib/x86/libtildefriends.so @cp out/android$(BUILD_TYPE)/tildefriends out/apk-fdroid-$(BUILD_TYPE)/lib/arm64-v8a/libtildefriends.so @cp out/android$(BUILD_TYPE)-armv7a/tildefriends out/apk-fdroid-$(BUILD_TYPE)/lib/armeabi-v7a/libtildefriends.so @$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk-fdroid-$(BUILD_TYPE)/lib/x86_64/libtildefriends.so @$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk-fdroid-$(BUILD_TYPE)/lib/x86/libtildefriends.so @$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk-fdroid-$(BUILD_TYPE)/lib/arm64-v8a/libtildefriends.so @$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk-fdroid-$(BUILD_TYPE)/lib/armeabi-v7a/libtildefriends.so @cp out/apk/res.fdroid.apk $@.zip @cp out/apk/classes.dex out/apk-fdroid-$(BUILD_TYPE)/classes.dex @touch -d @0 out/apk-fdroid-$(BUILD_TYPE)/classes.dex out/apk-fdroid-$(BUILD_TYPE)/lib/*/libtildefriends.so @chmod 755 out/apk-fdroid-$(BUILD_TYPE)/classes.dex out/apk-fdroid-$(BUILD_TYPE)/lib/*/libtildefriends.so @cd out/apk-fdroid-$(BUILD_TYPE) && zip -X -u ../../$@.zip -q classes.dex lib/*/libtildefriends.so && cd ../../ @mkdir out/apk-fdroid-$(BUILD_TYPE)-raw @for i in $(RAW_FILES); do mkdir -p $$(dirname out/apk-fdroid-$(BUILD_TYPE)-raw/$$i) && cp $$i out/apk-fdroid-$(BUILD_TYPE)-raw/$$i && touch -d @0 out/apk-fdroid-$(BUILD_TYPE)-raw/$$i && chmod 644 out/apk-fdroid-$(BUILD_TYPE)-raw/$$i; done @cd out/apk-fdroid-$(BUILD_TYPE)-raw && zip -X -u ../../$@.zip -q $(RAW_FILES) && cd ../../ @$(ANDROID_BUILD_TOOLS)/zipalign -f 4 $@.zip $@ out/%.apk: out/apk/%.unsigned.apk @echo "[apksigner] $(notdir $@)" @$(ANDROID_BUILD_TOOLS)/apksigner sign --ks .keys/android.jks --ks-key-alias androidKey --ks-pass pass:android --key-pass pass:android --min-sdk-version $(ANDROID_MIN_SDK_VERSION) --out $@ $< out/%.zopfli.apk: out/%.apk @echo "[zopfli] $(notdir $@)" $(ANDROID_BUILD_TOOLS)/zipalign -f -z 4 $< $@.zopfli @$(ANDROID_BUILD_TOOLS)/apksigner sign --ks .keys/android.jks --ks-key-alias androidKey --ks-pass pass:android --key-pass pass:android --min-sdk-version $(ANDROID_MIN_SDK_VERSION) --out $@ $@.zopfli release-apk: out/TildeFriends-arm-release.zopfli.apk out/TildeFriends-x86-release.zopfli.apk .PHONY: release-apk apkgo: out/TildeFriends-arm-debug.apk @adb install -r $< @adb shell am start com.unprompted.tildefriends/.TildeFriendsActivity .PHONY: apkgo releaseapkgo: out/TildeFriends-arm-release.apk @adb install -r $< @adb shell am start com.unprompted.tildefriends/.TildeFriendsActivity .PHONY: releaseapkgo # iOS Support out/%.app/Info.plist: src/ios/Info.plist @mkdir -p $(dir $@) @cp -v $< $@ out/%.app/tildefriends.png: src/ios/tildefriends.png @mkdir -p $(dir $@) @cp -v $< $@ out/data.zip: $(RAW_FILES) @zip -u $@ -q -9 $(RAW_FILES) out/tildefriends-%.app/tildefriends: out/%/tildefriends out/tildefriends-%.app/Info.plist out/tildefriends-%.app/tildefriends.png out/data.zip @mkdir -p $(dir $@) @cp -v $< $@ @cp -v out/data.zip $(@D)/ ifeq ($(HAVE_LINUX_IOS),1) @zsign -q -k .keys/apple.p12 -f -m src/ios/embedded.mobileprovision $(realpath $(dir $@)) endif .SECONDARY: out/tildefriends-%.ipa: out/tildefriends-ios%.app/tildefriends @echo "[ipa] $@" @rm -rf $@.tmp $@ @mkdir -p $@.tmp/Payload/tildefriends.app/ @cp -R $(dir $<)/* $@.tmp/Payload/tildefriends.app/ @cd $@.tmp/ && zip -u ../../$@ -q -9 -r ./ @rm -rf $@.tmp/ out/%/tildefriends.standalone: out/%/tildefriends out/data.zip @echo "[standalone] $@" @cat $< out/data.zip > $@ @chmod +x $@ out/%/tildefriends.standalone.exe: out/%/tildefriends.exe out/data.zip @echo "[standalone] $@" @cat $< out/data.zip > $@ @chmod +x $@ iossimdebug-app: out/tildefriends-iossimdebug.app/tildefriends iossimrelease-app: out/tildefriends-iossimrelease.app/tildefriends iosdebug-app: out/tildefriends-iosdebug.app/tildefriends iosrelease-app: out/tildefriends-iosrelease.app/tildefriends iosdebug-ipa: out/tildefriends-debug.ipa iosrelease-ipa: out/tildefriends-release.ipa .PHONY: iossimdebug-app iossimrelease-app iosdebug-app iosrelease-app ios%go: out/tildefriends-ios%.app/tildefriends ideviceinstaller -i $(realpath $(dir $<)) iossimdebuggo: out/tildefriends-iossimdebug.app/tildefriends xcrun simctl install booted out/tildefriends-iossimdebug.app/ xcrun simctl launch booted com.unprompted.tildefriends .PHONY: iossimdebuggo apklog: @adb logcat *:S tildefriends .PHONY: apklog fetchdeps: @echo "[fetch] sqlite" @test -f out/deps/sqlite.zip && test "$$(cat out/deps/sqlite.txt 2>/dev/null)" = $(SQLITE_URL) || (mkdir -p out/deps/ && curl -q $(SQLITE_URL) -o out/deps/sqlite.zip) @test -d deps/sqlite/ && test "$$(cat out/deps/sqlite.txt 2>/dev/null)" = $(SQLITE_URL) || (mkdir -p deps/sqlite/ && unzip -qDjo -d deps/sqlite/ out/deps/sqlite.zip) @echo -n $(SQLITE_URL) > out/deps/sqlite.txt @echo "[fetch] prettier" @test -f deps/prettier/standalone.mjs || curl -q --create-dirs -O --output-dir deps/prettier/ https://cdn.jsdelivr.net/npm/prettier@3.2.5/standalone.mjs @test -f deps/prettier/html.mjs || curl -q --create-dirs -O --output-dir deps/prettier/ https://cdn.jsdelivr.net/npm/prettier@3.2.5/plugins/html.mjs @test -f deps/prettier/babel.mjs || curl -q --create-dirs -O --output-dir deps/prettier/ https://cdn.jsdelivr.net/npm/prettier@3.2.5/plugins/babel.mjs @test -f deps/prettier/estree.mjs || curl -q --create-dirs -O --output-dir deps/prettier/ https://cdn.jsdelivr.net/npm/prettier@3.2.5/plugins/estree.mjs .PHONY: fetchdeps ANDROID_DEPS := deps/openssl/android/arm64-v8a/usr/local/lib/libssl.a $(ANDROID_DEPS): +@ANDROID_NDK_ROOT=$(ANDROID_NDK) tools/ssl-android $(filter $(BUILD_DIR)/android%,$(APP_OBJS)): | $(ANDROID_DEPS) ifeq ($(HAVE_WIN),1) WINDOWS_DEPS := deps/openssl/mingw64/usr/local/lib/libssl.a $(WINDOWS_DEPS): +@tools/ssl-mingw64 $(filter $(BUILD_DIR)/win%,$(APP_OBJS)): | $(WINDOWS_DEPS) endif ifeq ($(UNAME_S),Darwin) IOS_DEPS := deps/openssl/ios/ios64-xcrun/usr/local/lib/libssl.a $(IOS_DEPS): +@tools/ssl-ios $(filter $(BUILD_DIR)/ios%,$(APP_OBJS)): | $(IOS_DEPS) endif out/tildefriends-x86_64.AppImage: out/release/tildefriends out/data.zip @echo "[appimage] $$@" @rm -rf out/tildefriends.AppDir @mkdir -p out/tildefriends.AppDir/usr/bin @mkdir -p out/tildefriends.AppDir/usr/share/applications @mkdir -p out/tildefriends.AppDir/usr/share/icons/hicolor/scalable/apps @mkdir -p out/tildefriends.AppDir/usr/share/tildefriends @echo $(APPIMAGETOOL_MD5) > out/appimagetool.md5 @test -x out/appimagetool || curl -q -L -o out/appimagetool $(APPIMAGETOOL_URL) && md5sum -c out/appimagetool.md5 && chmod +x out/appimagetool @echo "[Desktop Entry]\nName=tildefriends\nExec=/usr/bin/tildefriends\nIcon=/usr/share/icons/hicolor/scalable/apps/tildefriends\nType=Application\nCategories=Network" > out/tildefriends.AppDir/tildefriends.desktop @cp src/ios/tildefriends.svg out/tildefriends.AppDir/usr/share/icons/hicolor/scalable/apps/ @cp src/ios/tildefriends.svg out/tildefriends.AppDir/ @cp out/release/tildefriends out/tildefriends.AppDir/usr/bin/ @cp out/data.zip out/tildefriends.AppDir/usr/share/tildefriends/data.zip @echo "#!/bin/sh\n\$${APPDIR}/usr/bin/tildefriends run -z \$$APPDIR/usr/share/tildefriends/data.zip" > out/tildefriends.AppDir/AppRun @chmod +x out/tildefriends.AppDir/AppRun @cd out; ./appimagetool --appimage-extract; cd .. @cd out; unset SOURCE_DATE_EPOCH; PATH=$$PATH:squashfs-root/usr/bin ARCH=x86_64 squashfs-root/usr/bin/appimagetool -u 'zsync|https://dev.tildefriends.net/releases/tildefriends-x86_64.AppImage.zsync' tildefriends.AppDir tildefriends-x86_64.AppImage; cd .. appimage: out/tildefriends-x86_64.AppImage .PHONY: appimage flatpak: out/ flatpak-builder --force-clean --user --install-deps-from=flathub --install --repo=out/flatpak-repo out/flatpak src/com.unprompted.tildefriends.yml .PHONY: flatpak clean: rm -rf $(BUILD_DIR) .PHONY: clean tarball: @echo [archive] out/tildefriends-$(VERSION_NUMBER).tar.xz @rm -rf out/tildefriends-$(VERSION_NUMBER) @mkdir -p out/tildefriends-$(VERSION_NUMBER) @git ls-files --recurse-submodules | tar -c -T- | tar -x -C out/tildefriends-$(VERSION_NUMBER) @tar \ --exclude=apps/welcome* \ --exclude=deps/libbacktrace/Isaac.Newton-Opticks.txt \ --exclude=deps/libsodium/builds/msvc/vs* \ --exclude=deps/libsodium/builds/msvc/build \ --exclude=deps/libsodium/builds/msvc/properties \ --exclude=deps/libsodium/configure \ --exclude=deps/libsodium/test \ --exclude=deps/libuv/docs \ --exclude=deps/libuv/test \ --exclude=deps/openssl \ --exclude=deps/speedscope/*.map \ --exclude=deps/sqlite/shell.c \ --exclude=deps/zlib/contrib/vstudio \ --exclude=deps/zlib/doc \ -caf out/tildefriends-$(VERSION_NUMBER).tar.xz \ -C out/ \ tildefriends-$(VERSION_NUMBER) .PHONY: tarball dist: release-apk iosrelease-ipa aab $(if $(HAVE_WIN), out/winrelease/tildefriends.standalone.exe) out/TildeFriends-release.fdroid.apk appimage tarball @mkdir -p dist/ @echo "[cp] tildefriends-$(VERSION_NUMBER).tar.xz" @cp out/tildefriends-$(VERSION_NUMBER).tar.xz dist/tildefriends-$(VERSION_NUMBER).tar.xz @echo "[cp] TildeFriends-x86-$(VERSION_NUMBER).apk" @cp out/TildeFriends-x86-release.zopfli.apk dist/TildeFriends-x86-$(VERSION_NUMBER).apk @echo "[cp] TildeFriends-arm-$(VERSION_NUMBER).apk" @cp out/TildeFriends-arm-release.zopfli.apk dist/TildeFriends-arm-$(VERSION_NUMBER).apk @echo "[cp] TildeFriends-$(VERSION_NUMBER).ipa" @cp out/tildefriends-release.ipa dist/TildeFriends-$(VERSION_NUMBER).ipa @test $(HAVE_WIN) && echo "[cp] tildefriends-$(VERSION_NUMBER).exe" @test $(HAVE_WIN) && cp out/winrelease/tildefriends.standalone.exe dist/tildefriends-$(VERSION_NUMBER).exe @echo "[cp] TildeFriends-$(VERSION_NUMBER).aab" @cp out/TildeFriends.aab dist/TildeFriends-$(VERSION_NUMBER).aab @echo "[cp] TildeFriends-$(VERSION_NUMBER).fdroid.apk" @cp out/TildeFriends-release.fdroid.apk dist/TildeFriends-$(VERSION_NUMBER).fdroid.apk @echo "[cp] TildeFriends-x86_64-$(VERSION_NUMBER).AppImage" @cp out/tildefriends-x86_64.AppImage dist/TildeFriends-x86_64-$(VERSION_NUMBER).AppImage .PHONY: dist dist-test: dist @tar -xf tildefriends-$(VERSION_NUMBER).tar.xz @$(MAKE) -C tildefriends-$(VERSION_NUMBER)/ debug release @docker build tildefriends-$(VERSION_NUMBER)/ @rm -rf tildefriends-$(VERSION_NUMBER) .PHONY: dist-test format: @clang-format -i $(wildcard src/*.c src/*.h src/*.m) .PHONY: format prettier: @npm run prettier .PHONY: prettier docs: @doxygen .PHONY: docs fdroid: out/apk/TildeFriends-release.fdroid.unsigned.apk .PHONY: fdroid