]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
AC_ARG_PROGRAM must not be expanded twice, which is likely since
authorAkim Demaille <akim@epita.fr>
Tue, 14 Mar 2000 08:20:25 +0000 (08:20 +0000)
committerAkim Demaille <akim@epita.fr>
Tue, 14 Mar 2000 08:20:25 +0000 (08:20 +0000)
Automake calls it, and usually users do too.  If it happens,
`--program-prefix=g' actually prepend two (or more) `g'.

* acgeneral.m4 (AC_DEFUN_ONCE): New macro.
(AC_ARG_PROGRAM): AC_DEFUNed_ONCE.  Or is it AC_DEFUN_ONCE'd? :).
No longer AC_EXPAND_ONCE the help string, the macro itself is
expanded at most once.
Rename the here-doc tag EOF_SED as EOF.

ChangeLog
acgeneral.m4
lib/autoconf/general.m4

index 18bb7329c9a5b6c1605eafd8522a608176980be9..308a5bd833b102562a14bdbffbc8ca011ee0f617 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2000-03-14  Akim Demaille  <akim@epita.fr>
+
+       AC_ARG_PROGRAM must not be expanded twice, which is likely since
+       Automake calls it, and usually users do too.  If it happens,
+       `--program-prefix=g' actually prepend two (or more) `g'.
+
+       * acgeneral.m4 (AC_DEFUN_ONCE): New macro.
+       (AC_ARG_PROGRAM): AC_DEFUNed_ONCE.  Or is it AC_DEFUN_ONCE'd? :).
+       No longer AC_EXPAND_ONCE the help string, the macro itself is
+       expanded at most once.
+       Rename the here-doc tag EOF_SED as EOF.
+
 2000-03-14  Akim Demaille  <akim@epita.fr>
 
        Get rid of the ICMDS diversion.
index 85bb38ef5791c0a7be7dba30fed46f86da0df667..875817d7f81a284bee84d219422745900ee11169 100644 (file)
@@ -1,6 +1,5 @@
 # This file is part of Autoconf.                       -*- Autoconf -*-
 # Parameterized macros.
-# Requires GNU m4.
 # Copyright (C) 1992, 93, 94, 95, 96, 98, 99, 2000
 # Free Software Foundation, Inc.
 #
@@ -49,7 +48,6 @@
 # Written by David MacKenzie, with help from
 # Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
 # Roland McGrath, Noah Friedman, david d zuhn, and many others.
-#
 
 m4_namespace_push(autoconf)
 
@@ -216,11 +214,22 @@ undivert(AC_DIVERT([NORMAL_1]))dnl
 # future.
 define([AC_DEFUN],
 [ifelse([$3],,
-[define([$1], [AC_PRO([$1])$2[]AC_EPI()])],
-[define([$2-$3], [$1])
+        [define([$1], [AC_PRO([$1])$2[]AC_EPI()])],
+        [define([$2-$3], [$1])
 define([$1], [AC_PRO([$1])$4[]AC_EPI()])])])
 
 
+# AC_DEFUN_ONCE(NAME, EXPANSION)
+# ------------------------------
+# As AC_DEFUN, but issues the EXPANSION only once, and warns if used
+# several times.
+define([AC_DEFUN_ONCE],
+[define([$1],
+[AC_PROVIDE_IF([$1],
+               [AC_WARNING([$1 invoked multiple times])],
+               [AC_PRO([$1])$2[]AC_EPI()])])])
+
+
 # AC_DEFUNCT(NAME, COMMENT)
 # -------------------------
 # Declare the macro NAME no longer exists, and must not be used.
@@ -1385,25 +1394,25 @@ esac[]dnl
 
 # AC_ARG_PROGRAM
 # --------------
-# FIXME: Must be run only once.  Introduce AC_DEFUN_ONCE?
-AC_DEFUN(AC_ARG_PROGRAM,
+# This macro is expanded only once, to avoid that `foo' ends up being
+# installed as `ggfoo'.
+AC_DEFUN_ONCE(AC_ARG_PROGRAM,
 [dnl Document the options.
-AC_EXPAND_ONCE([AC_DIVERT_PUSH([HELP_BEGIN])dnl
+AC_DIVERT_PUSH([HELP_BEGIN])dnl
 
 Program names:
-  --program-prefix=PREFIX prepend PREFIX to installed program names
-  --program-suffix=SUFFIX append SUFFIX to installed program names
-  --program-transform-name=PROGRAM
-                          run sed PROGRAM on installed program names
-AC_DIVERT_POP])[]dnl
+  --program-prefix=PREFIX            prepend PREFIX to installed program names
+  --program-suffix=SUFFIX            append SUFFIX to installed program names
+  --program-transform-name=PROGRAM   run sed PROGRAM on installed program names
+AC_DIVERT_POP()dnl
 if test "$program_transform_name" = s,x,x,; then
   program_transform_name=
 else
   # Double any \ or $.  echo might interpret backslashes.
-  cat <<\EOF_SED >conftestsed
+  cat <<\EOF >conftestsed
 s,\\,\\\\,g; s,\$,$$,g
-EOF_SED
-  program_transform_name=`echo $program_transform_name|sed -f conftestsed`
+EOF
+  program_transform_name=`echo $program_transform_name | sed -f conftestsed`
   rm -f conftestsed
 fi
 test "$program_prefix" != NONE &&
@@ -1414,7 +1423,8 @@ test "$program_suffix" != NONE &&
 
 # sed with no file args requires a program.
 test "$program_transform_name" = "" && program_transform_name="s,x,x,"
-])
+])# AC_ARG_PROGRAM
+
 
 
 ## ----------------- ##
index 85bb38ef5791c0a7be7dba30fed46f86da0df667..875817d7f81a284bee84d219422745900ee11169 100644 (file)
@@ -1,6 +1,5 @@
 # This file is part of Autoconf.                       -*- Autoconf -*-
 # Parameterized macros.
-# Requires GNU m4.
 # Copyright (C) 1992, 93, 94, 95, 96, 98, 99, 2000
 # Free Software Foundation, Inc.
 #
@@ -49,7 +48,6 @@
 # Written by David MacKenzie, with help from
 # Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
 # Roland McGrath, Noah Friedman, david d zuhn, and many others.
-#
 
 m4_namespace_push(autoconf)
 
@@ -216,11 +214,22 @@ undivert(AC_DIVERT([NORMAL_1]))dnl
 # future.
 define([AC_DEFUN],
 [ifelse([$3],,
-[define([$1], [AC_PRO([$1])$2[]AC_EPI()])],
-[define([$2-$3], [$1])
+        [define([$1], [AC_PRO([$1])$2[]AC_EPI()])],
+        [define([$2-$3], [$1])
 define([$1], [AC_PRO([$1])$4[]AC_EPI()])])])
 
 
+# AC_DEFUN_ONCE(NAME, EXPANSION)
+# ------------------------------
+# As AC_DEFUN, but issues the EXPANSION only once, and warns if used
+# several times.
+define([AC_DEFUN_ONCE],
+[define([$1],
+[AC_PROVIDE_IF([$1],
+               [AC_WARNING([$1 invoked multiple times])],
+               [AC_PRO([$1])$2[]AC_EPI()])])])
+
+
 # AC_DEFUNCT(NAME, COMMENT)
 # -------------------------
 # Declare the macro NAME no longer exists, and must not be used.
@@ -1385,25 +1394,25 @@ esac[]dnl
 
 # AC_ARG_PROGRAM
 # --------------
-# FIXME: Must be run only once.  Introduce AC_DEFUN_ONCE?
-AC_DEFUN(AC_ARG_PROGRAM,
+# This macro is expanded only once, to avoid that `foo' ends up being
+# installed as `ggfoo'.
+AC_DEFUN_ONCE(AC_ARG_PROGRAM,
 [dnl Document the options.
-AC_EXPAND_ONCE([AC_DIVERT_PUSH([HELP_BEGIN])dnl
+AC_DIVERT_PUSH([HELP_BEGIN])dnl
 
 Program names:
-  --program-prefix=PREFIX prepend PREFIX to installed program names
-  --program-suffix=SUFFIX append SUFFIX to installed program names
-  --program-transform-name=PROGRAM
-                          run sed PROGRAM on installed program names
-AC_DIVERT_POP])[]dnl
+  --program-prefix=PREFIX            prepend PREFIX to installed program names
+  --program-suffix=SUFFIX            append SUFFIX to installed program names
+  --program-transform-name=PROGRAM   run sed PROGRAM on installed program names
+AC_DIVERT_POP()dnl
 if test "$program_transform_name" = s,x,x,; then
   program_transform_name=
 else
   # Double any \ or $.  echo might interpret backslashes.
-  cat <<\EOF_SED >conftestsed
+  cat <<\EOF >conftestsed
 s,\\,\\\\,g; s,\$,$$,g
-EOF_SED
-  program_transform_name=`echo $program_transform_name|sed -f conftestsed`
+EOF
+  program_transform_name=`echo $program_transform_name | sed -f conftestsed`
   rm -f conftestsed
 fi
 test "$program_prefix" != NONE &&
@@ -1414,7 +1423,8 @@ test "$program_suffix" != NONE &&
 
 # sed with no file args requires a program.
 test "$program_transform_name" = "" && program_transform_name="s,x,x,"
-])
+])# AC_ARG_PROGRAM
+
 
 
 ## ----------------- ##