-
Notifications
You must be signed in to change notification settings - Fork 48
/
Makefile
112 lines (95 loc) · 4.29 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
XCODE_DEVELOPER = $(shell xcode-select --print-path)
IOS_PLATFORM ?= iPhoneOS
# Pick latest SDK in the directory
IOS_PLATFORM_DEVELOPER = ${XCODE_DEVELOPER}/Platforms/${IOS_PLATFORM}.platform/Developer
IOS_SDK = ${IOS_PLATFORM_DEVELOPER}/SDKs/$(shell ls ${IOS_PLATFORM_DEVELOPER}/SDKs | sort -r | head -n1)
all: lib/libspatialite.a
lib/libspatialite.a: build_arches
mkdir -p lib
mkdir -p include
# Copy includes
cp -R build/armv7/include/geos include
cp -R build/armv7/include/spatialite include
cp -R build/armv7/include/*.h include
# Make fat libraries for all architectures
for file in build/armv7/lib/*.a; \
do name=`basename $$file .a`; \
lipo -create \
-arch armv7 build/armv7/lib/$$name.a \
-arch armv7s build/armv7s/lib/$$name.a \
-arch arm64 build/arm64/lib/$$name.a \
-arch i386 build/i386/lib/$$name.a \
-arch x86_64 build/x86_64/lib/$$name.a \
-output lib/$$name.a \
; \
done;
# Build separate architectures
build_arches:
${MAKE} arch ARCH=armv7 IOS_PLATFORM=iPhoneOS HOST=arm-apple-darwin
${MAKE} arch ARCH=armv7s IOS_PLATFORM=iPhoneOS HOST=arm-apple-darwin
${MAKE} arch ARCH=arm64 IOS_PLATFORM=iPhoneOS HOST=arm-apple-darwin
${MAKE} arch ARCH=i386 IOS_PLATFORM=iPhoneSimulator HOST=i386-apple-darwin
${MAKE} arch ARCH=x86_64 IOS_PLATFORM=iPhoneSimulator HOST=x86_64-apple-darwin
PREFIX = ${CURDIR}/build/${ARCH}
LIBDIR = ${PREFIX}/lib
BINDIR = ${PREFIX}/bin
INCLUDEDIR = ${PREFIX}/include
CXX = ${XCODE_DEVELOPER}/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
CC = ${XCODE_DEVELOPER}/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
CFLAGS = -isysroot ${IOS_SDK} -I${IOS_SDK}/usr/include -arch ${ARCH} -I${INCLUDEDIR} -miphoneos-version-min=7.0 -O3
CXXFLAGS = -stdlib=libc++ -std=c++11 -isysroot ${IOS_SDK} -I${IOS_SDK}/usr/include -arch ${ARCH} -I${INCLUDEDIR} -miphoneos-version-min=7.0 -O3
LDFLAGS = -stdlib=libc++ -isysroot ${IOS_SDK} -L${LIBDIR} -L${IOS_SDK}/usr/lib -arch ${ARCH} -miphoneos-version-min=7.0
arch: ${LIBDIR}/libspatialite.a
${LIBDIR}/libspatialite.a: ${LIBDIR}/libproj.a ${LIBDIR}/libgeos.a ${LIBDIR}/libsqlite3.a ${CURDIR}/spatialite
cd spatialite && env \
CXX=${CXX} \
CC=${CC} \
CFLAGS="${CFLAGS} -Wno-error=implicit-function-declaration" \
CXXFLAGS="${CXXFLAGS} -Wno-error=implicit-function-declaration" \
LDFLAGS="${LDFLAGS} -liconv -lgeos -lgeos_c -lc++" ./configure --host=${HOST} --enable-freexl=no --enable-libxml2=no --prefix=${PREFIX} --with-geosconfig=${BINDIR}/geos-config --disable-shared && make clean install-strip
${CURDIR}/spatialite:
curl http://www.gaia-gis.it/gaia-sins/libspatialite-sources/libspatialite-4.3.0a.tar.gz > spatialite.tar.gz
tar -xzf spatialite.tar.gz
rm spatialite.tar.gz
mv libspatialite-4.3.0a spatialite
patch -Np0 < spatialite.patch
${LIBDIR}/libproj.a: ${CURDIR}/proj
cd proj && env \
CXX=${CXX} \
CC=${CC} \
CFLAGS="${CFLAGS}" \
CXXFLAGS="${CXXFLAGS}" \
LDFLAGS="${LDFLAGS}" ./configure --host=${HOST} --prefix=${PREFIX} --disable-shared && make clean install
${CURDIR}/proj:
curl -L http://download.osgeo.org/proj/proj-4.9.3.tar.gz > proj.tar.gz
tar -xzf proj.tar.gz
rm proj.tar.gz
mv proj-4.9.3 proj
${LIBDIR}/libgeos.a: ${CURDIR}/geos
cd geos && env \
CXX=${CXX} \
CC=${CC} \
CFLAGS="${CFLAGS}" \
CXXFLAGS="${CXXFLAGS}" \
LDFLAGS="${LDFLAGS}" ./configure --host=${HOST} --prefix=${PREFIX} --disable-shared && make clean install
${CURDIR}/geos:
curl http://download.osgeo.org/geos/geos-3.6.1.tar.bz2 > geos.tar.bz2
tar -xzf geos.tar.bz2
rm geos.tar.bz2
mv geos-3.6.1 geos
${LIBDIR}/libsqlite3.a: ${CURDIR}/sqlite3
cd sqlite3 && env LIBTOOL=${XCODE_DEVELOPER}/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool \
CXX=${CXX} \
CC=${CC} \
CFLAGS="${CFLAGS} -DSQLITE_THREADSAFE=1 -DSQLITE_ENABLE_RTREE=1 -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_FTS3_PARENTHESIS=1" \
CXXFLAGS="${CXXFLAGS} -DSQLITE_THREADSAFE=1 -DSQLITE_ENABLE_RTREE=1 -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_FTS3_PARENTHESIS=1" \
LDFLAGS="-Wl,-arch -Wl,${ARCH} -arch_only ${ARCH} ${LDFLAGS}" \
./configure --host=${HOST} --prefix=${PREFIX} --disable-shared --enable-static && make clean install
${CURDIR}/sqlite3:
curl http://www.sqlite.org/2017/sqlite-autoconf-3170000.tar.gz > sqlite3.tar.gz
tar xzvf sqlite3.tar.gz
rm sqlite3.tar.gz
mv sqlite-autoconf-3170000 sqlite3
touch sqlite3
clean:
rm -rf build geos proj spatialite sqlite3 include lib