Skip to content

Commit 5d658b5

Browse files
author
Jesse Crocker
committed
Scripts that worked 5 years ago
1 parent 1456664 commit 5d658b5

File tree

2 files changed

+244
-0
lines changed

2 files changed

+244
-0
lines changed

build-gdal-combined-lib.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/bash
2+
PREFIX=`pwd`/install/
3+
rm -rf $PREFIX
4+
mkdir $PREFIX
5+
LOG=./log
6+
rm -rf $LOG
7+
mkdir $LOG
8+
9+
if [ -e ${PREFIX} ]
10+
then
11+
echo removing ${PREFIX}
12+
rm -rf ${PREFIX}
13+
fi
14+
15+
mkdir ${PREFIX}
16+
17+
for f in "armv7" "armv7s" "arm64"; do
18+
echo Building $f
19+
./build_gdal_ios.sh -p ${PREFIX} -a $f device 2>&1 | tee "${LOG}/${f}.txt"
20+
done
21+
22+
echo Building simulator
23+
for f in "i386" "x86_64"; do
24+
echo Building $f
25+
./build_gdal_ios.sh -p ${PREFIX} -a $f simulator 2>&1 | tee "${LOG}/simulator.txt"
26+
done
27+
28+
29+
SDK_VERSION=8.3
30+
31+
lipo \
32+
${PREFIX}/i386/iphonesimulator${SDK_VERSION}.sdk/lib/libgdal.a \
33+
${PREFIX}/x86_64/iphonesimulator${SDK_VERSION}.sdk/lib/libgdal.a \
34+
${PREFIX}/armv7/iphoneos${SDK_VERSION}.sdk/lib/libgdal.a \
35+
${PREFIX}/armv7s/iphoneos${SDK_VERSION}.sdk/lib/libgdal.a \
36+
${PREFIX}/arm64/iphoneos${SDK_VERSION}.sdk/lib/libgdal.a \
37+
-output ${PREFIX}/libgdal.a \
38+
-create | tee $LOG/lipo.txt
39+
40+
lipo \
41+
${PREFIX}/i386/iphonesimulator${SDK_VERSION}.sdk/lib/libproj.a \
42+
${PREFIX}/x86_64/iphonesimulator${SDK_VERSION}.sdk/lib/libproj.a \
43+
${PREFIX}/armv7/iphoneos${SDK_VERSION}.sdk/lib/libproj.a \
44+
${PREFIX}/armv7s/iphoneos${SDK_VERSION}.sdk/lib/libproj.a \
45+
${PREFIX}/arm64/iphoneos${SDK_VERSION}.sdk/lib/libproj.a \
46+
-output ${PREFIX}/libproj.a \
47+
-create | tee $LOG/lipo-proj.txt
48+
49+
#create zipfile for cocoapods distribution
50+
cd ${PREFIX}
51+
mkdir GDAL
52+
cp libgdal.a ${PREFIX}/libproj.a GDAL
53+
cp arm64/iphoneos8.3.sdk/include/*.h GDAL
54+
zip gdal.zip GDAL/*

build_gdal_ios.sh

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
#!/bin/bash
2+
set -u
3+
4+
default_iphoneos_version=8.3
5+
default_architecture=armv7
6+
7+
export IPHONEOS_DEPLOYMENT_TARGET="${IPHONEOS_DEPLOYMENT_TARGET:-$default_iphoneos_version}"
8+
DEFAULT_ARCHITECTURE="${DEFAULT_ARCHITECTURE:-$default_architecture}"
9+
DEFAULT_PREFIX="${HOME}/Desktop/iOS_GDAL"
10+
11+
12+
usage ()
13+
{
14+
cat >&2 << EOF
15+
Usage: ${0} [-h] [-p prefix] [-a arch] target [configure_args]
16+
-h Print help message
17+
-p Installation prefix (default: \$HOME/Documents/iOS_GDAL...)
18+
-a Architecture target for compilation (default: armv7)
19+
20+
The target must be "device" or "simulator". Any additional arguments
21+
are passed to configure.
22+
23+
The following environment variables affect the build process:
24+
25+
IPHONEOS_DEPLOYMENT_TARGET (default: $default_iphoneos_version)
26+
DEFAULT_PREFIX (default: $default_prefix)
27+
EOF
28+
}
29+
30+
prefix="${DEFAULT_PREFIX}"
31+
32+
while getopts ":hp:a:" opt; do
33+
case $opt in
34+
h ) usage ; exit 0 ;;
35+
p ) prefix="$OPTARG" ;;
36+
a ) DEFAULT_ARCHITECTURE="$OPTARG" ;;
37+
\? ) usage ; exit 2 ;;
38+
esac
39+
done
40+
shift $(( $OPTIND - 1 ))
41+
42+
if (( $# < 1 )); then
43+
usage
44+
exit 2
45+
fi
46+
47+
target=$1
48+
shift
49+
50+
case $target in
51+
52+
device )
53+
arch="${DEFAULT_ARCHITECTURE}"
54+
platform=iphoneos
55+
extra_cflags=" "
56+
;;
57+
58+
simulator )
59+
arch="${DEFAULT_ARCHITECTURE}"
60+
platform=iphonesimulator
61+
extra_cflags="-D__IPHONE_OS_VERSION_MIN_REQUIRED=${IPHONEOS_DEPLOYMENT_TARGET%%.*}0000"
62+
;;
63+
64+
* )
65+
echo No target found!!!
66+
usage
67+
exit 2
68+
69+
esac
70+
if [ $arch = "arm64" ]
71+
then
72+
host="arm-apple-darwin"
73+
else
74+
host="${arch}-apple-darwin"
75+
fi
76+
77+
echo "building for host ${host}"
78+
79+
platform_dir=`xcrun -find -sdk ${platform} --show-sdk-platform-path`
80+
platform_sdk_dir=`xcrun -find -sdk ${platform} --show-sdk-path`
81+
prefix="${prefix}/${arch}/${platform}${IPHONEOS_DEPLOYMENT_TARGET}.sdk"
82+
83+
echo
84+
echo library will be exported to $prefix
85+
86+
#setup compiler flags
87+
export CC=`xcrun -find -sdk iphoneos gcc`
88+
export CFLAGS="-Wno-error=implicit-function-declaration -arch ${arch} -pipe -Os -gdwarf-2 -isysroot ${platform_sdk_dir} ${extra_cflags}"
89+
export LDFLAGS="-arch ${arch} -isysroot ${platform_sdk_dir}"
90+
export CXX=`xcrun -find -sdk iphoneos g++`
91+
export CXXFLAGS="${CFLAGS}"
92+
export CPP=`xcrun -find -sdk iphoneos cpp`
93+
export CXXCPP="${CPP}"
94+
95+
echo CFLAGS ${CFLAGS}
96+
97+
#set proj4 install destination
98+
proj_prefix=$prefix
99+
echo install proj to $proj_prefix
100+
101+
#download proj4 if necesary
102+
if [ ! -e proj-4.8.0 ]
103+
then
104+
echo proj4 missing, downloading
105+
wget http://download.osgeo.org/proj/proj-4.8.0.tar.gz
106+
tar -xzf proj-4.8.0.tar.gz
107+
fi
108+
109+
#configure and build proj4
110+
pushd proj-4.8.0
111+
112+
echo
113+
echo "cleaning proj"
114+
make clean
115+
116+
echo
117+
echo "configure proj"
118+
./configure \
119+
--prefix=${proj_prefix} \
120+
--enable-shared=no \
121+
--enable-static=yes \
122+
--host=$host \
123+
"$@" || exit
124+
125+
echo
126+
echo "make install proj"
127+
time make install || exit
128+
129+
popd
130+
131+
#download gdal if necesary
132+
if [ ! -e gdal-1.11.2 ]
133+
then
134+
wget http://download.osgeo.org/gdal/1.11.0/gdal-1.11.2.tar.gz
135+
tar -xzf gdal-1.11.2.tar.gz
136+
fi
137+
138+
#configure and build gdal
139+
cd gdal-1.11.2
140+
141+
echo "cleaning gdal"
142+
make clean
143+
144+
echo
145+
echo "configure gdal"
146+
./configure \
147+
--prefix="${prefix}" \
148+
--host=$host \
149+
--disable-shared \
150+
--enable-static \
151+
--with-hide-internal-symbols \
152+
--with-unix-stdio-64=no \
153+
--with-geos=no \
154+
--without-pg \
155+
--without-grass \
156+
--without-libgrass \
157+
--without-cfitsio \
158+
--without-pcraster \
159+
--without-netcdf \
160+
--without-ogdi \
161+
--without-fme \
162+
--without-hdf4 \
163+
--without-hdf5 \
164+
--without-jasper \
165+
--without-kakadu \
166+
--without-grib \
167+
--without-mysql \
168+
--without-ingres \
169+
--without-xerces \
170+
--without-odbc \
171+
--without-curl \
172+
--without-idb \
173+
--without-sde \
174+
--with-sse=no \
175+
--with-avx=no \
176+
--with-static-proj4=${prefix} \
177+
--with-sqlite3=${platform_sdk_dir} \
178+
|| exit
179+
180+
#echo '#include "cpl_config_extras.h"' >> port/cpl_config.h
181+
182+
echo
183+
echo "building gdal"
184+
time make
185+
186+
echo
187+
echo "installing"
188+
time make install
189+
190+
echo "Gdal build complete"

0 commit comments

Comments
 (0)