If you build from source you can avoid the dependency on gdal
by using the --without-raster
option.
This means you can't use the 'CREATE EXTENSION postgis;' shortcut. more info
Prerequisites that I have listed:
apt-get install libgeos-3.4.2 libgeos-dev libxml2-dev
wget http://download.osgeo.org/proj/proj-4.9.2.tar.gz
tar xfvz proj-4.9.2.tar.gz
cd proj-4.9.2
./configure
make && make install
Postgis:
wget http://download.osgeo.org/postgis/source/postgis-2.1.8.tar.gz
tar xfvz postgis-2.1.8.tar.gz
cd postgis-2.1.8
./configure --with-pgconfig=/usr/lib/postgresql/9.4/bin/pg_config --without-raster
make && make install
Now there was a problem for me in that the postgis library can't see the proj library, as can be seen from the 'not found' when executing ldd /usr/lib/postgresql/9.4/lib/postgis-2.1.so
The solution was to softlink it:
ln /usr/local/lib/libproj.so.9.1.0 /usr/lib/libproj.so.9
Then you have to execute 'postgis.sql' against your database (and possibly others; see link to installation steps above)
psql -d yourdatabase -f /usr/share/postgresql/9.4/contrib/postgis-2.1/postgis.sql