* NightStrike wrote on Thu, Mar 13, 2008 at 10:07:31PM CET: > On 3/13/08, Ralf Wildenhues <Ralf.Wildenhues@xxxxxx> wrote: > > > > AC_INIT > > AC_DEFUN([FOO], [echo foo]) > > AC_DEFUN([BAR], [AC_REQUIRE([FOO]) > > echo bar]) > > x=zork > > AS_CASE([$x], [y*], [BAR]) > > > > will print 'foo' because FOO will be expanded outside of the AS_CASE. > I'm trying to follow this logic, but I'm not putting it together in my > head. Why isn't the result nothing? Because it expands to this: x=zork echo foo case $x in y*) echo bar ;; esac That is, required macros of macro expansions that happen inside defun'ed macros get pushed right before the outermost defun'ed macro. <http://www.gnu.org/software/autoconf/manual/html_node/Dependencies-Between-Macros.html> Here's a slightly more useful example: # FIND(PATTERN, FILE) # ------------------- AC_DEFUN([FIND], [AC_REQUIRE([AC_PROG_GREP]) $GREP $1 $2 ]) AS_CASE([$whatever], [blabla], [FIND([pattern], [file])]) FIND([pattern2], [file2]) The AC_PROG_GREP will be expanded only once (that's what AC_REQUIRE does). If it were expanded inside the case..esac, then if $whatever did not match, the second FIND would provoke a syntax error because $GREP has not been initialized at that point. One should not that this also frequently leads to confusion, because users don't realize AC_REQUIRE'd macros end up quite a bit earlier than they expect. Cheers, Ralf _______________________________________________ Autoconf mailing list Autoconf@xxxxxxx http://lists.gnu.org/mailman/listinfo/autoconf