]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* acgeneral.m4 (_AC_WHICH_A): New macro.
authorAkim Demaille <akim@epita.fr>
Fri, 3 Mar 2000 14:15:41 +0000 (14:15 +0000)
committerAkim Demaille <akim@epita.fr>
Fri, 3 Mar 2000 14:15:41 +0000 (14:15 +0000)
(AC_CHECK_PROG): Use it.  Use ifval.
(AC_CHECK_PROGS): Use ifval.  Fix the quoting.
* tests/semantics.m4: Test AC_CHECK_PROG.
* tests/Makefile.am (EGREP_EXCLUDE): Add /AC_CHECK_PROGS?/.

ChangeLog
acgeneral.m4
lib/autoconf/general.m4
tests/Makefile.am
tests/Makefile.in
tests/semantics.m4

index 2cd7917eba77a97fd51fe62f19fd06b217ec60a9..7849a57d73ffcc44c0a9184c940885db4e078b71 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2000-03-03  Akim Demaille  <akim@epita.fr>
+
+       * acgeneral.m4 (_AC_WHICH_A): New macro.
+       (AC_CHECK_PROG): Use it.  Use ifval.
+       (AC_CHECK_PROGS): Use ifval.  Fix the quoting.
+       * tests/semantics.m4: Test AC_CHECK_PROG.
+       * tests/Makefile.am (EGREP_EXCLUDE): Add /AC_CHECK_PROGS?/.
+
 2000-03-02  Russ Allbery  <rra@stanford.edu>
 
        * autoscan.pl (parse_args): Add support for -m <macrodir>.
index 479bc040e7b7161e7433e8ad62aa12b32c11fe76..4aeff1aebbfcaca06ad1571d2e2389ac5a7ffaf2 100644 (file)
@@ -2039,6 +2039,26 @@ $2],
 ## ----------------------- ##
 
 
+# _AC_WHICH_A(NAME, PATH)
+# -----------------------
+# Work like `which -a NAME' in PATH, even if NAME is not executable.
+# Can be used inside backquotes.
+define([_AC_WHICH_A],
+[IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
+dnl $ac_dummy forces splitting on constant user-supplied paths.
+dnl POSIX.2 word splitting is done only on the output of word expansions,
+dnl not every word.  This closes a longstanding sh security hole.
+ac_dummy="$2"
+for ac_dir in $ac_dummy; do
+  test -z "$ac_dir" && ac_dir=.
+  if test -f $ac_dir/$1; then
+    echo "$ac_dir/$1"
+  fi
+done
+IFS="$ac_save_ifs"
+])
+
+
 # AC_CHECK_PROG(VARIABLE, PROG-TO-CHECK-FOR,
 #               [VALUE-IF-FOUND], [VALUE-IF-NOT-FOUND],
 #               [PATH], [REJECT])
@@ -2051,28 +2071,19 @@ AC_CACHE_VAL(ac_cv_prog_$1,
 [if test -n "[$]$1"; then
   ac_cv_prog_$1="[$]$1" # Let the user override the test.
 else
-  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS=":"
-ifelse([$6], , , [  ac_prog_rejected=no
+ifval([$6], [  ac_prog_rejected=no
 ])dnl
-dnl $ac_dummy forces splitting on constant user-supplied paths.
-dnl POSIX.2 word splitting is done only on the output of word expansions,
-dnl not every word.  This closes a longstanding sh security hole.
-  ac_dummy="ifelse([$5], , $PATH, [$5])"
-  for ac_dir in $ac_dummy; do
-    test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/$ac_word; then
-ifelse([$6], , , dnl
-[      if test "[$ac_dir/$ac_word]" = "$6"; then
-        ac_prog_rejected=yes
-       continue
-      fi
-])dnl
-      ac_cv_prog_$1="$3"
-      break
+  for ac_path in `_AC_WHICH_A([$ac_word], [m4_default([$5], [$PATH])])`; do
+ifval([$6],
+[    if test "$ac_path" = "$6"; then
+      ac_prog_rejected=yes
+      continue
     fi
+])dnl
+    ac_cv_prog_$1="$3"
+    break
   done
-  IFS="$ac_save_ifs"
-ifelse([$6], , , [if test $ac_prog_rejected = yes; then
+ifval([$6], [if test $ac_prog_rejected = yes; then
   # We found a bogon in the path, so make sure we never use it.
   set dummy [$]ac_cv_prog_$1
   shift
@@ -2081,10 +2092,10 @@ ifelse([$6], , , [if test $ac_prog_rejected = yes; then
     # However, it has the same basename, so the bogon will be chosen
     # first if we set $1 to just the basename; use the full file name.
     shift
-    set dummy "$ac_dir/$ac_word" "[$]@"
+    set dummy "$ac_path" "[$]@"
     shift
     ac_cv_prog_$1="[$]@"
-ifelse([$2], [$4], dnl
+ifelse([$2], [$4],
 [  else
     # Default is a loser.
     AC_MSG_ERROR([$1=$6 unacceptable, but no other $4 found in dnl
@@ -2095,7 +2106,7 @@ fi
 ])dnl
 dnl If no 4th arg is given, leave the cache variable unset,
 dnl so AC_CHECK_PROGS will keep looking.
-ifelse([$4], , , [  test -z "[$]ac_cv_prog_$1" && ac_cv_prog_$1="$4"
+ifval([$4], [  test -z "[$]ac_cv_prog_$1" && ac_cv_prog_$1="$4"
 ])dnl
 fi])dnl
 $1="$ac_cv_prog_$1"
@@ -2114,10 +2125,10 @@ AC_SUBST($1)dnl
 AC_DEFUN(AC_CHECK_PROGS,
 [for ac_prog in $2
 do
-AC_CHECK_PROG($1, [$]ac_prog, [$]ac_prog, , $4)
+AC_CHECK_PROG([$1], [$]ac_prog, [$]ac_prog, , [$4])
 test -n "[$]$1" && break
 done
-ifelse([$3], , , [test -n "[$]$1" || $1="$3"
+ifval([$3], [test -n "[$]$1" || $1="$3"
 ])])
 
 
index 479bc040e7b7161e7433e8ad62aa12b32c11fe76..4aeff1aebbfcaca06ad1571d2e2389ac5a7ffaf2 100644 (file)
@@ -2039,6 +2039,26 @@ $2],
 ## ----------------------- ##
 
 
+# _AC_WHICH_A(NAME, PATH)
+# -----------------------
+# Work like `which -a NAME' in PATH, even if NAME is not executable.
+# Can be used inside backquotes.
+define([_AC_WHICH_A],
+[IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
+dnl $ac_dummy forces splitting on constant user-supplied paths.
+dnl POSIX.2 word splitting is done only on the output of word expansions,
+dnl not every word.  This closes a longstanding sh security hole.
+ac_dummy="$2"
+for ac_dir in $ac_dummy; do
+  test -z "$ac_dir" && ac_dir=.
+  if test -f $ac_dir/$1; then
+    echo "$ac_dir/$1"
+  fi
+done
+IFS="$ac_save_ifs"
+])
+
+
 # AC_CHECK_PROG(VARIABLE, PROG-TO-CHECK-FOR,
 #               [VALUE-IF-FOUND], [VALUE-IF-NOT-FOUND],
 #               [PATH], [REJECT])
@@ -2051,28 +2071,19 @@ AC_CACHE_VAL(ac_cv_prog_$1,
 [if test -n "[$]$1"; then
   ac_cv_prog_$1="[$]$1" # Let the user override the test.
 else
-  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS=":"
-ifelse([$6], , , [  ac_prog_rejected=no
+ifval([$6], [  ac_prog_rejected=no
 ])dnl
-dnl $ac_dummy forces splitting on constant user-supplied paths.
-dnl POSIX.2 word splitting is done only on the output of word expansions,
-dnl not every word.  This closes a longstanding sh security hole.
-  ac_dummy="ifelse([$5], , $PATH, [$5])"
-  for ac_dir in $ac_dummy; do
-    test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/$ac_word; then
-ifelse([$6], , , dnl
-[      if test "[$ac_dir/$ac_word]" = "$6"; then
-        ac_prog_rejected=yes
-       continue
-      fi
-])dnl
-      ac_cv_prog_$1="$3"
-      break
+  for ac_path in `_AC_WHICH_A([$ac_word], [m4_default([$5], [$PATH])])`; do
+ifval([$6],
+[    if test "$ac_path" = "$6"; then
+      ac_prog_rejected=yes
+      continue
     fi
+])dnl
+    ac_cv_prog_$1="$3"
+    break
   done
-  IFS="$ac_save_ifs"
-ifelse([$6], , , [if test $ac_prog_rejected = yes; then
+ifval([$6], [if test $ac_prog_rejected = yes; then
   # We found a bogon in the path, so make sure we never use it.
   set dummy [$]ac_cv_prog_$1
   shift
@@ -2081,10 +2092,10 @@ ifelse([$6], , , [if test $ac_prog_rejected = yes; then
     # However, it has the same basename, so the bogon will be chosen
     # first if we set $1 to just the basename; use the full file name.
     shift
-    set dummy "$ac_dir/$ac_word" "[$]@"
+    set dummy "$ac_path" "[$]@"
     shift
     ac_cv_prog_$1="[$]@"
-ifelse([$2], [$4], dnl
+ifelse([$2], [$4],
 [  else
     # Default is a loser.
     AC_MSG_ERROR([$1=$6 unacceptable, but no other $4 found in dnl
@@ -2095,7 +2106,7 @@ fi
 ])dnl
 dnl If no 4th arg is given, leave the cache variable unset,
 dnl so AC_CHECK_PROGS will keep looking.
-ifelse([$4], , , [  test -z "[$]ac_cv_prog_$1" && ac_cv_prog_$1="$4"
+ifval([$4], [  test -z "[$]ac_cv_prog_$1" && ac_cv_prog_$1="$4"
 ])dnl
 fi])dnl
 $1="$ac_cv_prog_$1"
@@ -2114,10 +2125,10 @@ AC_SUBST($1)dnl
 AC_DEFUN(AC_CHECK_PROGS,
 [for ac_prog in $2
 do
-AC_CHECK_PROG($1, [$]ac_prog, [$]ac_prog, , $4)
+AC_CHECK_PROG([$1], [$]ac_prog, [$]ac_prog, , [$4])
 test -n "[$]$1" && break
 done
-ifelse([$3], , , [test -n "[$]$1" || $1="$3"
+ifval([$3], [test -n "[$]$1" || $1="$3"
 ])])
 
 
index dbb186cf94a41f491500953fb813b5af500a85d1..5f440c153e318526cc3b80c76c7b2b1e55c816ea 100644 (file)
@@ -49,8 +49,8 @@ testsuite: atgeneral.m4 atspecific.m4 suite.m4 macros.m4 $(SUITE)
 # and some are already tested elsewhere.  EGREP_EXCLUDE must filter out
 # the macros we don't want to test in syntax.m4.
 #
-# - AC_CHECK decls, files, funcs, members, types, headers
-#   Already performed in the semantical tests.
+# - AC_CHECK decl, file, func, header, member, prog, sizeof, type
+#   Performed in the semantics tests.
 # - AC_CONFIG
 #   They fail when the source does not exist.
 # - AC_INIT
@@ -59,15 +59,15 @@ testsuite: atgeneral.m4 atspecific.m4 suite.m4 macros.m4 $(SUITE)
 # - AC_PROG_(CC|CXX|F77)_(GNU|WORKS)
 #   are used in AC_PROG_CC etc.
 # - AC_PATH_PROGS?
-#   They produce `= val' because $1 is empty.
+#   They produce `= val' because $1, the variable used to store the result,
+#   is empty.
 # - AC_TRY
 #   Used in many places.
 # - _AC_
 #   Internal macros are used elsewhere.
 EGREP_EXCLUDE = egrep -v \
   -e '^AC_ARG_VAR$$' \
-  -e '^AC_CHECK_(DECL|FILE|FUNC|HEADER|MEMBER|SIZEOF|TYPE)S?$$' \
-  -e '^AC_CHECK_PROGS$$' \
+  -e '^AC_CHECK_(DECL|FILE|FUNC|HEADER|MEMBER|PROG|SIZEOF|TYPE)S?$$' \
   -e '^AC_CONFIG' \
   -e '^AC_INIT' \
   -e '^AC_LINKER_OPTION$$' \
index f4a22e6165eb2f9afead0aa48259d319065aa408..af1654141048aa75ef31bc1ab1452477e4fad2cc 100644 (file)
@@ -80,8 +80,8 @@ PERL = perl
 # and some are already tested elsewhere.  EGREP_EXCLUDE must filter out
 # the macros we don't want to test in syntax.m4.
 #
-# - AC_CHECK decls, files, funcs, members, types, headers
-#   Already performed in the semantical tests.
+# - AC_CHECK decl, file, func, header, member, prog, sizeof, type
+#   Performed in the semantics tests.
 # - AC_CONFIG
 #   They fail when the source does not exist.
 # - AC_INIT
@@ -90,12 +90,13 @@ PERL = perl
 # - AC_PROG_(CC|CXX|F77)_(GNU|WORKS)
 #   are used in AC_PROG_CC etc.
 # - AC_PATH_PROGS?
-#   They produce `= val' because $1 is empty.
+#   They produce `= val' because $1, the variable use to store the result,
+#   is empty.
 # - AC_TRY
 #   Used in many places.
 # - _AC_
 #   Internal macros are used elsewhere.
-EGREP_EXCLUDE = egrep -v   -e '^AC_ARG_VAR$$'   -e '^AC_CHECK_(DECL|FILE|FUNC|HEADER|MEMBER|SIZEOF|TYPE)S?$$'   -e '^AC_CHECK_PROGS$$'   -e '^AC_CONFIG'   -e '^AC_INIT'   -e '^AC_LINKER_OPTION$$'   -e '^AC_LINK_FILES$$'   -e '^AC_LIST_MEMBER_OF$$'   -e '^AC_PATH_(TOOL|PROG)S?$$'   -e '^AC_PROG_(CC|CXX|F77)_(GNU|WORKS)$$'   -e '^AC_REPLACE_FUNCS$$'   -e '^AC_SEARCH_LIBS$$'   -e '^AC_TRY'   -e '_AC_'
+EGREP_EXCLUDE = egrep -v   -e '^AC_ARG_VAR$$'   -e '^AC_CHECK_(DECL|FILE|FUNC|HEADER|MEMBER|PROG|SIZEOF|TYPE)S?$$'   -e '^AC_CONFIG'   -e '^AC_INIT'   -e '^AC_LINKER_OPTION$$'   -e '^AC_LINK_FILES$$'   -e '^AC_LIST_MEMBER_OF$$'   -e '^AC_PATH_(TOOL|PROG)S?$$'   -e '^AC_PROG_(CC|CXX|F77)_(GNU|WORKS)$$'   -e '^AC_REPLACE_FUNCS$$'   -e '^AC_SEARCH_LIBS$$'   -e '^AC_TRY'   -e '_AC_'
 
 
 CLEANFILES = debug-*.sh macro configure configure.in config.status config.cache config.log config.h.in config.h
index dca8f5763f825ae41ae969509041f3029fbe4f5d..11de539acd1bea81150f2edc5e34096894e19a9c 100644 (file)
@@ -152,3 +152,65 @@ rm ac-exists1 ac-exists2],
 [#define HAVE_AC_EXISTS1 1
 /* #undef HAVE_AC_MISSING1 */
 ])])
+
+
+
+## --------------- ##
+## AC_CHECK_PROG.  ##
+## --------------- ##
+
+AT_SETUP(AC_CHECK_PROG)
+
+# Create a sub directory `path' with 6 subdirs which all 7 contain
+# an executable `tool'. `6' contains a `better' tool.
+
+mkdir path
+
+cat >path/tool <<\EOF
+#! /bin/sh
+exit 0
+EOF
+chmod +x path/tool
+
+for i in 1 2 3 4 5 6
+do
+  mkdir path/$i
+  cp path/tool path/$i
+done
+cp path/tool path/6/better
+
+# Perform various tests of AC_CHECK_PROG and AC_CHECK_PROGS.
+AT_DATA(configure.in,
+[[AC_INIT
+path=`echo "1:2:3:4:5:6" | sed -e 's,\([[0-9]]\),'\`pwd\`'/path/\1,g'`
+fail=0
+
+AC_CHECK_PROG(TOOL1, tool, found, not-found, $path)
+test "$TOOL1" = found || fail=1
+
+# Yes, the semantics of this macro is weird.
+AC_CHECK_PROG(TOOL2, tool,, not-found, $path)
+test "$TOOL2" = not-found || fail=1
+
+AC_CHECK_PROG(TOOL3, tool, tool, not-found, $path, `pwd`/path/1/tool)
+test "$TOOL3" = `pwd`/path/2/tool || fail=1
+
+AC_CHECK_PROG(TOOL4, better, better, not-found, $path, `pwd`/path/1/tool)
+test "$TOOL4" = better || fail=1
+
+# When a tool is not found, and no value is given for not-found,
+# the variable is left empty.
+AC_CHECK_PROGS(TOOL5, missing,, $path)
+test -z "$TOOL5" || fail=1
+
+AC_CHECK_PROGS(TOOL6, missing tool better,, $path)
+test "$TOOL6" = tool || fail=1
+
+# no AC_OUTPUT, we don't need config.status.
+exit $fail
+]])
+
+AT_CHECK([../autoconf -m .. -l $at_srcdir], 0,, ignore)
+AT_CHECK([./configure], 0, ignore)
+
+AT_CLEANUP(path config.log config.cache configure)