1
1
# Makefile for SQLite JavaScript Extension
2
- # Supports compilation for Linux, macOS, and Windows
2
+ # Supports compilation for Linux, macOS, Windows, Android and iOS
3
3
4
4
# Set default platform if not specified
5
5
ifeq ($(OS ) ,Windows_NT)
@@ -33,7 +33,6 @@ CFLAGS := -Wall -Wextra -fPIC -g -O2 -DQJS_BUILD_LIBC $(INCLUDES)
33
33
ifeq ($(PLATFORM ) ,windows)
34
34
TARGET := $(DIST_DIR ) /js.dll
35
35
LDFLAGS := -shared
36
- CC := gcc
37
36
# Windows-specific flags
38
37
CFLAGS += -D_WIN32
39
38
# Create .def file for Windows
@@ -43,6 +42,28 @@ else ifeq ($(PLATFORM),macos)
43
42
LDFLAGS := -dynamiclib -undefined dynamic_lookup
44
43
# macOS-specific flags
45
44
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 )
46
67
else # linux
47
68
TARGET := $(DIST_DIR ) /js.so
48
69
LDFLAGS := -shared
@@ -112,6 +133,9 @@ help:
112
133
@echo " linux (default on Linux)"
113
134
@echo " macos (default on macOS)"
114
135
@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)"
115
139
@echo " "
116
140
@echo " Targets:"
117
141
@echo " all - Build the extension (default)"
0 commit comments