############################################################# # # find SAGA installation tree, and set some useful variables # # SAGA_LOCATION # SAGA_MAKE_DIR # = $SAGA_LOCATION/share/saga/make/ # SAGA_CONF_DIR # = $SAGA_LOCATION/share/saga/config/ # SAGA_INC_DIR # = $SAGA_LOCATION/include/ # SAGA_LIB_DIR # = $SAGA_LOCATION/lib/ # SAGA_BIN_DIR # = $SAGA_LOCATION/bin/ # SAGA_INI_DIR # = $SAGA_LOCATION/share/saga/ # SAGA_CONFIG # = $SAGA_BIN_DIR/saga-config # SAGA_VERSION # = `$SAGA_CONFIG --version` # SAGA_VERSION_MAJOR # SAGA_VERSION_MINOR # SAGA_VERSION_SUBMINOR # SAGA_PACKAGE_VERSION # = `grep 'Version' PACKAGE` # # This macro stays backward compatible to old versions, by defining # # SAGA_MAKE_INLUDE_ROOT # = $SAGA_MAKE_DIR # TMP_SAGA_LOCATION # = $SAGA_LOCATION # SAGA_LIB_VERSION # = $SAGA_PACKAGE_VERSION # # Thos vars are deprecated though, and may disappear in future versions. # AC_DEFUN([AX_SAGA_CONFIG], [ AC_LANG(C++) AC_ARG_VAR([SAGA_LOCATION],[SAGA installation root]) tmp_location="" AC_ARG_WITH([saga], AS_HELP_STRING([--with-saga=DIR], [use saga at DIR (optional)]), [ if test "$withval" = "no"; then AC_MSG_ERROR([SAGA is required]) elif test "$withval" = "yes"; then tmp_location="" else tmp_location="$withval" fi ], [tmp_location=""]) # try to find a valid SAGA_LOCATION amongst the possible candidates packages=`ls /usr/local/saga* /usr/local/package/saga* 2>>/dev/null` for tmp_path in $tmp_location $SAGA_LOCATION /usr /usr/local /opt /opt/local $packages; do AC_MSG_CHECKING(for saga in $tmp_path) # try to verify the prefix via "saga-config --prefix" SAGA_CONFIG=$tmp_path/bin/saga-config tmp=`$SAGA_CONFIG --prefix 2> /dev/null` if ! test "x$tmp" = "x"; then AC_MSG_RESULT([found (prefix: $tmp)]) TMP_SAGA_LOCATION=$tmp_path break else AC_MSG_RESULT([not found]) fi done # if the above did not yield a SAGA__LOCATION, try to find saga-config in # $PATH, and use the reported prefix if test "x$TMP_SAGA_LOCATION" = "x"; then SAGA_CONFIG="" AC_PATH_PROG([SAGA_CONFIG], [saga-config], []) if test "x$SAGA_CONFIG" != "x"; then AC_MSG_CHECKING([saga-config prefix]) if test "x$SAGA_CONFIG" != "x"; then TMP_SAGA_LOCATION=`$SAGA_CONFIG --prefix` AC_MSG_RESULT([$TMP_SAGA_LOCATION]) else AC_MSG_ERROR([invalid]) fi fi fi # if we have a usable SAGA_LOCATION, try to infer all required vars if ! test "x$TMP_SAGA_LOCATION" = "x"; then AC_MSG_CHECKING([saga version]) SAGA_VERSION=`$SAGA_CONFIG --version` SAGA_VERSION_MAJOR=`echo $SAGA_VERSION | cut -f 1 -d .` SAGA_VERSION_MINOR=`echo $SAGA_VERSION | cut -f 2 -d .` SAGA_VERSION_SUBMINOR=`echo $SAGA_VERSION | cut -f 3 -d .` if test "$SAGA_VERSION_SUBMINOR" == ""; then SAGA_VERSION_SUBMINOR=0 fi AC_SUBST(SAGA_VERSION) AC_SUBST(SAGA_VERSION_MAJOR) AC_SUBST(SAGA_VERSION_MINOR) AC_SUBST(SAGA_VERSION_SUBMINOR) export SAGA_VERSION export SAGA_VERSION_MAJOR export SAGA_VERSION_MINOR export SAGA_VERSION_SUBMINOR AC_MSG_RESULT([$SAGA_VERSION_MAJOR.$SAGA_VERSION_MINOR.$SAGA_VERSION_SUBMINOR]) fi # found anything? if test "x$TMP_SAGA_LOCATION" = "x"; then AC_MSG_ERROR([Couldn't find SAGA installation.]) fi # We set SAGA_LIB_VERSION to SAGA_VERSION by default. If a local PACKAGE file is # present though. for example for an adaptor, we use its version info instead. # A configure is of course still able to overrule that, AC_MSG_CHECKING([saga package version]) SAGA_PACKAGE_VERSION=$SAGA_VERSION test -f PACKAGE && SAGA_PACKAGE_VERSION=`grep -e '^VERSION:' PACKAGE | cut -f 2 -d ' '` AC_MSG_RESULT([$SAGA_PACKAGE_VERSION]) AC_SUBST(SAGA_PACKAGE_VERSION) export SAGA_PACKAGE_VERSION # we set SAGA_LOCATION, and a couple of other vars SAGA_LOCATION=$TMP_SAGA_LOCATION SAGA_MAKE_DIR=$SAGA_LOCATION/share/saga/make/ SAGA_CONF_DIR=$SAGA_LOCATION/share/saga/config/ SAGA_INC_DIR=$SAGA_LOCATION/include/ SAGA_LIB_DIR=$SAGA_LOCATION/lib/ SAGA_BIN_DIR=$SAGA_LOCATION/bin SAGA_INI_DIR=$SAGA_LOCATION/share/saga/ SAGA_CONFIG=$SAGA_BIN_DIR/saga-config SAGA_VERSION=`$SAGA_CONFIG --version` export SAGA_LOCATION export SAGA_MAKE_DIR export SAGA_CONF_DIR export SAGA_INC_DIR export SAGA_LIB_DIR export SAGA_BIN_DIR export SAGA_INI_DIR export SAGA_CONFIG export SAGA_VERSION AC_SUBST(SAGA_LOCATION) AC_SUBST(SAGA_MAKE_DIR) AC_SUBST(SAGA_CONF_DIR) AC_SUBST(SAGA_INC_DIR) AC_SUBST(SAGA_LIB_DIR) AC_SUBST(SAGA_BIN_DIR) AC_SUBST(SAGA_INI_DIR) AC_SUBST(SAGA_CONFIG) AC_SUBST(SAGA_VERSION) # the adaptor and binding config files depend on the earlier findings of # SAGA's main configure. SAGA_CONF="$SAGA_CONF_DIR/saga-config.cache" test -e "$SAGA_CONF" && source "$SAGA_CONF" test -e "$SAGA_CONF" || AC_MSG_ERROR([SAGA tree at $SAGA_LOCATION seems invalid, no $SAGA_CONF found.]) # be backward compatible to old versions of saga.m4 TMP_SAGA_LOCATION=$SAGA_LOCATION export TMP_SAGA_LOCATION AC_SUBST(TMP_SAGA_LOCATION) SAGA_MAKE_INCLUDE_DIR=$SAGA_MAKE_DIR export SAGA_MAKE_INCLUDE_DIR AC_SUBST(SAGA_MAKE_INCLUDE_DIR) SAGA_LIB_VERSION=$SAGA_PACKAGE_VERSION export SAGA_LIB_VERSION AC_SUBST(SAGA_LIB_VERSION) TMP_SAGA_INSTTYPE=install export TMP_SAGA_INSTTYPE AC_SUBST(TMP_SAGA_INSTTYPE) # by convention, SAGA components keep configure files in a config/subdir. We # set a full path to that, so that make files can find the respective includes CONFDIR=`pwd`/config/ export CONFDIR AC_SUBST(CONFDIR) ])