autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Initial draft patch: AS_EXECUTABLE_P


From: Tim Van Holder
Subject: Initial draft patch: AS_EXECUTABLE_P
Date: Mon, 22 Jan 2001 23:27:28 +0100

Here is an initial draft of an AS_EXECUTABLE_P macro to
replace the current 'test -f'. It works on my system
(tested using a basic "AC_INIT; AC_PROG_CC" configure.in),
but the _AS_TEST_PREPARE macro will probably need some
refining. And of course, names will probably need changing
too.

2001-01-22      Tim Van Holder <address@hidden>

        * m4sh.m4 (AS_EXECUTABLE_P, _AS_TEST_PREPARE):
        New macros.
        (AS_SANITIZE_SHELL): Call _AS_TEST_PREPARE.
        * acgeneral.m4 (AC_CHECK_PROG, AC_PATH_PROG): Use
        AS_EXECUTABLE_P instead of test -f.

Index: m4sh.m4
===================================================================
RCS file: /cvs/autoconf/m4sh.m4,v
retrieving revision 1.27
diff -u -r1.27 m4sh.m4
--- m4sh.m4     2001/01/22 08:59:02     1.27
+++ m4sh.m4     2001/01/22 22:18:52
@@ -67,6 +67,7 @@
 fi
 
 _AS_EXPR_PREPARE
+_AS_TEST_PREPARE
 _AS_UNSET_PREPARE
 
 # NLS nuisances.
@@ -288,6 +289,15 @@
 AS_DIRNAME_SED([$1])])
 
 
+# AS_EXECUTABLE_P
+# ---------------
+# Check whether a file is executable.
+m4_defun([AS_EXECUTABLE_P],
+[m4_require([_AS_TEST_PREPARE])dnl
+$as_executable_p [$1]dnl
+])# AS_EXECUTABLE_P
+
+
 # _AS_EXPR_PREPARE
 # ----------------
 # Some expr work properly (i.e. compute and issue the right result),
@@ -298,7 +308,7 @@
   as_expr=expr
 else
   as_expr=false
-fi[]dnl
+fi
 ])# _AS_EXPR_PREPARE
 
 
@@ -322,6 +332,28 @@
   esac
 done; }
 ])# AS_MKDIR_P
+
+# _AS_TEST_PREPARE
+# ----------------
+# Find out ahead of time whether we want test -x (preferred) or test -f
+# to check whether a file is executable.
+m4_defun([_AS_TEST_PREPARE],
+[# Find out how to test for executable files. Don't use a zero-byte file,
+# as systems may use methods other than mode bits to determine executability.
+cat >conftest.file <<_ACEOF
address@hidden:@! /bin/sh
+exit 0
+_ACEOF
+chmod 100 conftest.file
+if test -x conftest.file; then
+  as_executable_p="test -x"
+elif test -f conftest.file; then
+  as_executable_p="test -f"
+else
+  AS_ERROR([Can't check whether a file is executable on this system])
+fi
+rm -f conftest.file
+])# _AS_TEST_PREPARE
 
 
 
Index: acgeneral.m4
===================================================================
RCS file: /cvs/autoconf/acgeneral.m4,v
retrieving revision 1.672
diff -u -r1.672 acgeneral.m4
--- acgeneral.m4        2001/01/22 14:07:09     1.672
+++ acgeneral.m4        2001/01/22 22:18:55
@@ -2378,7 +2378,7 @@
 m4_ifvaln([$6],
 [  ac_prog_rejected=no])dnl
   AC_SHELL_PATH_WALK([$5],
-[test -f "$ac_dir/$ac_word" || continue
+[AS_EXECUTABLE_P("$ac_dir/$ac_word") || continue
 m4_ifvaln([$6],
 [if test "$ac_dir/$ac_word" = "$6"; then
   ac_prog_rejected=yes
@@ -2447,8 +2447,8 @@
   ;;
   *)
   AC_SHELL_PATH_WALK([$4],
-[if test -f "$ac_dir/$ac_word"; then
+[if AS_EXECUTABLE_P("$ac_dir/$ac_word"); then
    ac_cv_path_$1="$ac_dir/$ac_word"
    break
 fi])
 dnl If no 3rd arg is given, leave the cache variable unset,




reply via email to

[Prev in Thread] Current Thread [Next in Thread]