-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
107 lines (73 loc) · 2.66 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
# use JDK1.5 to build native libraries
include Makefile.common
RESOURCE_DIR = src/main/resources
.phony: all package win32 mac32 linux32 native deploy
all: package
deploy:
mvn deploy
MVN:=mvn
SRC:=src/main/java
SQLITE_OUT:=$(TARGET)/$(sqlite)-$(OS_NAME)-$(OS_ARCH)
SQLITE_ARCHIVE:=$(TARGET)/$(sqlite)-amal.zip
SQLITE_UNPACKED:=$(TARGET)/sqlite-unpack.log
SQLITE_AMAL_DIR=$(TARGET)/$(SQLITE_AMAL_PREFIX)
SQLITE_ARCHIVE_SHA1:=ebe33c20d37a715db95288010c1009cd560f2452
CFLAGS:= -I$(SQLITE_OUT) -I$(SQLITE_AMAL_DIR) $(CFLAGS)
$(SQLITE_ARCHIVE):
@mkdir -p $(@D)
curl -o$@ http://www.sqlite.org/2017/$(SQLITE_AMAL_PREFIX).zip
$(SQLITE_UNPACKED): $(SQLITE_ARCHIVE)
[[ "$(SQLITE_ARCHIVE_SHA1)" == $$(sha1sum $< | cut -d' ' -f1) ]] || exit 1
unzip -qo $< -d $(TARGET)
touch $@
$(SQLITE_OUT)/org/sqlite/%.class: src/main/java/org/sqlite/%.java
@mkdir -p $(@D)
$(JAVAC) -source 1.8 -target 1.8 -sourcepath $(SRC) -d $(SQLITE_OUT) $<
jni-header: $(SRC)/org/sqlite/NativeDB.h
$(SQLITE_OUT)/NativeDB.h: $(SQLITE_OUT)/org/sqlite/NativeDB.class
$(JAVAH) -classpath $(SQLITE_OUT) -jni -o $@ org.sqlite.NativeDB
test:
mvn test
clean: clean-native clean-java clean-tests
$(SQLITE_OUT)/sqlite3.o : $(SQLITE_UNPACKED)
@mkdir -p $(@D)
$(CC) -o $@ -c $(CFLAGS) \
-DSQLITE_ENABLE_COLUMN_METADATA \
-DSQLITE_THREADSAFE=2 \
-DSQLITE_DEFAULT_MEMSTATUS=0 \
-DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 \
-DHAVE_USLEEP \
-DSQLITE_CORE \
$(SQLITE_FLAGS) \
$(SQLITE_AMAL_DIR)/sqlite3.c
$(SQLITE_OUT)/$(LIBNAME): $(SQLITE_OUT)/sqlite3.o $(SRC)/org/sqlite/NativeDB.c $(SQLITE_OUT)/NativeDB.h
@mkdir -p $(@D)
$(CC) $(CFLAGS) -c -o $(SQLITE_OUT)/NativeDB.o $(SRC)/org/sqlite/NativeDB.c
$(CC) $(CFLAGS) -o $@ $(SQLITE_OUT)/*.o $(LINKFLAGS)
$(STRIP) $@
NATIVE_DLL:=$(TARGET)/lib/$(OS_NAME)/$(OS_ARCH)/$(LIBNAME)
NATIVE_TARGET_DIR:=$(TARGET)/classes/org/sqlite/native/$(OS_NAME)/$(OS_ARCH)
native: $(SQLITE_UNPACKED) $(NATIVE_DLL)
$(NATIVE_DLL): $(SQLITE_OUT)/$(LIBNAME)
@mkdir -p $(@D)
cp $< $@
@mkdir -p $(NATIVE_TARGET_DIR)
cp $< $(NATIVE_TARGET_DIR)/$(LIBNAME)
win32:
$(MAKE) native CC=i686-w64-mingw32-gcc OS_NAME=Windows OS_ARCH=x86
linux32:
$(MAKE) native OS_NAME=Linux OS_ARCH=i386
sparcv9:
$(MAKE) native OS_NAME=SunOS OS_ARCH=sparcv9
mac32:
$(MAKE) native OS_NAME=Mac OS_ARCH=i386
package: $(NATIVE32_DLL) native
rm -rf target/dependency-maven-plugin-markers
$(MVN) package
clean-native:
rm -rf $(TARGET)/$(sqlite)-$(OS_NAME)*
clean-java:
rm -rf $(TARGET)/*classes
rm -rf $(TARGET)/sqlite-jdbc-*jar
clean-tests:
rm -rf $(TARGET)/{surefire*,testdb.jar*}