Skip to content

Instantly share code, notes, and snippets.

@perrygeo
Created July 13, 2016 16:58
Show Gist options
  • Save perrygeo/032ef941047944006f04e18b3799c4d1 to your computer and use it in GitHub Desktop.
Save perrygeo/032ef941047944006f04e18b3799c4d1 to your computer and use it in GitHub Desktop.
Install multiple gdal versions to /usr/local/gdal/
#!/bin/bash
set -ex
GDALBUILD="$(realpath `dirname $BASH_SOURCE`)/build"
GDALINST="/usr/local/gdal"
CPUS=4
GDALOPTS=" --with-webp=yes \
--with-geos=/usr/local/bin/geos-config \
--with-static-proj4=/usr/local \
--with-curl"
# Create dirs if not existing
if [ ! -d "$GDALBUILD" ]; then
mkdir $GDALBUILD;
fi
if [ ! -d "$GDALINST" ]; then
mkdir $GDALINST;
fi
# download gdal versions
cd $GDALBUILD
if [ ! -d gdal-1.9.2 ]; then
wget http://download.osgeo.org/gdal/gdal-1.9.2.tar.gz
tar -xzf gdal-1.9.2.tar.gz
fi
if [ ! -d gdal-1.10.1 ]; then
wget http://download.osgeo.org/gdal/1.10.1/gdal-1.10.1.tar.gz
tar -xzf gdal-1.10.1.tar.gz
fi
if [ ! -d gdal-1.11.5 ]; then
wget http://download.osgeo.org/gdal/1.11.5/gdal-1.11.5.tar.gz
tar -xzf gdal-1.11.5.tar.gz
fi
if [ ! -d gdal-2.0.3 ]; then
wget http://download.osgeo.org/gdal/2.0.3/gdal-2.0.3.tar.gz
tar -xzf gdal-2.0.3.tar.gz
fi
if [ ! -d gdal-2.1.1 ]; then
wget http://download.osgeo.org/gdal/2.1.1/gdal-2.1.1.tar.gz
tar -xzf gdal-2.1.1.tar.gz
fi
# Install
if [ ! -d $GDALINST/gdal-1.9.2 ]; then
cd $GDALBUILD/gdal-1.9.2
./configure --prefix=$GDALINST/gdal-1.9.2 $GDALOPTS
make -s -j $CPUS
make install
fi
if [ ! -d $GDALINST/gdal-1.10.1 ]; then
cd $GDALBUILD/gdal-1.10.1
./configure --prefix=$GDALINST/gdal-1.10.1 $GDALOPTS
make -s -j $CPUS
make install
fi
if [ ! -d $GDALINST/gdal-1.11.5 ]; then
cd $GDALBUILD/gdal-1.11.5
./configure --prefix=$GDALINST/gdal-1.11.5 $GDALOPTS
make -s -j $CPUS
make install
fi
if [ ! -d $GDALINST/gdal-2.0.3 ]; then
cd $GDALBUILD/gdal-2.0.3
./configure --prefix=$GDALINST/gdal-2.0.3 $GDALOPTS
make -s -j $CPUS
make install
fi
if [ ! -d $GDALINST/gdal-2.1.1 ]; then
cd $GDALBUILD/gdal-2.1.1
./configure --prefix=$GDALINST/gdal-2.1.1 $GDALOPTS
make -s -j $CPUS
make install
fi
@perrygeo
Copy link
Author

To switch active GDAL version to ex: 2.1.1

export PATH=/usr/local/gdal/gdal-2.1.1:$PATH

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment