-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathMakefile.common
executable file
·188 lines (156 loc) · 6.66 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
include VERSION
ifndef JAVA_HOME
$(error Set JAVA_HOME environment variable)
endif
libjdbc := $(wildcard lib/jdbc-*.jar)
JAVA := "$$JAVA_HOME/bin/java"
JAVAC := "$$JAVA_HOME/bin/javac"
JAVAH := "$$JAVA_HOME/bin/javah"
TARGET := target
OSINFO_CLASS := org.spatialite.util.OSInfo
OSINFO_PROG := lib/org/spatialite/util/OSInfo.class
## building OSInfo.java
#$(info compiling OSInfo.java)
#$(shell mkdir -p lib)
#$(shell $(JAVAC) src/main/java/org/spatialite/OSInfo.java -d lib)
OS_NAME := $(shell $(JAVA) -cp lib $(OSINFO_CLASS) --os)
OS_ARCH := $(shell $(JAVA) -cp lib $(OSINFO_CLASS) --arch)
LIB_FOLDER := $(shell $(JAVA) -cp lib $(OSINFO_CLASS))
# Windows uses different path separators, because they hate me
ifeq ($(OS_NAME),Windows)
sep := ;
else
sep := :
endif
sqlite := sqlite-$(version)
jni_md := $(shell find -L "$(JAVA_HOME)" -name jni_md.h)
ifneq ($(jni_md),)
jni_include := $(shell dirname "$(jni_md)")
endif
# os=Default is meant to be generic unix/linux
known_targets := Linux-i386 Linux-amd64 Linux-arm Mac-i386 Mac-x86_64 FreeBSD-amd64 OpenBSD-amd64 Windows-x86 Windows-amd64 SunOS-sparcv9
target := $(OS_NAME)-$(OS_ARCH)
ifeq (,$(findstring $(strip $(target)),$(known_targets)))
target := Default
endif
Default_CC := gcc
Default_STRIP := strip
Default_CFLAGS := -I$(JAVA_HOME)/include -Ispatialitejdbc/lib/inc_linux -Os -fPIC -fvisibility=hidden
Default_LINKFLAGS := -shared
Default_LIBNAME := libspatialitejdbc.so
Default_SQLITE_FLAGS :=
Linux-i386_CC := gcc
Linux-i386_STRIP := strip
Linux-i386_CFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_linux -O2 -fPIC -m32 -fvisibility=hidden
Linux-i386_LINKFLAGS := -shared -static-libgcc
Linux-i386_LIBNAME := libspatialitejdbc.so
Linux-i386_SQLITE_FLAGS :=
Linux-amd64_CC := gcc
Linux-amd64_STRIP := strip
Linux-amd64_CFLAGS := -Ilib/inc_linux -I$(JAVA_HOME)/include -O2 -fPIC -m64 -fvisibility=hidden
Linux-amd64_LINKFLAGS := -shared -static-libgcc
Linux-amd64_LIBNAME := libspatialitejdbc.so
Linux-amd64_SQLITE_FLAGS :=
Linux-arm_CC := gcc
Linux-arm_STRIP := strip
Linux-arm_CFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_linux -O2 -mfloat-abi=hard -mfpu=vfp -fPIC -fvisibility=hidden
Linux-arm_LINKFLAGS := -shared -static-libgcc
Linux-arm_LIBNAME := libsqlitejdbc.so
Linux-arm_SQLITE_FLAGS :=
FreeBSD-amd64_CC := cc
FreeBSD-amd64_STRIP := strip
FreeBSD-amd64_CFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_linux -O2 -fPIC -fvisibility=hidden
FreeBSD-amd64_LINKFLAGS := -shared
FreeBSD-amd64_LIBNAME := libsqlitejdbc.so
FreeBSD-amd64_SQLITE_FLAGS :=
OpenBSD-amd64_CC := gcc
OpenBSD-amd64_STRIP := strip
OpenBSD-amd64_CFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_linux -O2 -fPIC -fvisibility=hidden
OpenBSD-amd64_LINKFLAGS := -shared
OpenBSD-amd64_LIBNAME := libspatialitejdbc.so
OpenBSD-amd64_SQLITE_FLAGS :=
SunOS-sparcv9_CC := gcc
SunOS-sparcv9_STRIP := strip
SunOS-sparcv9_CFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_linux -O2 -fPIC -m64 -fvisibility=hidden
SunOS-sparcv9_LINKFLAGS := -shared -static-libgcc
SunOS-sparcv9_LIBNAME := libspatialitejdbc.so
SunOS-sparcv9_SQLITE_FLAGS :=
# Check for JNI location on OS X. First is old
ifneq ($(wildcard $(JAVA_HOME)/include),)
MAC_JNI_HOME = $(JAVA_HOME)/include
else
MAC_JNI_HOME = $(MAC_SDK)/System/Library/Frameworks/JavaVM.framework/Headers
endif
Mac-i386_CC := gcc -arch $(OS_ARCH)
Mac-i386_STRIP := strip -x
Mac-i386_CFLAGS := -I$(MAC_JNI_HOME) -O2 -fPIC -mmacosx-version-min=10.4 -fvisibility=hidden
Mac-i386_LINKFLAGS := -dynamiclib
Mac-i386_LIBNAME := libspatialitejdbc.jnilib
Mac-i386_SQLITE_FLAGS := -DSQLITE_ENABLE_LOCKING_STYLE=0
Mac-x86_64_CC := clang -arch $(OS_ARCH)
Mac-x86_64_STRIP := strip -x
MAC_SDK := /Developer/SDKs/MacOSX10.7.sdk
ifeq ($(wildcard MAC_SDK),)
MAC_SDK := /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk
endif
Mac-x86_64_CFLAGS := -I$(MAC_JNI_HOME) -O2 -fPIC -mmacosx-version-min=10.9 -fvisibility=hidden
Mac-x86_64_LINKFLAGS := -dynamiclib
Mac-x86_64_LIBNAME := libspatialitejdbc.jnilib
Mac-x86_64_SQLITE_FLAGS :=
Windows-x86_CC := i686-w64-mingw32-gcc
Windows-x86_STRIP := strip
Windows-x86_CFLAGS := -D_JNI_IMPLEMENTATION_ -Ilib/inc_win -O2
Windows-x86_LINKFLAGS := -Wl,--kill-at -shared
Windows-x86_LIBNAME := spatialitejdbc.dll
Windows-x86_SQLITE_FLAGS :=
Windows-amd64_CC := x86_64-w64-mingw32-gcc
Windows-amd64_STRIP := x86_64-w64-mingw32-strip
Windows-amd64_CFLAGS := -D_JNI_IMPLEMENTATION_ -Ilib/inc_win -O2
Windows-amd64_LINKFLAGS := -Wl,--kill-at -shared
Windows-amd64_LIBNAME := spatialitejdbc.dll
Windows-amd64_SQLITE_FLAGS :=
CC := $($(target)_CC)
STRIP := $($(target)_STRIP)
CFLAGS := $($(target)_CFLAGS)
LINKFLAGS := $($(target)_LINKFLAGS)
LIBNAME := $($(target)_LIBNAME)
SQLITE_FLAGS := $($(target)_SQLITE_FLAGS)
SQLITE_AMAL_PREFIX = sqlite-amalgamation-$(shell ./amalgamation_version.sh $(version))
CFLAGS := $(CFLAGS)
ifneq ($(jni_include),)
CFLAGS := $(CFLAGS) -I"$(jni_include)"
endif
# todo: set correct configure and linker flags for i386 arch below
#OS X build flags: http://www.kyngchaos.com/macosx/build/geos
PROJ_CONFIG_FLAGS = --with-pic
LIBXML2_CONFIG_FLAGS = --with-pic
LZMA_CONFIG_FLAGS = --with-pic
ICONV_CONFIG_FLAGS = --with-pic --enable-static
SPATIALITE_CONFIG_FLAGS = --with-pic --enable-freexl=no --enable-proj=yes --enable-geos=yes --enable-lwgeom=no
SPATIALITE_FLAGS = $(SPATIALITE_DIR)/src/.libs/libspatialite.a $(GEOS_DIR)/capi/.libs/libgeos_c.a $(GEOS_DIR)/src/.libs/libgeos.a $(PROJ_DIR)/src/.libs/libproj.a $(LIBXML2_DIR)/.libs/libxml2.a $(ZLIB_DIR)/libz.a $(LZMA_DIR)/src/sdk/7zip/Compress/LZMA/libLZMA.a $(ICONV_DIR)/lib/.libs/libiconv.a $(SPATIALITE_DIR)/src/virtualtext/.libs/libvirtualtext.a -lstdc++
# Note: GEOS is picky about the compiler, at least on OS X. We force to use clang on OS X to make it work, otherwise it's configure script will fail.
ifeq ($(OS_NAME),Windows)
NATIVE_DLL = win32
GEOS_CONFIG_FLAGS = --with-pic
GEOS_FORCE_COMPILERS =
else ifeq ($(OS_NAME),Linux)
NEED_ICONV_GLIBC_PATCH=true
GEOS_CONFIG_FLAGS = --with-pic
GEOS_FORCE_COMPILERS =
ifeq ($(target),Linux-arm)
NATIVE_DLL = linuxarm
else ifeq ($(target),Linux-amd64)
NATIVE_DLL = linux64
else
NATIVE_DLL = linux32
endif
else ifeq ($(OS_NAME),Mac)
GEOS_CONFIG_FLAGS = --with-pic --disable-dependency-tracking CFLAGS="-Os -arch i386 -arch x86_64" CXXFLAGS="-Os -arch i386 -arch x86_64" LDFLAGS="-arch i386 -arch x86_64"
ifeq ($(target),Mac-x86_64)
NATIVE_DLL = mac64
GEOS_FORCE_COMPILERS = CC=clang CXX=clang++
else
NATIVE_DLL = mac32
GEOS_FORCE_COMPILERS =
endif
endif