forked from davenquinn/libspatialite-ios
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
116 lines (98 loc) · 4.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
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/arm64/include/geos include
cp -R build/arm64/include/spatialite include
cp -R build/arm64/include/*.h include
# Make fat libraries for all architectures
for file in build/arm64/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=9.0 -O3 -fembed-bitcode
CXXFLAGS = -stdlib=libc++ -std=c++11 -isysroot ${IOS_SDK} -I${IOS_SDK}/usr/include -arch ${ARCH} -I${INCLUDEDIR} -miphoneos-version-min=9.0 -O3 -fembed-bitcode
LDFLAGS = -stdlib=libc++ -isysroot ${IOS_SDK} -L${LIBDIR} -L${IOS_SDK}/usr/lib -arch ${ARCH} -miphoneos-version-min=9.0
LIBTOOL=${XCODE_DEVELOPER}/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool
arch: ${LIBDIR}/libspatialite.a
${LIBDIR}/libspatialite.a: ${LIBDIR}/libsqlite3.a ${LIBDIR}/libproj.a ${LIBDIR}/libgeos.a ${CURDIR}/spatialite
cd spatialite && env LIBTOOL=${LIBTOOL} \
CXX=${CXX} \
CC=${CC} \
CFLAGS="${CFLAGS} -Wno-error=implicit-function-declaration -DACCEPT_USE_OF_DEPRECATED_PROJ_API_H -I${INCLUDEDIR}" \
CXXFLAGS="${CXXFLAGS} -Wno-error=implicit-function-declaration -DACCEPT_USE_OF_DEPRECATED_PROJ_API_H -I${INCLUDEDIR}" \
LDFLAGS="${LDFLAGS} -liconv -lgeos -lgeos_c -lc++ -L${LIBDIR}" ./configure --host=${HOST} --enable-freexl=no --enable-libxml2=no --prefix=${PREFIX} --with-sysroot=${PREFIX} --with-geosconfig=${BINDIR}/geos-config --enable-static --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
./update-spatialite
./change-deployment-target spatialite
${LIBDIR}/libproj.a: ${CURDIR}/proj
cd proj && git clean -dfx && ./autogen.sh && env \
CXX=${CXX} \
CC=${CC} \
CFLAGS="${CFLAGS}" \
CXXFLAGS="${CXXFLAGS}" \
LDFLAGS="${LDFLAGS}" ./configure --host=${HOST} --prefix=${PREFIX} --without-curl --disable-tiff --enable-static --disable-shared && make clean install
${CURDIR}/proj:
git submodule init
git submodule update
${LIBDIR}/libgeos.a: ${CURDIR}/geos
cd geos && git clean -dfx && ./autogen.sh && env \
CXX=${CXX} \
CC=${CC} \
CFLAGS="${CFLAGS}" \
CXXFLAGS="${CXXFLAGS}" \
LDFLAGS="${LDFLAGS}" ./configure --host=${HOST} --prefix=${PREFIX} --disable-python --enable-static --disable-shared --disable-inline && make clean install
${CURDIR}/geos:
git submodule init
git submodule update
${LIBDIR}/libsqlite3.a: ${CURDIR}/sqlite3
cd sqlite3 && env LIBTOOL=${LIBTOOL} \
CXX=${CXX} \
CC=${CC} \
CFLAGS="${CFLAGS} -DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_MAX_VARIABLE_NUMBER=250000 -DSQLITE_THREADSAFE=1 -DSQLITE_ENABLE_RTREE=1 -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_FTS3_PARENTHESIS=1" \
CXXFLAGS="${CXXFLAGS} -DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_MAX_VARIABLE_NUMBER=250000 -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} \
--enable-dynamic-extensions --enable-static --disable-shared && make clean install-includeHEADERS install-libLTLIBRARIES
${CURDIR}/sqlite3:
curl https://www.sqlite.org/2020/sqlite-autoconf-3320300.tar.gz > sqlite3.tar.gz
tar xzvf sqlite3.tar.gz
rm sqlite3.tar.gz
mv sqlite-autoconf-3320300 sqlite3
./change-deployment-target sqlite3
touch sqlite3
package:
zip -r libspatialite-ios-release.zip lib include COPYING
clean:
rm -rf build spatialite include lib sqlite3
cd geos && git clean -dfx && cd ..
cd proj && git clean -dfx && cd ..