autoconf-patches
[Top][All Lists]
Advanced

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

Portability of AC_ARG_PROGRAM


From: Akim Demaille
Subject: Portability of AC_ARG_PROGRAM
Date: 20 Jun 2001 21:06:40 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Academic Rigor)

I've been caught for one of my projects.  2.13 was `wrong' too.

I'm in favor of removing AC_ARG_PROGRAM and considering it as part of
the standard ./configure interface.  The worse part being that without
AC_ARG_PROGRAM, --program-prefix etc. are accepted, but ignored.

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        ./configure --program-suffix=foo produces `transform=s,$$,foo,;',
        but some sed choke on multiple `;', and other tools (e.g.,
        Automake), include the separator themselves.

        * acgeneral.m4 (AC_ARG_VAR): Be sure not to leave extra `;'.

Index: NEWS
===================================================================
RCS file: /cvs/autoconf/NEWS,v
retrieving revision 1.159
diff -u -u -r1.159 NEWS
--- NEWS 2001/06/19 06:45:18 1.159
+++ NEWS 2001/06/20 19:01:08
@@ -24,6 +24,7 @@
   of the first one.
 - AC_ARG_VAR properly propagates precious variables inherited from the
   environment to ./config.status.
+- Using --program-suffix/--program-prefix is portable.
 
 ** Generic macros
 - AC_CHECK_HEADER and AC_CHECK_HEADERS support a fourth argument to
Index: acgeneral.m4
===================================================================
RCS file: /cvs/autoconf/acgeneral.m4,v
retrieving revision 1.735
diff -u -u -r1.735 acgeneral.m4
--- acgeneral.m4 2001/06/17 18:14:28 1.735
+++ acgeneral.m4 2001/06/20 19:01:09
@@ -1615,24 +1615,23 @@
   --program-suffix=SUFFIX            append SUFFIX to installed program names
   --program-transform-name=PROGRAM   run sed PROGRAM on installed program names
 m4_divert_pop([HELP_BEGIN])dnl
-if test "$program_transform_name" = s,x,x,; then
+test $program_transform_name = s,x,x, &&
   program_transform_name=
-else
-  # Double any \ or $.  echo might interpret backslashes.
-  cat <<\EOF >conftest.sed
-s,\\,\\\\,g; s,\$,$$,g
-EOF
-  program_transform_name=`echo $program_transform_name | sed -f conftest.sed`
-  rm -f conftest.sed
-fi
 test "$program_prefix" != NONE &&
   program_transform_name="s,^,${program_prefix},;$program_transform_name"
 # Use a double $ so make ignores it.
 test "$program_suffix" != NONE &&
-  program_transform_name="s,\$\$,${program_suffix},;$program_transform_name"
-
-# sed with no file args requires a program.
-test -z "$program_transform_name" && program_transform_name="s,x,x,"
+  program_transform_name="s,\$,${program_suffix},;$program_transform_name"
+# Double any \ or $.  echo might interpret backslashes.
+# No trailing `;' due to the concatenation above.
+cat <<\EOF >conftest.sed
+s/\\/\\\\/g;
+s/\$/$$/g
+s/;*$//
+s/^$/s,x,x/
+EOF
+program_transform_name=`echo $program_transform_name | sed -f conftest.sed`
+rm -f conftest.sed
 ])# AC_ARG_PROGRAM
 
 
Index: doc/autoconf.texi
===================================================================
RCS file: /cvs/autoconf/doc/autoconf.texi,v
retrieving revision 1.472
diff -u -u -r1.472 autoconf.texi
--- doc/autoconf.texi 2001/06/19 06:45:18 1.472
+++ doc/autoconf.texi 2001/06/20 19:01:10
@@ -8422,6 +8422,14 @@
 Sed scripts should not use branch labels longer than 8 characters and
 should not contain comments.
 
+Don't include extra @samp{;}, as some @command{sed}, such as NetBSD
+1.4.2's, try to interpret the second as a command:
+
address@hidden
+$ echo a | sed 's/x/x/;;s/x/x/'
+sed: 1: "s/x/x/;;s/x/x/": invalid command code ;
address@hidden example
+
 Input should have reasonably long lines, since some @command{sed} have
 an input buffer limited to 4000 bytes.
 
@@ -9069,10 +9077,12 @@
 installed as @file{/usr/local/bin/gdiff}.
 
 As a more sophisticated example, you could use
+
 @example
 --program-transform-name='s/^/g/; s/^gg/g/; s/^gless/less/'
 @end example
 @noindent
+
 to prepend @samp{g} to most of the program names in a source tree,
 excepting those like @code{gdb} that already have one and those like
 @code{less} and @code{lesskey} that aren't @sc{gnu} programs.  (That is
@@ -9119,6 +9129,15 @@
         for p in $(PROGRAMS); do \
           rm -f $(bindir)/`echo $$p | sed '$(transform)'`; \
         done
address@hidden example
+
+It is guaranteed that @code{program_transform_name} is never empty, and
+that there are no useless separators.  Therefore you may safely embed
address@hidden within a sed program using @samp{;}:
+
address@hidden
+transform = @@program_transform_name@@
+transform_exe = s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/
 @end example
 
 Whether to do the transformations on documentation files (Texinfo or



reply via email to

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