Hello Sam, * Sam Steingold wrote on Wed, Sep 02, 2009 at 05:26:46PM CEST: > I want to cache several dependent variables, and I cannot figure out > how to do that correctly. * Sam Steingold wrote on Wed, Sep 02, 2009 at 07:51:20PM CEST: > does the cache variable name matter? > e.g., ac_cv_have_readline is not declared cached in > http://clisp.cvs.sourceforge.net/*checkout*/clisp/clisp/src/m4/readline.m4 > but I do see it in config.cache. Generally, configure currently saves all variables matching *_cv_* (glob notation), and considers a variable cached also if its value is empty. It uses AS_VAR_TEST_SET to test if the variable is cached. Being very precise, we don't document that you can use cache variables without one of the AC_CACHE_{CHECK,VAL} macros, but I'm not sure whether a future Autoconf version may make this a requirement. > specifically: > > AC_DEFUN([AC_FOO],[dnl > AC_ARG_WITH([foo], > AC_HELP_STRING([--with-foo],[use this FOO installation]), > [ac_cv_use_foo="$withval"], [ac_cv_use_foo=default]) By overwriting the cache variable with the value obtained from --with-foo, you cannot tell any more whether the variable was cached or you just read a command line argument. > ac_cv_have_foo=no Here you just overwrite the value obtained above again. > if test "$ac_cv_use_foo" = "no"; This will then always be true. > then AC_MSG_NOTICE([not checking for FOO]) > I want all the ac_cv_* vars to be cached. > how do I arrange for that? > i.e., should I put the "if $ac_cv_foo_command bar;" inside AC_CACHE_CHECK? > would those _nested_ AC_CACHE_CHECKs work? You should have one AC_CACHE_CHECK(MESSAGE, CACHE-ID, COMMANDS) or one AC_CACHE_VAL(CACHE-ID, COMMANDS) for one of the CACHE-IDs. The important thing is that you don't set that CACHE-ID outside of COMMANDS, and the COMMANDS should only set the CACHE-ID (and the other, dependent ones, I guess). Thus, this: > FOO=$ac_cv_foo_command; AC_SUBST(FOO) > FOO_BAR=$ac_cv_foo_bar; AC_SUBST(FOO_BAR) > FOO_ZOT=$ac_cv_foo_zot; AC_SUBST(FOO_ZOT) should happen outside (after) the AC_CACHE_{CHECK,VAL}. Hope that helps. I think there are a couple of examples in gnulib. Cheers, Ralf _______________________________________________ Autoconf mailing list Autoconf@xxxxxxx http://lists.gnu.org/mailman/listinfo/autoconf