bug-cppi
[Top][All Lists]
Advanced

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

[bug-cppi] [PATCH 1/3] build: use new gnulib module: non-recursive-gnuli


From: Jim Meyering
Subject: [bug-cppi] [PATCH 1/3] build: use new gnulib module: non-recursive-gnulib-prefix-hack
Date: Wed, 19 Sep 2012 19:43:46 +0200

[Cc'ing Akim, in case he wants to do this to bison.  If so,
with three projects using it, I'll move the module to gnulib. ]

I noticed "make distcheck" was failing due to cppi's slightly
aging prefix-gnulib-mk script not interacting well with
gnulib-tool-generated gnulib.mk files.  The fix was to update
to use the more modular "module" that gnulib is now using.
It encapsulates that script, and the autoconf snippet that
goes with it.  To use it, you need to do these things once your
project uses non-recursive make:

  - copy the three files:

      gl/build-aux/prefix-gnulib-mk
      gl/m4/non-recursive-gnulib-prefix-hack.m4
      gl/modules/non-recursive-gnulib-prefix-hack

  - add the new module name to your list of modules in bootstrap.conf

  - make sure the bootstrap_post_import_hook() function in
    bootstrap.conf does this:

  # Massage lib/gnulib.mk before using it later in the bootstrapping process.
  build-aux/prefix-gnulib-mk --lib-name=$gnulib_name lib/$gnulib_mk


I've just pushed these:

>From e66c35939c9929c0a58045010ad6661e747ecf4d Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Wed, 19 Sep 2012 19:15:17 +0200
Subject: [PATCH 1/3] build: use new gnulib module:
 non-recursive-gnulib-prefix-hack

Well, it's not officially a gnulib module yet.  For now, it's used
only here and in coreutils.
* configure.ac: Remove the code I'd copied from bison's configure.ac,
since now it's done via code in this module's .m4 file.
* bootstrap.conf (gnulib_modules): Add that module name to the list.
(bootstrap_post_import_hook): Invoke from its new location: build-aux/.
* gl/m4/non-recursive-gnulib-prefix-hack.m4: Likewise.
* gl/modules/non-recursive-gnulib-prefix-hack: Likewise.
* gl/build-aux/prefix-gnulib-mk: Copied from coreutils.
This is an improved version of ...
* etc/prefix-gnulib-mk: ...this.  Remove file.
---
 bootstrap.conf                              |  3 ++-
 configure.ac                                | 15 -------------
 {etc => gl/build-aux}/prefix-gnulib-mk      | 31 ++++++++++++++++++++-----
 gl/m4/non-recursive-gnulib-prefix-hack.m4   | 35 +++++++++++++++++++++++++++++
 gl/modules/non-recursive-gnulib-prefix-hack | 25 +++++++++++++++++++++
 5 files changed, 88 insertions(+), 21 deletions(-)
 rename {etc => gl/build-aux}/prefix-gnulib-mk (83%)
 create mode 100644 gl/m4/non-recursive-gnulib-prefix-hack.m4
 create mode 100644 gl/modules/non-recursive-gnulib-prefix-hack

diff --git a/bootstrap.conf b/bootstrap.conf
index 8b7e002..2f2ef13 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -42,6 +42,7 @@ gnulib_modules="
   malloc-gnu
   maintainer-makefile
   manywarnings
+  non-recursive-gnulib-prefix-hack
   obstack
   progname
   quote
@@ -130,7 +131,7 @@ tar        -
 bootstrap_post_import_hook()
 {
   # Massage lib/gnulib.mk before using it later in the bootstrapping process.
-  etc/prefix-gnulib-mk --lib-name=$gnulib_name lib/$gnulib_mk
+  build-aux/prefix-gnulib-mk --lib-name=$gnulib_name lib/$gnulib_mk
 }

 bootstrap_epilogue()
diff --git a/configure.ac b/configure.ac
index f7c434d..7897f5b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -88,21 +88,6 @@ AC_HEADER_ASSERT
 AM_GNU_GETTEXT([external])
 AM_GNU_GETTEXT_VERSION([0.18.1])

-# This is copied from bison.  FIXME: keep it in sync!
-# We use gnulib, but from lib/local.mk instead of lib/Makefile.am.
-# So prefix paths with lib/.  See also etc/prefix-gnulib-mk.
-gl_LIBOBJS=`echo "$gl_LIBOBJS" | sed -e 's, , lib/,g'`
-# Listing the names of the variables to prefix is error-prone.
-# Rather, adjust all the AC_SUBST variables whose name ends in '_H',
-# and whose content ends in '.h'.
-for ac_var in $ac_subst_vars
-do
-  eval "ac_val=\$$ac_var"
-  case $ac_var=$ac_val in
-    (*_H=*.h) eval "$ac_var=lib/\$$ac_var";;
-  esac
-done
-
 # Now that configure no longer creates src/ or man/, create them here.
 # Doing it this way is more maintainable that adding to each individual
 # Makefile rule that creates a file in one of those sub-directories.
diff --git a/etc/prefix-gnulib-mk b/gl/build-aux/prefix-gnulib-mk
similarity index 83%
rename from etc/prefix-gnulib-mk
rename to gl/build-aux/prefix-gnulib-mk
index 03ce18f..f0806d7 100755
--- a/etc/prefix-gnulib-mk
+++ b/gl/build-aux/prefix-gnulib-mk
@@ -66,7 +66,8 @@ sub prefix_word ($)
 {
   local ($_) = @_;
   $_ = $prefix . $_
-    unless /^-/ || m{^\$\(\w+\)} || $_ eq "Makefile" || $_ eq '\\';
+    unless (/^-/ || m{^\$\(\w+\)} || $_ eq "Makefile" || $_ eq '\\'
+            || $_ eq '@ALLOCA@');
   return $_;
 }

@@ -90,7 +91,14 @@ sub prefix_assignment ($$)

   # Some variables are initialized by gnulib.mk, and we don't want
   # that.  Change '=' to '+='.
-  if ($lhs_and_assign_op =~ 
/^(SUBDIRS|EXTRA_DIST|BUILT_SOURCES|SUFFIXES|MOSTLYCLEANFILES|CLEANFILES|DISTCLEANFILES|MAINTAINERCLEANFILES|AM_CFLAGS|AM_CPPFLAGS|AM_GNU_GETTEXT)
 =/)
+  if ($lhs_and_assign_op =~ /^GPERF =$/)
+    {
+      # Do not change the RHS, which specifies the GPERF program.
+    }
+  elsif ($lhs_and_assign_op =~
+      /^(SUBDIRS|EXTRA_DIST|BUILT_SOURCES|SUFFIXES|MOSTLYCLEANFILES
+         |CLEANFILES|DISTCLEANFILES|MAINTAINERCLEANFILES|AM_CFLAGS
+         |AM_CPPFLAGS|AM_GNU_GETTEXT)\ =/x)
     {
       $lhs_and_assign_op =~ s/=/+=/;
     }
@@ -99,9 +107,10 @@ sub prefix_assignment ($$)
     {
       $lhs_and_assign_op =~ s/^/# /;
     }
-  # Don't touch suffixes.
   elsif ($lhs_and_assign_op =~ /^SUFFIXES /)
     {
+      # Elide any SUFFIXES assignment or concatenation.
+      $lhs_and_assign_op =~ s/^/# /;
     }
   # The words are (probably) paths to files in lib/: prefix them.
   else
@@ -142,8 +151,20 @@ sub prefix ($)
   # Unfortunately, as a result we sometimes have lib/lib.
   s{($prefix){2}}{$1}g;

-  # $(srcdir) is actually $(top_srcdir)/lib.
-  s{\$\(srcdir\)}{\$(top_srcdir)/lib}g;
+  # lib_libcoreutils_a_SOURCES += \
+  #   imaxtostr.c \
+  #   inttostr.c \
+  #   offtostr.c \
+  #   uinttostr.c \
+  #   umaxtostr.c
+  # The above are not handled since they're on continued lines, so
+  # deal with them manually:
+  s{^  ((?:[ui]max|u?int|off)tostr\.c(:? \\)?)$}{  $prefix$1}gm;
+
+  # $(srcdir)/ is actually $(top_srcdir)/$prefix/.
+  # The trailing slash is required to avoid matching this rule:
+  #   test '$(srcdir)' = . || rm -f $(top_builddir)/GNUmakefile
+  s{\$\(srcdir\)/}{\$(top_srcdir)/$prefix}g;

   # Sometimes, t-$@ is used instead of address@hidden, which, of course, does
   # not work when we have a $@ with a directory in it.
diff --git a/gl/m4/non-recursive-gnulib-prefix-hack.m4 
b/gl/m4/non-recursive-gnulib-prefix-hack.m4
new file mode 100644
index 0000000..aeb0cc4
--- /dev/null
+++ b/gl/m4/non-recursive-gnulib-prefix-hack.m4
@@ -0,0 +1,35 @@
+dnl Copyright (C) 2012 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl gl_NON_RECURSIVE_GNULIB_PREFIX_HACK LIB_DIR
+dnl Adjust configure-set $gl_LIBOBJS and each AC_SUBST'd *_H variable
+dnl with a value ending in ".h" to reflect that these files are located
+dnl in the directory specified by LIB_DIR.
+AC_DEFUN([gl_NON_RECURSIVE_GNULIB_PREFIX_HACK],
+[
+  # Tell AC_LIBSOURCES where to find source files like alloca.c.
+  AC_CONFIG_LIBOBJ_DIR([lib])
+
+  # This hack originated in bison.  It is required when using non-recursive
+  # automake rules to build from gnulib-provided lib/ sources.  Hence, LIB_DIR
+  # is usually simply "lib".  Those rules use the list of names like "fchdir.o"
+  # and "strstr.o" in gl_LIBOBJS.  With non-recursive make, we must prefix each
+  # such file name with the "lib/" prefix.  See also 
build-aux/prefix-gnulib-mk.
+  gl_LIBOBJS=`echo "$gl_LIBOBJS" | sed -e 's, , $1/,g'`
+
+  # Listing the names of the variables to prefix is error-prone.
+  # Rather, adjust each AC_SUBST'd variable whose name ends in '_H'
+  # and whose value ends in '.h'.
+  for ac_var in $ac_subst_vars
+  do
+    eval "ac_val=\$$ac_var"
+    case $ac_var:$ac_val in
+      (*_H:*.h) eval "$ac_var=$1/\$$ac_var";;
+    esac
+  done
+
+  # If $ALLOCA is not empty, prefix its value with "lib/".
+  test -n "$ALLOCA" && ALLOCA="lib/$ALLOCA"
+])
diff --git a/gl/modules/non-recursive-gnulib-prefix-hack 
b/gl/modules/non-recursive-gnulib-prefix-hack
new file mode 100644
index 0000000..26cd914
--- /dev/null
+++ b/gl/modules/non-recursive-gnulib-prefix-hack
@@ -0,0 +1,25 @@
+Description:
+Compute a good buffer size for dealing with two files.
+
+Files:
+build-aux/prefix-gnulib-mk
+m4/non-recursive-gnulib-prefix-hack.m4
+
+Depends-on:
+
+configure.ac:
+dnl Run our hack near the end, just before config.status creation.
+dnl It must happen late, i.e., after gl_LIBOBJS has been finalized.
+AC_CONFIG_COMMANDS_PRE([
+  gl_NON_RECURSIVE_GNULIB_PREFIX_HACK([lib])
+  ])
+
+Makefile.am:
+
+Include:
+
+License:
+unlimited
+
+Maintainer:
+Jim Meyering
--
1.7.12.1.382.gb0576a6


>From ab13d4aae2ece4a98dd9f2ee7b74cdce6c491793 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Wed, 19 Sep 2012 19:16:04 +0200
Subject: [PATCH 2/3] build: update gnulib submodule to latest

---
 gnulib | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gnulib b/gnulib
index 0e3af50..3ff028f 160000
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit 0e3af50c9e20938bd1cea0182bf749ce61cb6782
+Subproject commit 3ff028fd56c2aa14ce5e380e81b91e27a0bf8e2c
--
1.7.12.1.382.gb0576a6


>From 6d6d0a30415fd47be94163c5555671b10c3f674c Mon Sep 17 00:00:00 2001
From: Akim Demaille <address@hidden>
Date: Wed, 19 Sep 2012 15:43:43 +0200
Subject: [PATCH 3/3] build: fix gperf fix

* src/local.mk (src/cpp-cond.c): Use a more accurate pattern
to make the lookup function static.  For details, see
https://lists.gnu.org/archive/html/bug-cppi/2012-03/msg00001.html
---
 src/local.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/local.mk b/src/local.mk
index 01231d1..c43c32e 100644
--- a/src/local.mk
+++ b/src/local.mk
@@ -28,7 +28,8 @@ GPERF_OPTIONS = \
 src/cpp-cond.c: src/cpp.gp
        $(AM_V_GEN)rm -f $@ address@hidden
        $(AM_V_at)$(GPERF) $(GPERF_OPTIONS) $< \
-         | perl -ne '/__GNUC_STDC_INLINE__/ and print "static\n"; print' \
+         | perl -0777 -p \
+            -e 's/const struct KW \*\ncpp_cond_lookup/static\n$$&/' \
          > address@hidden
        $(AM_V_at)chmod a-w address@hidden
        $(AM_V_at)mv address@hidden $@
--
1.7.12.1.382.gb0576a6



reply via email to

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