@@ -7,18 +7,18 @@ SQLITE3 ?= sqlite3
77
88# Set default platform if not specified
99ifeq ($(OS ) ,Windows_NT)
10- PLATFORM := windows
11- HOST := windows
12- CPUS := $(shell powershell -Command "[Environment]::ProcessorCount")
10+ PLATFORM := windows
11+ HOST := windows
12+ CPUS := $(shell powershell -Command "[Environment]::ProcessorCount")
1313else
14- HOST = $(shell uname -s | tr '[:upper:]' '[:lower:]')
15- ifeq ($(HOST),darwin)
16- PLATFORM := macos
17- CPUS := $(shell sysctl -n hw.ncpu)
18- else
19- PLATFORM := $(HOST )
20- CPUS := $(shell nproc)
21- endif
14+ HOST = $(shell uname -s | tr '[:upper:]' '[:lower:]')
15+ ifeq ($(HOST),darwin)
16+ PLATFORM := macos
17+ CPUS := $(shell sysctl -n hw.ncpu)
18+ else
19+ PLATFORM := $(HOST)
20+ CPUS := $(shell nproc)
21+ endif
2222endif
2323
2424# Speed up builds by using all available CPU cores
@@ -41,48 +41,48 @@ OBJ_FILES = $(patsubst %.c, $(BUILD_DIR)/%.o, $(notdir $(SRC_FILES)))
4141
4242# Platform-specific settings
4343ifeq ($(PLATFORM ) ,windows)
44- TARGET := $(DIST_DIR ) /vector.dll
45- LDFLAGS += -shared
46- # Create .def file for Windows
47- DEF_FILE := $(BUILD_DIR ) /vector.def
44+ TARGET := $(DIST_DIR)/vector.dll
45+ LDFLAGS += -shared
46+ # Create .def file for Windows
47+ DEF_FILE := $(BUILD_DIR)/vector.def
4848else ifeq ($(PLATFORM),macos)
49- TARGET := $(DIST_DIR ) /vector.dylib
50- LDFLAGS += -arch x86_64 -arch arm64 -dynamiclib -undefined dynamic_lookup
51- CFLAGS += -arch x86_64 -arch arm64
49+ TARGET := $(DIST_DIR)/vector.dylib
50+ LDFLAGS += -arch x86_64 -arch arm64 -dynamiclib -undefined dynamic_lookup
51+ CFLAGS += -arch x86_64 -arch arm64
5252else ifeq ($(PLATFORM),android)
53- # Set ARCH to find Android NDK's Clang compiler, the user should set the ARCH
54- ifeq ($(filter %,$(ARCH)),)
55- $(error "Android ARCH must be set to ARCH=x86_64 or ARCH=arm64-v8a")
56- endif
57- # Set ANDROID_NDK path to find android build tools
58- # e.g. on MacOS: export ANDROID_NDK=/Users/username/Library/Android/sdk/ndk/25.2.9519653
59- ifeq ($(filter %,$(ANDROID_NDK)),)
60- $(error "Android NDK must be set")
61- endif
62-
63- BIN = $(ANDROID_NDK ) /toolchains/llvm/prebuilt/$(HOST ) -x86_64/bin
64- PATH := $(BIN ) :$(PATH )
65-
66- ifneq (,$(filter $(ARCH),arm64 arm64-v8a))
67- override ARCH := aarch64
68- endif
69-
70- CC = $(BIN ) /$(ARCH ) -linux-android26-clang
71- TARGET := $(DIST_DIR ) /vector.so
72- LDFLAGS += -lm -shared
53+ # Set ARCH to find Android NDK's Clang compiler, the user should set the ARCH
54+ ifeq ($(filter %,$(ARCH)),)
55+ $(error "Android ARCH must be set to ARCH=x86_64 or ARCH=arm64-v8a")
56+ endif
57+ # Set ANDROID_NDK path to find android build tools
58+ # e.g. on MacOS: export ANDROID_NDK=/Users/username/Library/Android/sdk/ndk/25.2.9519653
59+ ifeq ($(filter %,$(ANDROID_NDK)),)
60+ $(error "Android NDK must be set")
61+ endif
62+
63+ BIN = $(ANDROID_NDK)/toolchains/llvm/prebuilt/$(HOST)-x86_64/bin
64+ PATH := $(BIN):$(PATH)
65+
66+ ifneq (,$(filter $(ARCH),arm64 arm64-v8a))
67+ override ARCH := aarch64
68+ endif
69+
70+ CC = $(BIN)/$(ARCH)-linux-android26-clang
71+ TARGET := $(DIST_DIR)/vector.so
72+ LDFLAGS += -lm -shared
7373else ifeq ($(PLATFORM),ios)
74- TARGET := $(DIST_DIR ) /vector.dylib
75- SDK := -isysroot $(shell xcrun --sdk iphoneos --show-sdk-path) -miphoneos-version-min=11.0
76- LDFLAGS += -dynamiclib $(SDK )
77- CFLAGS += -arch arm64 $(SDK )
74+ TARGET := $(DIST_DIR)/vector.dylib
75+ SDK := -isysroot $(shell xcrun --sdk iphoneos --show-sdk-path) -miphoneos-version-min=11.0
76+ LDFLAGS += -dynamiclib $(SDK)
77+ CFLAGS += -arch arm64 $(SDK)
7878else ifeq ($(PLATFORM),isim)
79- TARGET := $(DIST_DIR ) /vector.dylib
80- SDK := -isysroot $(shell xcrun --sdk iphonesimulator --show-sdk-path) -miphonesimulator-version-min=11.0
81- LDFLAGS += -arch x86_64 -arch arm64 -dynamiclib $(SDK )
82- CFLAGS += -arch x86_64 -arch arm64 $(SDK )
79+ TARGET := $(DIST_DIR)/vector.dylib
80+ SDK := -isysroot $(shell xcrun --sdk iphonesimulator --show-sdk-path) -miphonesimulator-version-min=11.0
81+ LDFLAGS += -arch x86_64 -arch arm64 -dynamiclib $(SDK)
82+ CFLAGS += -arch x86_64 -arch arm64 $(SDK)
8383else # linux
84- TARGET := $(DIST_DIR ) /vector.so
85- LDFLAGS += -shared
84+ TARGET := $(DIST_DIR)/vector.so
85+ LDFLAGS += -shared
8686endif
8787
8888# Windows .def file generation
@@ -104,7 +104,7 @@ all: $(TARGET)
104104$(TARGET ) : $(OBJ_FILES ) $(DEF_FILE )
105105 $(CC ) $(OBJ_FILES ) $(DEF_FILE ) -o $@ $(LDFLAGS )
106106ifeq ($(PLATFORM ) ,windows)
107- # Generate import library for Windows
107+ # Generate import library for Windows
108108 dlltool -D $@ -d $(DEF_FILE) -l $(DIST_DIR)/vector.lib
109109endif
110110
@@ -134,9 +134,9 @@ help:
134134 @echo " isim (only on macOS)"
135135 @echo " "
136136 @echo " Targets:"
137- @echo " all - Build the extension (default)"
138- @echo " clean - Remove built files"
139- @echo " test - Test the extension"
140- @echo " help - Display this help message"
137+ @echo " all - Build the extension (default)"
138+ @echo " clean - Remove built files"
139+ @echo " test - Test the extension"
140+ @echo " help - Display this help message"
141141
142142.PHONY : all clean test extension help
0 commit comments