automake
[Top][All Lists]
Advanced

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

stamph processing fix


From: Derek R. Price
Subject: stamph processing fix
Date: Tue, 03 Jul 2001 12:19:32 -0400

Hi!

Akim told me awhile back to port forward and resubmit some patches if
I noticed that they hadn't been accepted after some time had passed.
Anyway, it's been awhile, so here's a resubmission of the patch that
fixes the stamp-h? processing which configure is currently doing.

Basically, the old configure creates the initial stamp files in the
wrong places.

This fixes that as well as adding support for a more concise, less
loopy, more correctly placed, and less knowledgable (it doesn't need to
check for existance of directories and create them sometimes) configure
script when AC_FOREACH is available.

Derek

--
Derek Price                      CVS Solutions Architect ( http://CVSHome.org )
mailto:address@hidden         CollabNet ( http://collab.net )
--
It does me no injury for my neighbor to say there are twenty gods or no god.
It neither picks my pocket nor breaks my leg.

                        - Thomas Jefferson


? tmp.diff
Index: ChangeLog
===================================================================
RCS file: /cvs/automake/automake/ChangeLog,v
retrieving revision 1.1448
diff -u -r1.1448 ChangeLog
--- ChangeLog   2001/07/03 04:19:35     1.1448
+++ ChangeLog   2001/07/03 15:46:09
@@ -1,3 +1,12 @@
+2001-07-02  Derek Price  <address@hidden>
+
+       * m4/header.m4 (AM_CONFIG_HEADER): Create stamp-h files in the correct
+       locations.
+       * tests/dirname.test: New test.
+       * tests/stamph2.test: New test.
+       * tests/Makefile.am: Add new tests.
+       * tests/Makefile.in: Regenerated.
+
 2001-07-02  Tom Tromey  <address@hidden>
 
        Fix for libtool2.test:
Index: m4/header.m4
===================================================================
RCS file: /cvs/automake/automake/m4/header.m4,v
retrieving revision 1.7
diff -u -r1.7 header.m4
--- header.m4   2000/08/06 12:36:53     1.7
+++ header.m4   2001/07/03 15:46:10
@@ -10,19 +10,57 @@
 AC_PREREQ([2.12])
 
 AC_DEFUN([AM_CONFIG_HEADER],
+[ifdef([AC_FOREACH],dnl
+        [dnl init our file count if it isn't already
+        m4_ifndef([_AM_Config_Header_Index], 
m4_define([_AM_Config_Header_Index], [0]))
+        dnl prepare to store our destination file list for use in config.status
+        AC_FOREACH([_AM_File], [$1],
+                   [m4_pushdef([_AM_Dest], m4_patsubst(_AM_File, [:.*]))
+                   m4_define([_AM_Config_Header_Index], 
m4_incr(_AM_Config_Header_Index))
+                   dnl and add it to the list of files AC keeps track of, along
+                   dnl with our hook
+                   AC_CONFIG_HEADERS(_AM_File,
+dnl COMMANDS, [, INIT-CMDS]
+[# update the timestamp
+echo timestamp 
>"AS_ESCAPE(_AM_DIRNAME(]_AM_Dest[))/stamp-h]_AM_Config_Header_Index["
+][$2]m4_ifval([$3], [, [$3]]))dnl AC_CONFIG_HEADERS
+                   m4_popdef([_AM_Dest])])],dnl
 [AC_CONFIG_HEADER([$1])
   AC_OUTPUT_COMMANDS(
    ifelse(patsubst([$1], [[^ ]], []),
          [],
          [test -z "$CONFIG_HEADERS" || echo timestamp >dnl
-          patsubst([$1], [^\([^:]*/\)?.*], [\1])stamp-h]),
-  [am_indx=1
-  for am_file in $1; do
-    case " $CONFIG_HEADERS " in
-    *" $am_file "*)
-      echo timestamp > `echo $am_file | sed 
's%:.*%%;s%[^/]*$%%'`stamp-h$am_indx
-      ;;
-    esac
-    am_indx=\`expr \$am_indx + 1\`
-  done])
-])
+          patsubst([$1], [^\([^:]*/\)?.*], [\1])stamp-h]),dnl
+[am_indx=1
+for am_file in $1; do
+  case " \$CONFIG_HEADERS " in
+  *" \$am_file "*)
+    am_dir=\`echo \$am_file |sed 's%:.*%%;s%[^/]*\$%%'\`
+    if test -n "\$am_dir"; then
+      am_tmpdir=\`echo \$am_dir |sed 's%^\(/*\).*\$%\1%'\`
+      for am_subdir in \`echo \$am_dir |sed 's%/% %'\`; do
+        am_tmpdir=\$am_tmpdir\$am_subdir/
+        if test ! -d \$am_tmpdir; then
+          mkdir \$am_tmpdir
+        fi
+      done
+    fi
+    echo timestamp > "\$am_dir"stamp-h\$am_indx
+    ;;
+  esac
+  am_indx=\`expr \$am_indx + 1\`
+done])
+])]) # AM_CONFIG_HEADER
+
+# _AM_DIRNAME(PATH)
+# -----------------
+# Like AS_DIRNAME, only do it during macro expansion
+AC_DEFUN([_AM_DIRNAME],
+       [m4_if(m4_regexp([$1], [^.*[^/]//*[^/][^/]*/*$]), -1,
+             m4_if(m4_regexp([$1], [^//\([^/]\|$\)]), -1,
+                   m4_if(m4_regexp([$1], [^/.*]), -1,
+                         [.],
+                         m4_patsubst([$1], [^\(/\).*], [\1])),
+                   m4_patsubst([$1], [^\(//\)\([^/].*\|$\)], [\1])),
+             m4_patsubst([$1], [^\(.*[^/]\)//*[^/][^/]*/*$], [\1]))[]dnl
+]) # _AM_DIRNAME
Index: tests/Makefile.am
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.am,v
retrieving revision 1.319
diff -u -r1.319 Makefile.am
--- Makefile.am 2001/07/03 04:19:36     1.319
+++ Makefile.am 2001/07/03 15:46:10
@@ -101,6 +101,7 @@
 depend2.test \
 depend3.test \
 depend4.test \
+dirname.test \
 discover.test \
 distcommon.test \
 distdir.test \
@@ -247,6 +248,7 @@
 spell3.test \
 spelling.test \
 stamph.test \
+stamph2.test \
 stdlib.test \
 subdir.test \
 subdir2.test \
Index: tests/Makefile.in
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.in,v
retrieving revision 1.418
diff -u -r1.418 Makefile.in
--- Makefile.in 2001/07/03 04:19:36     1.418
+++ Makefile.in 2001/07/03 15:46:11
@@ -167,6 +167,7 @@
 depend2.test \
 depend3.test \
 depend4.test \
+dirname.test \
 discover.test \
 distcommon.test \
 distdir.test \
@@ -313,6 +314,7 @@
 spell3.test \
 spelling.test \
 stamph.test \
+stamph2.test \
 stdlib.test \
 subdir.test \
 subdir2.test \
Index: tests/dirname.test
===================================================================
RCS file: dirname.test
diff -N dirname.test
--- /dev/null   Tue May  5 13:32:27 1998
+++ dirname.test        Tue Jul  3 08:46:11 2001
@@ -0,0 +1,43 @@
+#! /bin/sh
+
+# Test the operation of the _AM_DIRNAME macro from m4/header.m4
+
+. $srcdir/defs || exit 1
+
+cat > configure.in << 'END'
+AC_PLAIN_SCRIPT
+echo "1 /a/path/to/a/file      = _AM_DIRNAME([/a/path/to/a/file])"
+echo "2 another/path/to/a/file = _AM_DIRNAME([another/path/to/a/file])"
+echo "3 file                   = _AM_DIRNAME([file])"
+echo "4 //                     = _AM_DIRNAME([//])"
+echo "5 //file                 = _AM_DIRNAME([//file])"
+echo "6 /                      = _AM_DIRNAME([/])"
+echo "7 /file                  = _AM_DIRNAME([/file])"
+END
+
+# Fail gracefully if no autoconf.
+$needs_autoconf
+
+$ACLOCAL || exit 1
+$AUTOCONF || exit 1
+
+# fail gracefully if autoconf didn't support AC_PLAIN_SCRIPT, because it won't
+# support our regexps anyhow
+test -s configure || exit 77
+
+./configure >got || exit 1
+
+cat >wanted <<EOF
+1 /a/path/to/a/file      = /a/path/to/a
+2 another/path/to/a/file = another/path/to/a
+3 file                   = .
+4 //                     = //
+5 //file                 = //
+6 /                      = /
+7 /file                  = /
+EOF
+
+diff -u wanted got || exit 1
+
+exit 0
+
Index: tests/stamph2.test
===================================================================
RCS file: stamph2.test
diff -N stamph2.test
--- /dev/null   Tue May  5 13:32:27 1998
+++ stamph2.test        Tue Jul  3 08:46:11 2001
@@ -0,0 +1,29 @@
+#! /bin/sh
+
+# Make sure stamp-h* files are created where we expect
+
+. $srcdir/defs || exit 1
+
+cat > configure.in << 'END'
+AC_INIT(Makefile.am)
+AM_INIT_AUTOMAKE(nonesuch, nonesuch)
+AM_CONFIG_HEADER(firstfile.h sdir/secondfile.h thirdfile.h)
+AC_OUTPUT(Makefile)
+END
+
+: > Makefile.am
+mkdir sdir
+: > firstfile.h.in
+: > sdir/secondfile.h.in
+: > thirdfile.h.in
+
+# Fail gracefully if no autoconf.
+$needs_autoconf
+
+$ACLOCAL || exit 1
+$AUTOCONF || exit 1
+$AUTOMAKE || exit 1
+./configure || exit 1
+
+(test -f stamp-h1 && test -f sdir/stamp-h2 && test -f stamp-h3) || exit 1
+exit 0

reply via email to

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