# find SAGA install or src root directory, and setup so that configure # and make scripts depending on SAGA can function with either one. AC_DEFUN([AX_SAGA_CONFIG], [ AC_LANG(C++) CONFPWD=`pwd` CONFDIR=`pwd`/config/ AC_SUBST(CONFPWD) AC_SUBST(CONFDIR) AC_ARG_VAR([SAGA_ROOT],[SAGA source tree root]) AC_ARG_VAR([SAGA_LOCATION],[SAGA installation root]) TMP_SAGA_LOCATION="" TMP_SAGA_INSTTYPE="" # check saga-config AC_PATH_PROG([SAGA_CONFIG], [saga-config]) AC_MSG_CHECKING([SAGA installation/sources]) if test "x$SAGA_CONFIG" != "x"; then TMP_SAGA_LOCATION=`$SAGA_CONFIG --prefix` TMP_SAGA_INSTTYPE="install" fi # check SAGA_LOCATION - prefer over saga-config if test "x$SAGA_LOCATION" != "x"; then TMP_SAGA_LOCATION=$SAGA_LOCATION TMP_SAGA_INSTTYPE="install" fi # check SAGA_ROOT - prefer over SAGA_LOCATION and saga-config if test "x$SAGA_ROOT" = "x"; then # try ./, ../ and ../../ as SAGA_ROOT if test -e ./make/saga.mk; then SAGA_ROOT=`pwd` fi if test -e ../make/saga.mk; then SAGA_ROOT=`pwd`/.. fi if test -e ../../make/saga.mk; then SAGA_ROOT=`pwd`/../../ fi if test -e ../../../make/saga.mk; then SAGA_ROOT=`pwd`/../../../ fi fi if test "x$SAGA_ROOT" != "x"; then TMP_SAGA_LOCATION=$SAGA_ROOT TMP_SAGA_INSTTYPE="source" fi # found anything? if test "x$TMP_SAGA_LOCATION" = "x"; then AC_MSG_ERROR([Could find neither SAGA source tree nor installation.]) fi AC_MSG_RESULT([$TMP_SAGA_LOCATION ($TMP_SAGA_INSTTYPE)]) AC_SUBST(TMP_SAGA_LOCATION) AC_SUBST(TMP_SAGA_INSTTYPE) # now, the adaptor and binding config files depend on the earlier findings of # the saga main configure. If those configures get run from within the main # configure, everything is known in the environment. If not, we have to pull # it. if test "x$TMP_SAGA_INSTTYPE" = "xsource"; then SAGA_CONFIG_DIR="$TMP_SAGA_LOCATION/config" else SAGA_CONFIG_DIR="$TMP_SAGA_LOCATION/share/saga/config" fi source "$SAGA_CONFIG_DIR/saga-config.cache" ])