forked from gstf/libspatialite-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
110 lines (93 loc) · 4.2 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
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`; \
${IOS_PLATFORM_DEVELOPER}/usr/bin/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 \
-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
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 -Wno-error=implicit-function-declaration
CXXFLAGS = -stdlib=libc++ -std=c++11 -isysroot ${IOS_SDK} -I${IOS_SDK}/usr/include -arch ${ARCH} -I${INCLUDEDIR} -miphoneos-version-min=7.0 -Wno-error=implicit-function-declaration
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}" \
CXXFLAGS="${CXXFLAGS}" \
LDFLAGS="${LDFLAGS} -liconv -lgeos -lgeos_c -lc++" ./configure --host=${HOST} --disable-freexl --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.2.1-rc1.tar.gz > spatialite.tar.gz
tar -xzf spatialite.tar.gz
rm spatialite.tar.gz
mv libspatialite-4.2.1-rc1 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 http://download.osgeo.org/proj/proj-4.8.0.tar.gz > proj.tar.gz
tar -xzf proj.tar.gz
rm proj.tar.gz
mv proj-4.8.0 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.4.2.tar.bz2 > geos.tar.bz2
tar -xzf geos.tar.bz2
rm geos.tar.bz2
mv geos-3.4.2 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://sqlite.org/2013/sqlite-autoconf-3080100.tar.gz > sqlite3.tar.gz
tar xzvf sqlite3.tar.gz
rm sqlite3.tar.gz
mv sqlite-autoconf-3080100 sqlite3
touch sqlite3
clean:
rm -rf build geos proj spatialite sqlite3 include lib