forked from Willena/sqlite-jdbc-crypt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
240 lines (183 loc) · 10.9 KB
/
Makefile
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
include Makefile.common
RESOURCE_DIR = src/main/resources
.phony: all package native native-all deploy
all: jni-header package
deploy:
mvn package deploy -DperformRelease=true --settings settings.xml
MVN:=mvn
SRC:=src/main/java
SQLITE_OUT:=$(TARGET)/$(sqlite)-$(OS_NAME)-$(OS_ARCH)
SQLITE_OBJ?=$(SQLITE_OUT)/sqlite3.o
SQLITE_ARCHIVE:=$(TARGET)/$(sqlite)-amal.zip
SQLITE_UNPACKED:=$(TARGET)/sqlite-unpack.log
SQLITE_SOURCE?=$(TARGET)/$(SQLITE_AMAL_PREFIX)
SQLITE_HEADER?=$(SQLITE_SOURCE)/sqlite3mc_amalgamation.h
ifneq ($(SQLITE_SOURCE),$(TARGET)/$(SQLITE_AMAL_PREFIX))
created := $(shell touch $(SQLITE_UNPACKED))
endif
SQLITE_INCLUDE := $(shell dirname "$(SQLITE_HEADER)")
CCFLAGS:= -I$(SQLITE_OUT) -I$(SQLITE_INCLUDE) $(CCFLAGS)
$(SQLITE_ARCHIVE):
echo "Downloading Archive"
#curl -s https://api.github.com/repos/utelle/SQLite3MultipleCiphers/releases | jq -r ".[].assets[] | select(.name | contains(\"$(version)-amalgamation\")) | .created_at |= fromdateiso8601 | .browser_download_url" | head -1 | wget -O $@ -i -
#wget -O $@ https://github.com/utelle/SQLite3MultipleCiphers/releases/download/v$(sqliteMCVersion)/sqlite3mc-$(sqliteMCVersion)-sqlite-$(version)-amalgamation.zip
curl -SL "https://github.com/utelle/SQLite3MultipleCiphers/releases/download/v$(sqliteMCVersion)/sqlite3mc-$(sqliteMCVersion)-sqlite-$(version)-amalgamation.zip" > $@
#if [ ! -d "$(TARGET)/$(version)" ] ; then git clone https://github.com/utelle/SQLite3MultipleCiphers.git $(TARGET)/$(version); cd $(TARGET)/$(version); fi
@mkdir -p $(@D)
$(SQLITE_UNPACKED): $(SQLITE_ARCHIVE)
unzip -qo $< -d $(TARGET)/$(version)
if [ -d "$(TARGET)/$(version)" ] ; then mv $(TARGET)/$(version) $(TARGET)/$(SQLITE_AMAL_PREFIX);fi
touch $@
$(TARGET)/common-lib/org/sqlite/%.class: src/main/java/org/sqlite/%.java
@mkdir -p $(@D)
$(JAVAC) -source 1.6 -target 1.6 -sourcepath $(SRC) -d $(TARGET)/common-lib $<
jni-header: $(TARGET)/common-lib/NativeDB.h
$(TARGET)/common-lib/NativeDB.h: src/main/java/org/sqlite/core/NativeDB.java
@mkdir -p $(TARGET)/common-lib
$(JAVAC) -d $(TARGET)/common-lib -sourcepath $(SRC) -h $(TARGET)/common-lib src/main/java/org/sqlite/core/NativeDB.java
mv target/common-lib/org_sqlite_core_NativeDB.h target/common-lib/NativeDB.h
test:
mvn test
clean: clean-target clean-native clean-java clean-tests
$(SQLITE_OUT)/sqlite3.o : $(SQLITE_UNPACKED)
@mkdir -p $(@D)
cp $(TARGET)/$(SQLITE_AMAL_PREFIX)/* $(SQLITE_OUT)/
# insert a code for loading extension functions
# perl -p -e "s/^opendb_out:/ if(!db->mallocFailed && rc==SQLITE_OK){ rc = RegisterExtensionFunctions(db); }\nopendb_out:/;" $(SQLITE_SOURCE)/sqlite3.c > $(SQLITE_OUT)/sqlite3.c.tmp
# register compile option 'JDBC_EXTENSIONS'
# perl -p -e "s/#if SQLITE_LIKE_DOESNT_MATCH_BLOBS/ \"JDBC_EXTENSIONS\",\n#if SQLITE_LIKE_DOESNT_MATCH_BLOBS/;" $(SQLITE_OUT)/sqlite3.c.tmp > $(SQLITE_OUT)/sqlite3.c
# cat src/main/ext/*.c >> $(SQLITE_OUT)/sqlite3.c
$(CC) -v
$(CC) -o $@ -c $(CCFLAGS) \
-DCODEC_TYPE=CODEC_TYPE_CHACHA20 \
-DSQLITE_THREADSAFE=1 \
-DSQLITE_DQS=0 \
-DSQLITE_MAX_ATTACHED=10 \
-DSQLITE_ENABLE_EXPLAIN_COMMENTS=1 \
-DSQLITE_SOUNDEX=1 \
-DSQLITE_ENABLE_COLUMN_METADATA=1 \
-DSQLITE_SECURE_DELETE=1 \
-DSQLITE_ENABLE_DESERIALIZE=1 \
-DSQLITE_ENABLE_FTS3=1 \
-DSQLITE_ENABLE_FTS3_PARENTHESIS=1 \
-DSQLITE_ENABLE_FTS4=1 \
-DSQLITE_ENABLE_FTS5=1 \
-DSQLITE_ENABLE_RTREE=1 \
-DSQLITE_ENABLE_GEOPOLY=1 \
-DSQLITE_CORE=1 \
-DSQLITE_ENABLE_EXTFUNC=1 \
-DSQLITE_ENABLE_CSV=1 \
-DSQLITE_ENABLE_SHA3 \
-DSQLITE_ENABLE_FILEIO \
-DSQLITE_ENABLE_CARRAY=1 \
-DSQLITE_ENABLE_SERIES=1 \
-DSQLITE_ENABLE_UUID=1 \
-DSQLITE_TEMP_STORE=2 \
-DSQLITE_USE_URI=1 \
-DSQLITE_USER_AUTHENTICATION=1 \
-DSQLITE_ENABLE_LOAD_EXTENSION=1 \
-DSQLITE_HAVE_ISNAN \
-DSQLITE_HAVE_USLEEP \
-DSQLITE_ENABLE_STAT2 \
-DSQLITE_DEFAULT_MEMSTATUS=0 \
-DSQLITE_DEFAULT_FILE_PERMISSIONS=0666 \
-DSQLITE_MAX_VARIABLE_NUMBER=250000 \
-DSQLITE_MAX_MMAP_SIZE=1099511627776 \
-DSQLITE_ENABLE_MATH_FUNCTIONS=1 \
-DSQLITE_ENABLE_REGEXP=1 \
-DSQLITE_ENABLE_VSV=1 \
-DSQLITE_MAX_LENGTH=2147483647 \
-DSQLITE_MAX_COLUMN=32767 \
-DSQLITE_MAX_SQL_LENGTH=1073741824 \
-DSQLITE_MAX_FUNCTION_ARG=127 \
-DSQLITE_MAX_ATTACHED=125 \
-DSQLITE_MAX_PAGE_COUNT=4294967294 \
-DNDEBUG \
$(SQLITE_FLAGS) \
$(SQLITE_OUT)/sqlite3mc_amalgamation.c
$(SQLITE_SOURCE)/sqlite3mc_amalgamation.h: $(SQLITE_UNPACKED)
$(SQLITE_OUT)/$(LIBNAME): $(SQLITE_HEADER) $(SQLITE_OBJ) $(SRC)/org/sqlite/core/NativeDB.c $(TARGET)/common-lib/NativeDB.h
@mkdir -p $(@D)
$(CC) $(CCFLAGS) -I $(TARGET)/common-lib -c -o $(SQLITE_OUT)/NativeDB.o $(SRC)/org/sqlite/core/NativeDB.c
$(CC) $(CCFLAGS) -o $@ $(SQLITE_OUT)/NativeDB.o $(SQLITE_OBJ) $(LINKFLAGS)
# Workaround for strip Protocol error when using VirtualBox on Mac
#cp $@ $(_TMP)/$(@F)
$(STRIP) $@
#cp $(_TMP)/$(@F) $@
NATIVE_DIR=src/main/resources/org/sqlite/native/$(OS_NAME)/$(OS_ARCH)
NATIVE_TARGET_DIR:=$(TARGET)/classes/org/sqlite/native/$(OS_NAME)/$(OS_ARCH)
NATIVE_DLL:=$(NATIVE_DIR)/$(LIBNAME)
# For cross-compilation, install docker. See also https://github.com/dockcross/dockcross
#native-all: native win32 win64 win-armv7 win-arm64 mac64 linux32 linux64 freebsd32 freebsd64 freebsd-arm64 linux-arm linux-armv6 linux-armv7 linux-arm64 linux-android-arm linux-android-arm64 linux-android-x86 linux-android-x64 linux-ppc64 alpine-linux64
native-all: native win32 win64 win-armv7 win-arm64 mac64 linux32 linux64 linux-arm linux-armv6 linux-armv7 linux-arm64 linux-android-arm linux-android-arm64 linux-android-x86 linux-android-x64 linux-ppc64 alpine-linux64
native: $(NATIVE_DLL)
$(NATIVE_DLL): $(SQLITE_OUT)/$(LIBNAME)
@mkdir -p $(@D)
cp $< $@
@mkdir -p $(NATIVE_TARGET_DIR)
cp $< $(NATIVE_TARGET_DIR)/$(LIBNAME)
DOCKER_RUN_OPTS=--rm
win32: $(SQLITE_UNPACKED) jni-header
./docker/dockcross-windows-x86 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=i686-w64-mingw32.static- OS_NAME=Windows OS_ARCH=x86'
win64: $(SQLITE_UNPACKED) jni-header
./docker/dockcross-windows-x64 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=x86_64-w64-mingw32.static- OS_NAME=Windows OS_ARCH=x86_64'
win-armv7: $(SQLITE_UNPACKED) jni-header
./docker/dockcross-windows-armv7 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=armv7-w64-mingw32- OS_NAME=Windows OS_ARCH=armv7'
win-arm64: $(SQLITE_UNPACKED) jni-header
./docker/dockcross-windows-arm64 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=aarch64-w64-mingw32- OS_NAME=Windows OS_ARCH=aarch64'
linux32: $(SQLITE_UNPACKED) jni-header
docker run $(DOCKER_RUN_OPTS) -v $$PWD:/work gillena/sqlite-build-env-i386 bash -c 'make clean-native native OS_NAME=Linux OS_ARCH=x86'
linux64: $(SQLITE_UNPACKED) jni-header
docker run $(DOCKER_RUN_OPTS) -v $$PWD:/work gillena/sqlite-build-env bash -c 'make clean-native native OS_NAME=Linux OS_ARCH=x86_64'
freebsd32: $(SQLITE_UNPACKED) jni-header
docker run $(DOCKER_RUN_OPTS) -v $$PWD:/workdir empterdose/freebsd-cross-build:9.3 sh -c 'apk add bash; apk add openjdk8; apk add perl; make clean-native native OS_NAME=FreeBSD OS_ARCH=x86 CROSS_PREFIX=i386-freebsd9-'
freebsd64: $(SQLITE_UNPACKED) jni-header
docker run $(DOCKER_RUN_OPTS) -v $$PWD:/workdir empterdose/freebsd-cross-build:9.3 sh -c 'apk add bash; apk add openjdk8; apk add perl; make clean-native native OS_NAME=FreeBSD OS_ARCH=x86_64 CROSS_PREFIX=x86_64-freebsd9-'
freebsd-arm64: $(SQLITE_UNPACKED) jni-header
docker run $(DOCKER_RUN_OPTS) -v $$PWD:/workdir gotson/freebsd-cross-build:aarch64-11.4 sh -c 'make clean-native native OS_NAME=FreeBSD OS_ARCH=aarch64 CROSS_PREFIX=aarch64-unknown-freebsd11-'
alpine-linux64: $(SQLITE_UNPACKED) jni-header
docker run $(DOCKER_RUN_OPTS) -v $$PWD:/work xerial/alpine-linux-x86_64 bash -c 'make clean-native native OS_NAME=Linux-Musl OS_ARCH=x86_64'
linux-arm: $(SQLITE_UNPACKED) jni-header
./docker/dockcross-armv5 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=armv5-unknown-linux-gnueabi- OS_NAME=Linux OS_ARCH=arm'
linux-armv6: $(SQLITE_UNPACKED) jni-header
./docker/dockcross-armv6 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=armv6-unknown-linux-gnueabihf- OS_NAME=Linux OS_ARCH=armv6'
linux-armv7: $(SQLITE_UNPACKED) jni-header
./docker/dockcross-armv7a -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=arm-cortexa8_neon-linux-gnueabihf- OS_NAME=Linux OS_ARCH=armv7'
linux-arm64: $(SQLITE_UNPACKED) jni-header
./docker/dockcross-arm64 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=aarch64-unknown-linux-gnu- OS_NAME=Linux OS_ARCH=aarch64'
linux-android-arm: $(SQLITE_UNPACKED) jni-header
./docker/dockcross-android-arm -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=/usr/arm-linux-androideabi/bin/arm-linux-androideabi- OS_NAME=Linux-Android OS_ARCH=arm'
linux-android-arm64: $(SQLITE_UNPACKED) jni-header
./docker/dockcross-android-arm64 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=/usr/aarch64-linux-android/bin/aarch64-linux-android- OS_NAME=Linux-Android OS_ARCH=aarch64'
linux-android-x86: $(SQLITE_UNPACKED) jni-header
./docker/dockcross-android-x86 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=/usr/i686-linux-android/bin/i686-linux-android- OS_NAME=Linux-Android OS_ARCH=x86'
linux-android-x64: $(SQLITE_UNPACKED) jni-header
./docker/dockcross-android-x86_64 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=/usr/x86_64-linux-android/bin/x86_64-linux-android- OS_NAME=Linux-Android OS_ARCH=x86_64'
linux-ppc64: $(SQLITE_UNPACKED) jni-header
./docker/dockcross-ppc64 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=powerpc64le-unknown-linux-gnu- OS_NAME=Linux OS_ARCH=ppc64'
mac64: $(SQLITE_UNPACKED) jni-header
docker run $(DOCKER_RUN_OPTS) -v $$PWD:/workdir -e CROSS_TRIPLE=x86_64-apple-darwin multiarch/crossbuild make clean-native native OS_NAME=Mac OS_ARCH=x86_64
# deprecated
mac32: $(SQLITE_UNPACKED) jni-header
docker run $(DOCKER_RUN_OPTS) -v $$PWD:/workdir -e CROSS_TRIPLE=i386-apple-darwin multiarch/crossbuild make clean-native native OS_NAME=Mac OS_ARCH=x86
sparcv9:
$(MAKE) native OS_NAME=SunOS OS_ARCH=sparcv9
package: native-all
rm -rf target/dependency-maven-plugin-markers
$(MVN) package
clean-native:
rm -rf $(SQLITE_OUT)
clean-java:
rm -rf $(TARGET)/*classes
rm -rf $(TARGET)/common-lib/*
rm -rf $(TARGET)/sqlite-jdbc-*jar
clean-tests:
rm -rf $(TARGET)/{surefire*,testdb.jar*}
clean-target:
rm -rf $(TARGET)/*
docker-linux64:
docker build -f docker/Dockerfile.linux_x86_64 -t xerial/centos5-linux-x86_64 .
docker-linux32:
docker build -f docker/Dockerfile.linux_x86 -t xerial/centos5-linux-x86 .
docker-alpine-linux64:
docker build -f docker/Dockerfile.alpine-linux_x86_64 -t xerial/alpine-linux-x86_64 .