dnl dnl CCAFE_EXTRACT_VAR( VARNAME, INPUT-FILE, INPUT-VARNAME, [ DEFAULT-VALUE ] ) dnl grep for lines of form INPUT-VARNAME = rest of line dnl and set VARNAME to be the value found. dnl If var is not found and default-value is supplied, var takes that value. dnl misfeatures: follows the autoconf convention that there should not dnl be sideeffects perpetrated on the output files -- only variables get dnl defined. AC_DEFUN(CCAFE_EXTRACT_VAR, [ AC_MSG_CHECKING([$2 for $3]) cevDefault= cev1=`grep "^$3 " $2` if test -z "$cev1"; then cev1=`grep "^$3 " $2` fi if test -z "$cev1"; then cev1=`grep "^$3=" $2` fi changequote(, )dnl cev2=`echo "$cev1" | sed 's/^[[:alnum:],[:space:],_,-,.]*=//'` cev3=`echo "$cev2" | sed 's/^[[:space:]]*//'` changequote([, ])dnl if test -z "$cev3" ; then ifelse([$4], , : , [ cev3="$4" ]) fi if test -z "$cev3" ; then AC_MSG_RESULT(no) else [$1]=$cev3 AC_MSG_RESULT([$cev3]) fi ] ) dnl dnl CCAFE_ENV_CHECK( VAR, [MESSAGE-IF-FOUND], [MESSAGE-IF-NOT-FOUND] ) dnl checks that VARNAME is or isn't defined. dnl When no MESSAGE-IFs are supplied, defaults to printing yes/no. dnl Side-effects: none, other than message output. dnl internally used variables are all prefixed cec_. dnl Internal variables (less prefix): dnl yes, no, var_eval, var_val, empty_eval, empty_test, there. dnl on normal completion: dnl cec_there == 1 if the variable is set (includes empty value) dnl cec_there == 0 if not set. dnl Bugs: dnl This macro would be 3 lines if we could assume bash syntax is portable. dnl It even works when checking for environment variables with the dnl value cec_not_there. AC_DEFUN(CCAFE_ENV_CHECK, [ if test -z "$1"; then AC_MSG_RESULT(CCAFE env_check called with empty VAR argument) else AC_MSG_CHECKING(environment for $1) # build a line which echos the name in $1 # get the value of that var cec_var_eval="echo $"`echo $1` cec_var_val=`eval $cec_var_eval` if test -z "$cec_var_val" ; then # either its there, not there or 0 len # 0 len may be meaningful so we need to distinguish. # at this point we don't need to worry about overwriting its value # temporarily since it's at most empty. cec_empty_eval="echo \${"`echo $1`"-cec_not_there}" cec_empty_test=`eval $cec_empty_eval` if test "X$cec_empty_test" = "Xcec_not_there" ; then cec_there=0 else cec_there=1 fi else cec_there=1 fi cec_yes=yes cec_no=no ifelse([$2], , : , [cec_yes="$2"]) ifelse([$3], , : , [cec_no="$3"]) if test $cec_there -eq 1 ; then AC_MSG_RESULT($cec_yes) else AC_MSG_RESULT($cec_no) fi fi ] ) dnl CCAFE_PATH_TO_FILE(VARIABLE, TEST_FILES, PATH, dnl [ RUN_IF_FOUND, [RUN_IF_NOT_FOUND) dnl Test for the presence of file(s) (TEST_FILES) in the given colon dnl separated list of directory paths (PATH). If all of the files for a dnl given path element are present, it sets VARIABLE to the matching PATH dnl element and calls AC_SUBST on it. The files appear in TEST_FILES as a dnl space separated list. The last two arguments are run if a path to the dnl files is found or not found respectively. AC_DEFUN(CCAFE_PATH_TO_FILE, [ var="$1" testFiles="$2" path="$3" result=_searching paths=`echo $path|tr ":" " "` for chome in $paths ; do for testFile in $testFiles ; do if ! test -f $chome/$testFile ; then result=_searching break fi result=$chome done if test "$result" = "$chome" ; then $1=$result if test -n '$4' ; then # if found $4 fi # echo " found: $result" break; fi done if test "$result" = _searching ; then if test -n '$5' ; then #if not found $5 fi fi ] ) AC_DEFUN(CCAFE_CHECK_BOOST, [ #-------------------------------------------------------------------- # See if we can find Boost # side effects: # BOOST_ROOT becomes defined if boost found or "" if not. # AC_SUBST for BOOST_ROOT is not a side effect, per autoconf macro # guidelines. #-------------------------------------------------------------------- AC_ARG_WITH(boost, [ --with-boost=BOOST_ROOT The full path to the BOOST install dir.], , [with_boost=yes] ) case $with_boost in no) # can't live without BOOST BOOST_ROOT=no AC_MSG_RESULT(BOOST disabled.) ;; yes) # The user didn't give the --with-boost # option or didn't give the library's location. # If that fails, disable and print a warning. BOOST_ROOT="yes" ;; *) # The user gave us --with-boost=BOOST_ROOT, use that as the # location of the BOOST library. BOOST_ROOT="$with_boost" AC_MSG_RESULT(BOOST root given.) ;; esac # test for success ccafe_boost_dirs="/usr/local:/usr/local/include:/usr/include:$HOME:$HOME/include" if test "$BOOST_ROOT" = "yes" ; then BOOST_ROOT="" AC_MSG_CHECKING([BOOST smart pointers]) CCAFE_PATH_TO_FILE(BOOST_ROOT, boost/shared_ptr.hpp, "$ccafe_boost_dirs", AC_MSG_RESULT([BOOST root dir found.]), [BOOST_ROOT=no]) fi ] ) #------------------------------------------------------------------------------ # NEOCCA_ROOT: See if the user gave us the location of cca-spec # then search $ccatut_cca_spec_dirs. # One of these directories must be # present and contain the correct files, or else the user # must give the directory that contains the correct files. # # buggy. needs to deal with package version ala babel. #------------------------------------------------------------------------------ # cca spec (must contain java and cxx binding subdirs) AC_DEFUN(NEOCLASSIC_SPEC_CCA, [ ccatut_cca_spec_dirs=" $prefix/cca-spec-neo $CCATUT_HOME/cca-spec-neo $TOP/cca-spec-neo $CURRDIR_PARENT/cca-spec-neo $CURRDIR_GRANDPARENT/cca-spec-neo $CURRDIR_GREATGRANDPARENT/cca-spec-neo $CURRDIR_ANCESTOR/cca-spec-neo /home/alice/CCA/cca-spec-neo $HOME/cca-spec-neo $HOME/cca/cca-spec-neo /usr/local/cca-spec-neo $prefix/cca /usr/local/cca $HOME/cca " AC_ARG_WITH(neo, [Location of neoclassic: --with-neo=SPEC_ROOT The prefix used when installing cca-spec-neo Give the full path: --with-neo='/usr/local/cca-spec-neo' or check out the spec from cvs in a directory next to CCAFFEINE. ] , , [with_neo=no]) case "$with_neo" in no) # lUser input error with_neo=_searching ;; yes) # User didn't give the option or didn't give useful # information, search for it ourselves with_neo=_searching ;; *) NEOCCA_ROOT="$with_neo" ;; esac if test "$with_neo" = _searching ; then AC_MSG_CHECKING([for REQUIRED cca-spec-neo]) for chome in $ccatut_cca_spec_dirs ; do if test -d $chome ; then with_neo=$chome AC_MSG_RESULT([found $chome.]) break fi done fi if test "$with_neo" = _searching ; then AC_MSG_RESULT([Cannot find CCA specification root directory.]) AC_MSG_ERROR([Please install it and/or use --with-cca=CCA_ROOT.]) fi if test ! -f "$with_neo/include/neocca.h" ; then AC_MSG_RESULT([No include/neocca.h in $with_neo.]) AC_MSG_ERROR([Please install a correct neoclassic specification directory.]) fi NEOCCA_INSTALL_ROOT="$with_cca" AC_SUBST(NEOCCA_INSTALL_ROOT) ] ) dnl -------------------------------------------------------------------- dnl Side effects: updates all the prefix related variables if prefix dnl has not been properly defined by now. dnl -------------------------------------------------------------------- AC_DEFUN(CCAFE_AC_PREFIX, [ if test -z "$1" ; then AC_MSG_ERROR([Ccafe_ac_prefix macro requires a default path.]) fi if test -z "$prefix" ; then prefix=$1; fi if test $prefix = "NONE" ; then prefix=$1; fi datadir='${prefix}/share'; sysconfdir='${prefix}/etc'; sharedstatedir='${prefix}/com'; localstatedir='${prefix}/var'; includedir='${prefix}/include'; infodir='${prefix}/info'; mandir='${prefix}/man'; ] ) dnl -------------------------------------------------------------------- dnl requires prefix be define, or does nothing. dnl -------------------------------------------------------------------- AC_DEFUN(CCAFE_AC_EXEC_PREFIX, [ if test -z "$1" ; then AC_MSG_ERROR([Ccafe_ac_exec_prefix macro requires a default path.]) fi if test -z "$exec_prefix" ; then exec_prefix=$1; fi if test $prefix = "NONE" ; then exec_prefix=$1; fi bindir='${exec_prefix}/bin'; sbindir='${exec_prefix}/sbin'; libexecdir='${exec_prefix}/libexec'; libdir='${exec_prefix}/lib'; ] ) dnl NEOCCA_PATH_TO_CONFIG_VER(VARIABLE, BINVAR, PATH, TEST_FILE, dnl [ RUN_IF_FOUND], [RUN_IF_NOT_FOUND]) dnl Test for the presence of file(s) (TEST_FILE) in the given colon dnl separated list of directory paths (PATH). If all the file dnl is found, it sets VARIABLE to the matching PATH element and dnl BINVAR to script found. dnl The last two arguments are run if a path to the dnl files is found or not found respectively. dnl Side effects: dnl If variable NEOCCA_PATH_TO_CONFIG is predefined to contain dnl the name of an appropriate executable, then we get dnl that as BINVAR and its root as VARIABLE. AC_DEFUN(NEOCCA_PATH_TO_CONFIG_VER, [ dnl AC_MSG_RESULT([entering cca_path_to_config_ver]) p2cv_var="$1" p2cv_binvar="$2" p2cv_path="$3" p2cv_testFile="$4" p2cv_config="no" #p2cv_testFile=bin/cca-spec-neo-config #p2cv_path="." p2cv_ok=no if test "x$NEOCCA_PATH_TO_CONFIG" != "x" ; then if test -x $NEOCCA_PATH_TO_CONFIG ; then p2cv_config=$NEOCCA_PATH_TO_CONFIG p2cv_path=`$NEOCCA_PATH_TO_CONFIG --var NEOCCA_INSTALL_ROOT` p2cv_result=$p2cv_path $1=$p2cv_result $2=$p2cv_config p2cv_ok=yes if test -n '$5' ; then # if found $5 fi dnl comment next dnl AC_MSG_RESULT([found $NEOCCA_PATH_TO_CONFIG]) else AC_MSG_WARN([Ignoring env NEOCCA_PATH_TO_CONFIG pointing to non-executable $NEOCCA_PATH_TO_CONFIG.]) fi fi if test "$p2cv_ok" = "no" ; then p2cv_tmpfile=`pwd`/.p2cv_tmpfile # for path elements # if ! element/testfile exists, res=search # for file-* w/ver number, try highest number # and work down. ver must end in a digit p2cv_result=_searching p2cv_paths=`echo $p2cv_path|tr ":" " "` for chome in $p2cv_paths ; do dnl comment next dnl AC_MSG_RESULT([trying $chome]) if test -x $chome/$p2cv_testFile ; then p2cv_result=$chome p2cv_config=$chome/$p2cv_testFile $1=$p2cv_result $2=$p2cv_config if test -n '$5' ; then # if found $5 fi dnl comment next dnl AC_MSG_RESULT([found basenamed file]) break fi if test -d $chome ; then pushd $chome > /dev/null flist="${p2cv_testFile}-*[0-9]" popd > /dev/null /bin/rm -f $p2cv_tmpfile for fname in $flist ; do echo $fname >> $p2cv_tmpfile done flist=`cat $p2cv_tmpfile | sort -n -r` /bin/rm -f $p2cv_tmpfile for fname in $flist ; do if test -x $chome/$fname ; then p2cv_result=$chome p2cv_config=$chome/$fname $1=$p2cv_result $2=$p2cv_config if test -n '$5' ; then # if found $5 fi dnl comment next dnl AC_MSG_RESULT([ found: $p2cv_result/$fname]) break; fi done fi done # not found anywhere if test "$p2cv_result" = _searching ; then dnl comment next dnl AC_MSG_RESULT([ nothing found]) p2cv_result=no if test -n '$6' ; then #if not found $6 fi fi # end of search for config with ver. dnl end of p2cv_ok no test fi dnl comment next dnl AC_MSG_RESULT([leaving neocca_path_to_config_ver]) ] ) dnl CCA_SPEC_NEO_CONFIG(DISTROOT, PATH, TESTFILE, NOTFOUNDWARNING, CONFIGBIN) dnl input dnl DISTROOT- input: the variable to set with the result dnl PATH- the directories to check for cca-spec-neo by finding cca-spec-neo-config dnl TESTFILE- the script file we require to exist. dnl output/sideeffects dnl DISTROOT becomes defined as no, or a directory dnl CONFIGBIN becomes defined as no, or the name of the cca-spec-neo-config-$ver dnl dnl See if the user gave us the location of cca-spec-neo dnl We have to do this one first, because it tells us where boost is. dnl dnl This macro does discovery and is reusable. dnl policy matters such as paths checked dnl and fatal or not are specific to the configure that includes this macro. dnl dnl eg CCA_SPEC_NEO_CONFIG(NEOCCA_ROOT, testpaths, bin/cca-spec-neo-config%ms%d%mb%d, msg, CCAFE_CCA_SPEC_NEO_CONFIG) AC_DEFUN(CCA_SPEC_NEO_CONFIG, [ CCA_NEO_TEST="" CCA_NEO="" AC_ARG_WITH(cca-neo, [ Location of cca-spec-neo: --with-cca-neo=SPEC_TREE The location of neoclassic CCA specification. Give the full path: --with-cca-neo='/where/is/cca-spec-neo/installed' The install prefix of cca-spec-neo will be the same as the build location unless it was configured with --prefix. Remember that for cca-spec-neo you must do make;make install. or give --with-cca-neo=no ] , , [with_cca_neo=yes]) case "$with_cca_neo" in no) CCA_NEO="no" AC_MSG_WARN([Neoclassic CCA spec option disabled. Use --with-cca-neo=/where/is/cca-spec-neo/installed if wanted.]) ;; yes) # User didn't give the option or didn't give useful # information, search for it ourselves with_cca_neo="yes" CCA_NEO="yes" AC_MSG_CHECKING([cca-spec-neo]) ;; *) CCA_NEO="$with_cca_neo" AC_MSG_CHECKING([cca-spec-neo]) ;; esac CCA_NEO_TEST="$CCA_NEO" CCA_NEO_CONFIG_TEST="no" if test "$CCA_NEO" != "no"; then CCA_NEO_TEST="" NEOCCA_PATH_TO_CONFIG_VER(CCA_NEO_TEST, CCA_NEO_CONFIG_TEST, $with_cca_neo:$2, $3, CCA_NEO="$CCA_NEO_TEST" CCA_NEO_CONFIG="$CCA_NEO_CONFIG_TEST" , CCA_NEO_TEST="no" CCA_NEO="no" CCA_NEO_CONFIG_TEST=no CCA_NEO_CONFIG=no [AC_MSG_WARN([$4])] ) fi $1="$CCA_NEO" $5="$CCA_NEO_CONFIG" dnl AC_MSG_RESULT([root $CCA_NEO , config $CCA_NEO_CONFIG]) ] ) AC_DEFUN(CCA_NEO_CONFIG_FORCE, [ AC_ARG_WITH(neo-config, [ Location of cca-spec-neo-config program: --with-neo-config=/usr/local/bin/cca-spec-neoabel-config[-version_numbers] Specify the particular neoclassic CCA specification config info script. This is not normally needed unless multiple versions of cca-spec-neo are installed in the same location. This option overrides environment variable NEOCCA_PATH_TO_CONFIG. ] , , [with_neo_config=no]) case "$with_neo_config" in no) ;; yes) with_neo_config="no" AC_MSG_ERROR([--with-neo-config must be given the path of the script.]) ;; *) if test -d $with_neo_config ; then AC_MSG_ERROR([--with-neo-config must be given the path of the script, not a directory.]) fi if ! test -x $with_neo_config ; then AC_MSG_ERROR([--with-neo-config=$with_neo_config: $with_neo_config not executable]) fi NEOCCA_PATH_TO_CONFIG=$with_neo_config ;; esac ] ) builtin(include,config/ccafe_pushd.m4) builtin(include,config/ccafe_config_args.m4)