forked from xerial/sqlite-jdbc
-
Notifications
You must be signed in to change notification settings - Fork 33
/
Makefile.common
304 lines (257 loc) · 13.6 KB
/
Makefile.common
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
include VERSION
ifndef JAVA_HOME
$(warning It is preferable to set the JAVA_HOME environment variable)
$(warning Trying to auto-detect JAVA_HOME)
$(info Value : $(shell $(which javac)))
JAVA_HOME := $(shell dirname $(dirname $(readlink -f $(which javac))))
endif
$(info Using JAVA_HOME with value "$(JAVA_HOME)")
JAVA := "$(JAVA_HOME)/bin/java"
JAVAC := "$(JAVA_HOME)/bin/javac"
JAVAH := "$(JAVA_HOME)/bin/javah"
TARGET := target
SRC:=src/main/java
OSINFO_CLASS := org.sqlite.util.OSInfo
OSINFO_PROG := lib/org/sqlite/util/OSInfo.class
JAVA_CLASSPATH:=$(TARGET)/classpath/slf4j-api.jar
## building OSInfo.java
ifeq ("$(wildcard $(OSINFO_PROG))","")
$(info Building OSInfo tool)
$(shell mkdir -p $(TARGET)/classpath)
$(shell curl -L -f -o$(JAVA_CLASSPATH) https://search.maven.org/remotecontent?filepath=org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.jar)
$(shell $(JAVAC) -cp $(JAVA_CLASSPATH) -sourcepath $(SRC) -d lib src/main/java/org/sqlite/util/OSInfo.java)
endif
ifndef OS_NAME
OS_NAME := $(shell $(JAVA) -cp lib:$(JAVA_CLASSPATH) $(OSINFO_CLASS) --os)
endif
ifndef OS_ARCH
OS_ARCH := $(shell $(JAVA) -cp lib:$(JAVA_CLASSPATH) $(OSINFO_CLASS) --arch)
endif
# Windows uses different path separators
ifeq ($(OS_NAME),Windows)
sep := ;
else
sep := :
endif
sqlite := sqlite-$(version)
ifdef JAVA_HOME
jni_h := $(shell find "$(JAVA_HOME)" -name jni.h)
ifneq ($(jni_h),)
jni_include := $(shell dirname "$(jni_h)")
endif
jni_md := $(shell find "$(JAVA_HOME)" -name jni_md.h)
ifneq ($(jni_md),)
jni_md_include := $(shell dirname "$(jni_md)")
endif
endif
# os=Default is meant to be generic unix/linux
known_targets := Linux-x86 Linux-x86_64 Linux-Musl-x86 Linux-Musl-x86_64 Linux-Musl-aarch64 Linux-arm Linux-armv6 Linux-armv7 Linux-aarch64 Linux-Android-arm Linux-Android-aarch64 Linux-Android-x86 Linux-Android-x86_64 Linux-ppc64 Linux-riscv64 Mac-x86 Mac-x86_64 Mac-aarch64 DragonFly-x86_64 FreeBSD-x86 FreeBSD-x86_64 FreeBSD-aarch64 OpenBSD-x86_64 Windows-x86 Windows-x86_64 Windows-armv7 Windows-aarch64 SunOS-sparcv9 HPUX-ia64_32
target := $(OS_NAME)-$(OS_ARCH)
ifeq (,$(findstring $(strip $(target)),$(known_targets)))
target := Default
endif
$(info Will build using target: $(target) (detected os: $(OS_NAME), arch: $(OS_ARCH)))
# cross-compilation toolchain prefix (e.g. "arm-linux-gnueabi-")
CROSS_PREFIX :=
Default_CC := $(CROSS_PREFIX)gcc
Default_STRIP := $(CROSS_PREFIX)strip
Default_CCFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_linux -Os -fPIC -fvisibility=hidden -std=gnu11 -march=native
Default_LINKFLAGS := -shared -static-libgcc -pthread -lm
Default_LIBNAME := libsqlitejdbc.so
Default_SQLITE_FLAGS :=
Linux-x86_CC := $(CROSS_PREFIX)gcc
Linux-x86_STRIP := $(CROSS_PREFIX)strip
Linux-x86_CCFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_linux -Os -fPIC -m32 -fvisibility=hidden -msse4.2 -maes
Linux-x86_LINKFLAGS := $(Default_LINKFLAGS)
Linux-x86_LIBNAME := libsqlitejdbc.so
Linux-x86_SQLITE_FLAGS :=
Linux-x86_64_CC := $(CROSS_PREFIX)gcc
Linux-x86_64_STRIP := $(CROSS_PREFIX)strip
Linux-x86_64_CCFLAGS := -Ilib/inc_linux -I$(JAVA_HOME)/include -Os -fPIC -m64 -fvisibility=hidden -msse4.2 -maes
Linux-x86_64_LINKFLAGS := $(Default_LINKFLAGS)
Linux-x86_64_LIBNAME := libsqlitejdbc.so
Linux-x86_64_SQLITE_FLAGS :=
Linux-Musl-x86_64_CC := $(CROSS_PREFIX)gcc
Linux-Musl-x86_64_STRIP := $(CROSS_PREFIX)strip
Linux-Musl-x86_64_CCFLAGS := -Ilib/inc_linux -I$(JAVA_HOME)/include -Os -fPIC -m64 -fvisibility=hidden -msse4.2 -maes
Linux-Musl-x86_64_LINKFLAGS := -shared -static-libgcc
Linux-Musl-x86_64_LIBNAME := libsqlitejdbc.so
Linux-Musl-x86_64_SQLITE_FLAGS :=
Linux-Musl-x86_CC := $(CROSS_PREFIX)gcc
Linux-Musl-x86_STRIP := $(CROSS_PREFIX)strip
Linux-Musl-x86_CCFLAGS := -Ilib/inc_linux -I$(JAVA_HOME)/include -Os -fPIC -m32 -fvisibility=hidden -msse4.2 -maes
Linux-Musl-x86_LINKFLAGS := -shared -static-libgcc
Linux-Musl-x86_LIBNAME := libsqlitejdbc.so
Linux-Musl-x86_SQLITE_FLAGS :=
Linux-arm_CC := $(CROSS_PREFIX)gcc
Linux-arm_STRIP := $(CROSS_PREFIX)strip
Linux-arm_CCFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_linux -Os -fPIC -mfloat-abi=soft -fvisibility=hidden -std=gnu11 -march=armv5t
Linux-arm_LINKFLAGS := $(Default_LINKFLAGS)
Linux-arm_LIBNAME := libsqlitejdbc.so
Linux-arm_SQLITE_FLAGS :=
Linux-armv6_CC := $(CROSS_PREFIX)gcc
Linux-armv6_STRIP := $(CROSS_PREFIX)strip
Linux-armv6_CCFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_linux -Os -mfloat-abi=hard -mfpu=vfp -fPIC -fvisibility=hidden -std=gnu11 -march=armv6
Linux-armv6_LINKFLAGS := $(Default_LINKFLAGS)
Linux-armv6_LIBNAME := libsqlitejdbc.so
Linux-armv6_SQLITE_FLAGS :=
Linux-armv7_CC := $(CROSS_PREFIX)gcc
Linux-armv7_STRIP := $(CROSS_PREFIX)strip
Linux-armv7_CCFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_linux -Os -mfloat-abi=hard -mfpu=vfp -fPIC -fvisibility=hidden -std=gnu11 -march=armv7-a
Linux-armv7_LINKFLAGS := $(Default_LINKFLAGS)
Linux-armv7_LIBNAME := libsqlitejdbc.so
Linux-armv7_SQLITE_FLAGS :=
Linux-aarch64_CC := $(CROSS_PREFIX)gcc
Linux-aarch64_STRIP := $(CROSS_PREFIX)strip
Linux-aarch64_CCFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_linux -Os -fPIC -fvisibility=hidden -std=gnu11 -march=armv8-a
Linux-aarch64_LINKFLAGS := -shared -static-libgcc
Linux-aarch64_LIBNAME := libsqlitejdbc.so
Linux-aarch64_SQLITE_FLAGS :=
Linux-Musl-aarch64_CC := $(CROSS_PREFIX)gcc
Linux-Musl-aarch64_STRIP := $(CROSS_PREFIX)strip
Linux-Musl-aarch64_CCFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_linux -Os -fPIC -fvisibility=hidden -std=gnu11 -march=armv8-a
Linux-Musl-aarch64_LINKFLAGS := -shared -static-libgcc
Linux-Musl-aarch64_LIBNAME := libsqlitejdbc.so
Linux-Musl-aarch64_SQLITE_FLAGS :=
Linux-Android-arm_CC := $(CROSS_PREFIX)clang
Linux-Android-arm_STRIP := $(CROSS_ROOT)/bin/llvm-strip
Linux-Android-arm_CCFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_linux -I$(CROSS_ROOT)/sysroot/usr/include -Os -fPIC -fvisibility=hidden -fPIE -pie -lm -lc -landroid -ldl -llog
Linux-Android-arm_LINKFLAGS := $(Default_LINKFLAGS) -Wl,-soname,libsqlitejdbc.so
Linux-Android-arm_LIBNAME := libsqlitejdbc.so
Linux-Android-arm_SQLITE_FLAGS :=
Linux-Android-aarch64_CC := $(CROSS_PREFIX)clang
Linux-Android-aarch64_STRIP := $(CROSS_ROOT)/bin/llvm-strip
Linux-Android-aarch64_CCFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_linux -I$(CROSS_ROOT)/sysroot/usr/include -Os -fPIC -fvisibility=hidden -fPIE -pie -lm -lc -landroid -ldl -llog
Linux-Android-aarch64_LINKFLAGS := $(Default_LINKFLAGS) -Wl,-soname,libsqlitejdbc.so
Linux-Android-aarch64_LIBNAME := libsqlitejdbc.so
Linux-Android-aarch64_SQLITE_FLAGS :=
Linux-Android-x86_CC := $(CROSS_PREFIX)clang
Linux-Android-x86_STRIP := $(CROSS_ROOT)/bin/llvm-strip
Linux-Android-x86_CCFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_linux -I$(CROSS_ROOT)/sysroot/usr/include -Os -fPIC -fvisibility=hidden -fPIE -pie -lm -lc -landroid -ldl -llog -msse4.2 -maes
Linux-Android-x86_LINKFLAGS := $(Default_LINKFLAGS) -Wl,-soname,libsqlitejdbc.so
Linux-Android-x86_LIBNAME := libsqlitejdbc.so
Linux-Android-x86_SQLITE_FLAGS :=
Linux-Android-x86_64_CC := $(CROSS_PREFIX)clang
Linux-Android-x86_64_STRIP := $(CROSS_ROOT)/bin/llvm-strip
Linux-Android-x86_64_CCFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_linux -I$(CROSS_ROOT)/sysroot/usr/include -Os -fPIC -fvisibility=hidden -fPIE -pie -lm -lc -landroid -ldl -llog -msse4.2 -maes
Linux-Android-x86_64_LINKFLAGS := $(Default_LINKFLAGS) -Wl,-soname,libsqlitejdbc.so
Linux-Android-x86_64_LIBNAME := libsqlitejdbc.so
Linux-Android-x86_64_SQLITE_FLAGS :=
Linux-ppc64_CC := $(CROSS_PREFIX)gcc
Linux-ppc64_STRIP := $(CROSS_PREFIX)strip
Linux-ppc64_CCFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_linux -Os -fPIC -fvisibility=hidden -std=gnu11
Linux-ppc64_LINKFLAGS := $(Default_LINKFLAGS)
Linux-ppc64_LIBNAME := libsqlitejdbc.so
Linux-ppc64_SQLITE_FLAGS :=
Linux-riscv64_CC := $(CROSS_PREFIX)gcc
Linux-riscv64_STRIP := $(CROSS_PREFIX)strip
Linux-riscv64_CCFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_linux -Os -fPIC -fvisibility=hidden
Linux-riscv64_LINKFLAGS := $(Default_LINKFLAGS)
Linux-riscv64_LIBNAME := libsqlitejdbc.so
Linux-riscv64_SQLITE_FLAGS :=
DragonFly-x86_64_CC := $(CROSS_PREFIX)cc
DragonFly-x86_64_STRIP := $(CROSS_PREFIX)strip
DragonFly-x86_64_CCFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_linux -O2 -fPIC -fvisibility=hidden
DragonFly-x86_64_LINKFLAGS := -shared
DragonFly-x86_64_LIBNAME := libsqlitejdbc.so
DragonFly-x86_64_SQLITE_FLAGS :=
FreeBSD-x86_CC := $(CROSS_PREFIX)clang
FreeBSD-x86_STRIP := $(CROSS_PREFIX)strip
FreeBSD-x86_CCFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_linux -Os -fPIC -fvisibility=hidden -msse4.2 -maes
FreeBSD-x86_LINKFLAGS := -shared
FreeBSD-x86_LIBNAME := libsqlitejdbc.so
FreeBSD-x86_SQLITE_FLAGS :=
FreeBSD-x86_64_CC := $(CROSS_PREFIX)clang
FreeBSD-x86_64_STRIP := $(CROSS_PREFIX)strip
FreeBSD-x86_64_CCFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_linux -Os -fPIC -fvisibility=hidden -msse4.2 -maes
FreeBSD-x86_64_LINKFLAGS := -shared
FreeBSD-x86_64_LIBNAME := libsqlitejdbc.so
FreeBSD-x86_64_SQLITE_FLAGS :=
FreeBSD-aarch64_CC := $(CROSS_PREFIX)clang
FreeBSD-aarch64_STRIP := $(CROSS_PREFIX)strip
FreeBSD-aarch64_CCFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_linux -Os -fPIC -fvisibility=hidden
FreeBSD-aarch64_LINKFLAGS := -shared
FreeBSD-aarch64_LIBNAME := libsqlitejdbc.so
FreeBSD-aarch64_SQLITE_FLAGS :=
OpenBSD-x86_64_CC := $(CROSS_PREFIX)gcc
OpenBSD-x86_64_STRIP := $(CROSS_PREFIX)strip
OpenBSD-x86_64_CCFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_linux -Os -fPIC -fvisibility=hidden -msse4.2 -maes
OpenBSD-x86_64_LINKFLAGS := -shared
OpenBSD-x86_64_LIBNAME := libsqlitejdbc.so
OpenBSD-x86_64_SQLITE_FLAGS :=
SunOS-sparcv9_CC := $(CROSS_PREFIX)gcc
SunOS-sparcv9_STRIP := $(CROSS_PREFIX)strip
SunOS-sparcv9_CCFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_linux -O2s -fPIC -m64 -fvisibility=hidden -march=native
SunOS-sparcv9_LINKFLAGS := -shared -static-libgcc
SunOS-sparcv9_LIBNAME := libsqlitejdbc.so
SunOS-sparcv9_SQLITE_FLAGS :=
Mac-x86_CC := gcc
Mac-x86_STRIP := strip -x
Mac-x86_CCFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_mac -Os -fPIC -mmacosx-version-min=10.4 -fvisibility=hidden -msse4.2 -maes
Mac-x86_LINKFLAGS := -dynamiclib
Mac-x86_LIBNAME := libsqlitejdbc.dylib
Mac-x86_SQLITE_FLAGS := -DSQLITE_ENABLE_LOCKING_STYLE=0
HPUX-ia64_32_CC := cc
HPUX-ia64_32_STRIP := strip
HPUX-ia64_32_CCFLAGS := -Ilib/inc_linux +Osize +z -Bhidden -march=native
HPUX-ia64_32_LINKFLAGS := -b
HPUX-ia64_32_LIBNAME := libsqlitejdbc.so
HPUX-ia64_32_SQLITE_FLAGS :=
Mac-x86_64_CC := gcc -arch $(OS_ARCH)
Mac-x86_64_STRIP := strip -x
MAC_SDK := /Developer/SDKs/MacOSX10.10.sdk
ifeq ($(wildcard MAC_SDK),)
MAC_SDK := /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk
endif
Mac-x86_64_CCFLAGS := -I$(MAC_SDK)/System/Library/Frameworks/JavaVM.framework/Headers -Ilib/inc_mac -Os -fPIC -mmacosx-version-min=10.6 -fvisibility=hidden -msse4.2 -maes -Wno-implicit-function-declaration
Mac-x86_64_LINKFLAGS := -dynamiclib -framework Security
Mac-x86_64_LIBNAME := libsqlitejdbc.dylib
Mac-x86_64_SQLITE_FLAGS :=
# Use a CROSS_PREFIX as the cross-triple clang is not available in crossbuild, see https://github.com/multiarch/crossbuild/blob/ad79cc84b6fb3fb1d09bc4a78719ef26f23bab85/Dockerfile#L134
# When running on a M1 mac, CROSS_PREFIX will be empty, and 'make native' can still build
Mac-aarch64_CC := $(CROSS_PREFIX)clang
Mac-aarch64_STRIP := $(CROSS_PREFIX)strip -x
MAC_SDK := /usr/osxcross/SDK/MacOSX11.3.sdk
Mac-aarch64_CCFLAGS := -I$(MAC_SDK)/System/Library/Frameworks/JavaVM.framework/Headers -Ilib/inc_mac -Os -fPIC -mmacosx-version-min=10.9 -fvisibility=hidden -Wno-implicit-function-declaration
Mac-aarch64_LINKFLAGS := -dynamiclib -framework Security
Mac-aarch64_LIBNAME := libsqlitejdbc.dylib
Mac-aarch64_SQLITE_FLAGS :=
Windows-x86_CC := $(CROSS_PREFIX)gcc
Windows-x86_STRIP := $(CROSS_PREFIX)strip
Windows-x86_CCFLAGS := -D_JNI_IMPLEMENTATION_ -Ilib/inc_win -Os -msse4.2 -maes
Windows-x86_LINKFLAGS := -Wl,--kill-at -shared -static-libgcc
Windows-x86_LIBNAME := sqlitejdbc.dll
Windows-x86_SQLITE_FLAGS :=
Windows-x86_64_CC := $(CROSS_PREFIX)gcc
Windows-x86_64_STRIP := $(CROSS_PREFIX)strip
Windows-x86_64_CCFLAGS := -D_JNI_IMPLEMENTATION_ -Ilib/inc_win -Os -msse4.2 -maes
Windows-x86_64_LINKFLAGS := -Wl,--kill-at -shared -static-libgcc
Windows-x86_64_LIBNAME := sqlitejdbc.dll
Windows-x86_64_SQLITE_FLAGS :=
Windows-armv7_CC := $(CROSS_PREFIX)clang
Windows-armv7_STRIP := $(CROSS_PREFIX)strip
Windows-armv7_CCFLAGS := -D_JNI_IMPLEMENTATION_ -Ilib/inc_win -Os
Windows-armv7_LINKFLAGS := -Wl,--kill-at -shared -static-libgcc
Windows-armv7_LIBNAME := sqlitejdbc.dll
Windows-armv7_SQLITE_FLAGS :=
Windows-aarch64_CC := $(CROSS_PREFIX)clang
Windows-aarch64_STRIP := $(CROSS_PREFIX)strip
Windows-aarch64_CCFLAGS := -D_JNI_IMPLEMENTATION_ -Ilib/inc_win -Os
Windows-aarch64_LINKFLAGS := -Wl,--kill-at -shared -static-libgcc
Windows-aarch64_LIBNAME := sqlitejdbc.dll
Windows-aarch64_SQLITE_FLAGS :=
CC := $($(target)_CC)
STRIP := $($(target)_STRIP)
CCFLAGS := $($(target)_CCFLAGS)
LINKFLAGS := $($(target)_LINKFLAGS)
LIBNAME := $($(target)_LIBNAME)
SQLITE_FLAGS := $($(target)_SQLITE_FLAGS)
SQLITE_AMAL_PREFIX = sqlite-amalgamation-$(shell ./amalgamation_version.sh $(version))
SQLITE_OLD_AMAL_PREFIX = sqlite-amalgamation-$(subst .,_,$(version))
CCFLAGS := $(CCFLAGS)
ifneq ($(jni_include),)
CCFLAGS := $(CCFLAGS) -I"$(jni_include)"
endif
ifneq ($(jni_md_include),)
CCFLAGS := $(CCFLAGS) -I"$(jni_md_include)"
endif