11# Makefile for SQLite JavaScript Extension
2- # Supports compilation for Linux, macOS, and Windows
2+ # Supports compilation for Linux, macOS, Windows, Android and iOS
33
44# Set default platform if not specified
55ifeq ($(OS ) ,Windows_NT)
@@ -33,7 +33,6 @@ CFLAGS := -Wall -Wextra -fPIC -g -O2 -DQJS_BUILD_LIBC $(INCLUDES)
3333ifeq ($(PLATFORM ) ,windows)
3434 TARGET := $(DIST_DIR ) /js.dll
3535 LDFLAGS := -shared
36- CC := gcc
3736 # Windows-specific flags
3837 CFLAGS += -D_WIN32
3938 # Create .def file for Windows
@@ -43,6 +42,28 @@ else ifeq ($(PLATFORM),macos)
4342 LDFLAGS := -dynamiclib -undefined dynamic_lookup
4443 # macOS-specific flags
4544 CFLAGS += -arch x86_64 -arch arm64
45+ else ifeq ($(PLATFORM),android)
46+ # Use Android NDK's Clang compiler, the user should set the CC
47+ # example CC=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android26-clang
48+ ifeq ($(filter %-clang,$(CC)),)
49+ $(error "CC must be set to the Android NDK's Clang compiler")
50+ endif
51+ TARGET := $(DIST_DIR ) /js.so
52+ LDFLAGS := -shared
53+ # Android-specific flags
54+ CFLAGS += -D__ANDROID__
55+ else ifeq ($(PLATFORM),ios)
56+ TARGET := $(DIST_DIR ) /js.dylib
57+ SDK := -isysroot $(shell xcrun --sdk iphoneos --show-sdk-path) -miphoneos-version-min=11.0
58+ LDFLAGS := -dynamiclib $(SDK )
59+ # iOS-specific flags
60+ CFLAGS += -arch arm64 $(SDK )
61+ else ifeq ($(PLATFORM),isim)
62+ TARGET := $(DIST_DIR ) /js.dylib
63+ SDK := -isysroot $(shell xcrun --sdk iphonesimulator --show-sdk-path) -miphonesimulator-version-min=11.0
64+ LDFLAGS := -dynamiclib $(SDK )
65+ # iphonesimulator-specific flags
66+ CFLAGS += -arch x86_64 -arch arm64 $(SDK )
4667else # linux
4768 TARGET := $(DIST_DIR ) /js.so
4869 LDFLAGS := -shared
@@ -112,6 +133,9 @@ help:
112133 @echo " linux (default on Linux)"
113134 @echo " macos (default on macOS)"
114135 @echo " windows (default on Windows)"
136+ @echo " android (needs CC to be set to Android NDK's Clang compiler)"
137+ @echo " ios (only on macOS)"
138+ @echo " isim (only on macOS)"
115139 @echo " "
116140 @echo " Targets:"
117141 @echo " all - Build the extension (default)"
0 commit comments