+dnl ---------------------------------------------------------------------------
+dnl Find the required GDAL libraries, and include files.
+dnl ---------------------------------------------------------------------------
+
+AC_ARG_WITH(gdal,[ --with-gdal[[=DIR]] path to GDAL build tree],,)
+
+if test "$with_gdal" != "" ; then
+ GDAL_HOME=$with_gdal
+ echo Using requested GDAL_HOME of $GDAL_HOME
+elif test "$GDAL_HOME" != "" ; then
+ echo Using predefined GDAL_HOME=$GDAL_HOME
+elif test -d ../gdal ; then
+ GDAL_HOME=`pwd`/../gdal
+ echo Found local GDAL_HOME=$GDAL_HOME
+else
+ AC_CHECK_LIB(gdal.1.1,GDALOpen,gdal_found=1,gdal_found=0)
+
+gdal_missing_msg="
+fGIS requires GDAL 1.1, but libgdal.1.1.so was not found. Please download
+and install it. See http://www.remotesensing.org/gdal/
+"
+
+ if test "$gdal_found" != "1" ; then
+ AC_MSG_ERROR([$gdal_missing_msg])
+ fi
+
+gdal_h_missing_msg="
+fGIS requires GDAL 1.1, but gdal.h was not found. Please ensure GDAL,
+and the development include files are installed, or that you run configure
+with --with-gdal=path_to_gdal_build_tree.
+See http://www.remotesensing.org/gdal/
+"
+
+ AC_CHECK_HEADERS(gdal.h)
+ if test "$ac_cv_header_gdal_h" != "yes" ; then
+ AC_MSG_ERROR([$gdal_h_missing_msg])
+ fi
+ GDAL_LIB="-lgdal.1.1"
+ LIBS="$GDAL_LIB $LIBS"
+ GDAL_INC=""
+ AC_SUBST(GDAL_INC,$GDAL_INC)
+fi
+
+if test "$GDAL_HOME" != "" ; then
+ GDAL_LIB="-L$GDAL_HOME -lgdal.1.1"
+ LIBS="$GDAL_LIB $LIBS"
+
+ GDAL_INC="-I$GDAL_HOME/port -I$GDAL_HOME/core -I$GDAL_HOME/ogr"
+
+ if test ! -d $GDAL_HOME/core ; then
+
+ AC_MSG_ERROR([Unable to find $GDAL_HOME/core directory, are you sure a
+regular GDAL build tree can be found at $GDAL_HOME?])
+ fi
+
+ if test ! -f $GDAL_HOME/libgdal.1.1.so ; then
+
+ AC_MSG_ERROR([Unable to find $GDAL_HOME/libgdal.1.1.so, are you sure a
+regular GDAL build tree can be found at $GDAL_HOME?])
+ fi
+
+ AC_SUBST(GDAL_INC,$GDAL_INC)
+fi
+