|
| 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