On Fri, Aug 31, 2007 at 06:50:07AM -0600, Eric Blake wrote: > >>> In other words, during configuration, autoconf finds the first program on > >>> your PATH named gm4, gnum4, and then m4, which also meets the minimum > >>> requirements of m4 1.4.5 or later.
> The attached patch implements the above algorithm. However, before I > apply it, I wonder if it is time to make a documented public macro that > makes this idiom kosher, rather than using an internal macro. > Note that _AC_PATH_PROG_FEATURE_CHECK already has a bug in its current > usage in programs.m4 - it is currently only used by AC_PROG_GREP and > AC_PROG_SED, both of which invoke it inside AC_CACHE_CHECK. Therefore, > its attempt to do AC_SUBST([$1]) is useless - if you run ./configure -C > with the program variable unset, the first run will set the variable, but > the second run will leave it unset. Fortunately, both AC_PROG_GREP and > AC_PROG_SED (and my patch below) work around this bug, by re-calling > AC_SUBST(variable) after the cache context ends. I see no AC_SUBST(M4) in your patch, though. > I'm thinking a public macro should look like: > > # AC_PATH_PROG_FEATURE_CHECK(VARIABLE, PROGNAME-LIST, MSG, > # FEATURE-TEST, [PATH=$PATH]) > # -------------------------------------------------------- The name 'AC_PATH_PROGS_FEATURE_CHECK' is more accurate: the macro follows AC_PATH_PROGS more than AC_PATH_PROG. The MSG argument is unusual in an Autoconf macro; typically the calling code would do that itself, if needed. > # Cache a search for a program, using MSG as in AC_CACHE_CHECK. > # If VARIABLE is set, use it without any questions. Otherwise, > # call FEATURE_TEST repeatedly with $ac_path_VARIABLE set to the > # name of a program in PROGNAME-LIST found in PATH. FEATURE-TEST > # must set $ac_cv_path_VARIABLE to the path of an acceptable > # program, or else _AC_PATH_PROG_FEATURE_CHECK will report that > # no acceptable program was found, and abort. Aborting should not be the fixed failure resolution of a public, generic macro. AC_PATH_PROGS has a VALUE-IF-NOT-FOUND argument; it is probably best to keep that pattern. Callers can test for that value and abort. On the other hand, but for current practice, an ACTION-IF-NOT-FOUND allows for more intuitive control flow in the caller. > If a suitable > # $ac_path_VARIABLE is found in the FEATURE-TEST macro, it can > # set $ac_path_VARIABLE_found=':' to accept that value without > # any further checks. On success, VARIABLE will contain the > # final program found, and will be AC_SUBST'd.
