forked from xerial/sqlite-jdbc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.common
259 lines (218 loc) · 10.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
include VERSION
ifndef JAVA_HOME
$(warning Set JAVA_HOME environment variable)
endif
JAVA := "$$JAVA_HOME/bin/java"
JAVAC := "$$JAVA_HOME/bin/javac"
JAVAH := "$$JAVA_HOME/bin/javah"
TARGET := target
OSINFO_CLASS := org.sqlite.OSInfo
OSINFO_PROG := lib/org/sqlite/util/OSInfo.class
## building OSInfo.java
#$(info compiling OSInfo.java)
#$(shell mkdir -p lib)
#$(shell $(JAVAC) src/main/java/org/sqlite/util/OSInfo.java -d lib)
ifndef OS_NAME
OS_NAME := $(shell $(JAVA) -cp lib $(OSINFO_CLASS) --os)
endif
ifndef OS_ARCH
OS_ARCH := $(shell $(JAVA) -cp lib $(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 -L "$(JAVA_HOME)" -name jni.h)
ifneq ($(jni_h),)
jni_include := $(shell dirname "$(jni_h)")
endif
jni_md := $(shell find -L "$(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-arm Linux-armv6 Linux-armv7 Linux-Android-arm Linux-Android-aarch64 Linux-Android-x86 Linux-Android-x86_64 Linux-ppc64 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
# 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
Default_LINKFLAGS := -shared
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
Linux-x86_LINKFLAGS := -shared -static-libgcc
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
Linux-x86_64_LINKFLAGS := -shared -static-libgcc
Linux-x86_64_LIBNAME := libsqlitejdbc.so
Linux-x86_64_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=softfp -mfpu=vfp -fvisibility=hidden
Linux-arm_LINKFLAGS := -shared -static-libgcc
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
Linux-armv6_LINKFLAGS := -shared -static-libgcc
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
Linux-armv7_LINKFLAGS := -shared -static-libgcc
Linux-armv7_LIBNAME := libsqlitejdbc.so
Linux-armv7_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 := -shared -static-libgcc
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 := -shared -static-libgcc
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
Linux-Android-x86_LINKFLAGS := -shared -static-libgcc
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
Linux-Android-x86_64_LINKFLAGS := -shared -static-libgcc
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
Linux-ppc64_LINKFLAGS := -shared -static-libgcc
Linux-ppc64_LIBNAME := libsqlitejdbc.so
Linux-ppc64_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)gcc
FreeBSD-x86_STRIP := $(CROSS_PREFIX)strip
FreeBSD-x86_CCFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_linux -Os -fPIC -fvisibility=hidden
FreeBSD-x86_LINKFLAGS := -shared
FreeBSD-x86_LIBNAME := libsqlitejdbc.so
FreeBSD-x86_SQLITE_FLAGS :=
FreeBSD-x86_64_CC := $(CROSS_PREFIX)gcc
FreeBSD-x86_64_STRIP := $(CROSS_PREFIX)strip
FreeBSD-x86_64_CCFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_linux -Os -fPIC -fvisibility=hidden
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
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
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
Mac-x86_LINKFLAGS := -dynamiclib
Mac-x86_LIBNAME := libsqlitejdbc.jnilib
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
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 -Wno-implicit-function-declaration
Mac-x86_64_LINKFLAGS := -dynamiclib
Mac-x86_64_LIBNAME := libsqlitejdbc.jnilib
Mac-x86_64_SQLITE_FLAGS :=
Mac-aarch64_CC := gcc -arch arm64
Mac-aarch64_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-aarch64_CCFLAGS := -I$(MAC_SDK)/System/Library/Frameworks/JavaVM.framework/Headers -Ilib/inc_mac -Os -fPIC -mmacosx-version-min=10.6 -fvisibility=hidden -Wno-implicit-function-declaration
Mac-aarch64_LINKFLAGS := -dynamiclib
Mac-aarch64_LIBNAME := libsqlitejdbc.jnilib
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
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
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