[augeas-devel] [PATCH 5 of 7] Infrastructure and import of gnulib modules

David Lutterkort dlutter at redhat.com
Thu May 29 23:56:47 UTC 2008


8 files changed, 154 insertions(+), 17 deletions(-)
.hgignore         |    1 
Makefile.am       |    6 ++--
autogen.sh        |   44 ++++++++++++++++++++++++++---
bootstrap         |   79 +++++++++++++++++++++++++++++++++++++++++++++++++++++
configure.ac      |   22 ++++++++++++--
src/Makefile.am   |   11 ++++---
src/augeas.c      |    1 
tests/Makefile.am |    7 +++-


# HG changeset patch
# User David Lutterkort <dlutter at redhat.com>
# Date 1212104855 25200
# Node ID 010976c03f1efb044e31c5b4b1c5db3fd8572faf
# Parent  d86534b6dc334b7c62385e45337d4cacdb392bf9
Infrastructure and import of gnulib modules

We do not keep the gnulib sources in our own repo. Instead, autogen.sh now
calls out to bootstrap to pull in needed files from gnulib.

The bootstrap script was copied from libvirt.

diff -r d86534b6dc33 -r 010976c03f1e .hgignore
--- a/.hgignore	Thu May 29 16:42:57 2008 -0700
+++ b/.hgignore	Thu May 29 16:47:35 2008 -0700
@@ -1,6 +1,7 @@
 .*~$
 ^augeas\.(pc|spec)$
 ^build/
+^gnulib/
 ^config\.h(\.in)?$
 ^aclocal\.m4$
 ^autom4te\.cache/
diff -r d86534b6dc33 -r 010976c03f1e Makefile.am
--- a/Makefile.am	Thu May 29 16:42:57 2008 -0700
+++ b/Makefile.am	Thu May 29 16:47:35 2008 -0700
@@ -1,4 +1,6 @@ SUBDIRS=src tests man
-SUBDIRS=src tests man
+SUBDIRS=gnulib/lib src gnulib/tests tests man
+
+ACLOCAL_AMFLAGS = -I gnulib/m4
 
 lensdir=$(datadir)/augeas/lenses
 lenstestdir=$(datadir)/augeas/lenses/tests
@@ -13,5 +15,3 @@ pkgconfig_DATA = augeas.pc
 
 distclean-local:
 	-rm -rf $(top_builddir)/build
-
-
diff -r d86534b6dc33 -r 010976c03f1e autogen.sh
--- a/autogen.sh	Thu May 29 16:42:57 2008 -0700
+++ b/autogen.sh	Thu May 29 16:47:35 2008 -0700
@@ -1,7 +1,27 @@
-#!/bin/sh
+#!/bin/bash
 # Run this to generate all the initial makefiles, etc.
 
+usage() {
+  echo >&2 "\
+Usage: $0 [OPTION]...
+Generate makefiles and other infrastructure needed for building
+
+
+Options:
+ --gnulib-srcdir=DIRNAME  Specify the local directory where gnulib
+                          sources reside.  Use this if you already
+                          have gnulib sources on your machine, and
+                          do not want to waste your bandwidth downloading
+                          them again.
+ --help                   Print this message
+ any other option         Pass to the 'configure' script verbatim
+
+Running without arguments will suffice in most cases.
+"
+}
+
 BUILD_AUX=build/aux
+GNULIB_DIR=gnulib
 
 set -e
 srcdir=`dirname $0`
@@ -9,6 +29,21 @@ test -z "$srcdir" && srcdir=.
 
 THEDIR=`pwd`
 cd $srcdir
+
+# Split out options for bootstrap and for configure
+declare -a CF_ARGS
+for option
+do
+  case $option in
+  --help)
+    usage
+    exit;;
+  --gnulib-srcdir=*)
+    GNULIB_SRCDIR=$option;;
+  *)
+    CF_ARGS[${#CF_ARGS[@]}]=$option;;
+  esac
+done
 
 #Check for OSX
 case `uname -s` in
@@ -39,7 +74,7 @@ if test "$DIE" -eq 1; then
 	exit 1
 fi
 
-if test -z "$*"; then
+if test -z "${CF_ARGS[*]}"; then
 	echo "I am going to run ./configure with --enable-warnings - if you "
         echo "wish to pass any extra arguments to it, please specify them on "
         echo "the $0 command line."
@@ -48,7 +83,8 @@ mkdir -p $BUILD_AUX
 mkdir -p $BUILD_AUX
 
 $LIBTOOLIZE --copy --force
-aclocal
+./bootstrap $GNULIB_SRCDIR
+aclocal -I gnulib/m4
 autoheader
 automake --add-missing
 autoconf
@@ -60,7 +96,7 @@ if test x$OBJ_DIR != x; then
     cd "$OBJ_DIR"
 fi
 
-$srcdir/configure --enable-warnings "$@" && {
+$srcdir/configure --enable-warnings "${CF_ARGS[@]}" && {
     echo
     echo "Now type 'make' to compile augeas."
 }
diff -r d86534b6dc33 -r 010976c03f1e bootstrap
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bootstrap	Thu May 29 16:47:35 2008 -0700
@@ -0,0 +1,79 @@
+#!/bin/sh
+
+usage() {
+  echo >&2 "\
+Usage: $0 [OPTION]...
+Bootstrap this package from the checked-out sources.
+
+Options:
+ --gnulib-srcdir=DIRNAME  Specify the local directory where gnulib
+                          sources reside.  Use this if you already
+                          have gnulib sources on your machine, and
+                          do not want to waste your bandwidth downloading
+                          them again.
+
+If the file bootstrap.conf exists in the current working directory, its
+contents are read as shell variables to configure the bootstrap.
+
+Running without arguments will suffice in most cases.
+"
+}
+
+for option
+do
+  case $option in
+  --help)
+    usage
+    exit;;
+  --gnulib-srcdir=*)
+    GNULIB_SRCDIR=${option#--gnulib-srcdir=};;
+  *)
+    echo >&2 "$0: $option: unknown option"
+    exit 1;;
+  esac
+done
+
+cleanup_gnulib() {
+  st=$?
+  rm -fr .gnulib
+  exit $st
+}
+
+case ${GNULIB_SRCDIR--} in
+-)
+  if [ ! -d .gnulib ]; then
+    echo "$0: getting gnulib files..."
+
+    trap cleanup_gnulib 1 2 13 15
+
+    git clone --depth 1 git://git.sv.gnu.org/gnulib .gnulib ||
+      cleanup_gnulib
+
+    trap - 1 2 13 15
+  fi
+  GNULIB_SRCDIR=.gnulib
+esac
+
+gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
+<$gnulib_tool || exit
+
+modules='
+argz
+regex
+strndup
+'
+
+# Tell gnulib to:
+#   require LGPLv2+
+#   put *.m4 files in new gnulib/m4/ dir
+#   put *.[ch] files in new gnulib/lib/ dir.
+
+$gnulib_tool			\
+  --lgpl=2			\
+  --with-tests			\
+  --m4-base=gnulib/m4		\
+  --source-base=gnulib/lib	\
+  --tests-base=gnulib/tests	\
+  --aux-dir=build/aux           \
+  --quiet                       \
+  --import $modules
diff -r d86534b6dc33 -r 010976c03f1e configure.ac
--- a/configure.ac	Thu May 29 16:42:57 2008 -0700
+++ b/configure.ac	Thu May 29 16:47:35 2008 -0700
@@ -7,6 +7,16 @@ AC_GNU_SOURCE
 AC_GNU_SOURCE
 
 AC_PROG_CC
+gl_EARLY
+
+
+dnl gl_INIT uses m4_foreach_w, yet that is not defined in autoconf-2.59.
+dnl In order to accommodate developers with such old tools, here's a
+dnl replacement definition.
+m4_ifndef([m4_foreach_w],
+  [m4_define([m4_foreach_w],
+    [m4_foreach([$1], m4_split(m4_normalize([$2]), [ ]), [$3])])])
+
 AC_PROG_LIBTOOL
 AC_PROG_YACC
 AC_PROG_LEX
@@ -20,8 +30,12 @@ AUGEAS_CHECK_READLINE
 AUGEAS_CHECK_READLINE
 AC_CHECK_FUNCS([open_memstream])
 
-AC_OUTPUT(Makefile
-          src/Makefile
-          man/Makefile
-          tests/Makefile
+gl_INIT
+
+AC_OUTPUT(Makefile \
+          gnulib/lib/Makefile \
+          gnulib/tests/Makefile \
+          src/Makefile \
+          man/Makefile \
+          tests/Makefile \
           augeas.pc augeas.spec)
diff -r d86534b6dc33 -r 010976c03f1e src/Makefile.am
--- a/src/Makefile.am	Thu May 29 16:42:57 2008 -0700
+++ b/src/Makefile.am	Thu May 29 16:47:35 2008 -0700
@@ -1,5 +1,8 @@
 
-AM_CFLAGS = @AUGEAS_CFLAGS@ @WARN_CFLAGS@
+GNULIB= ../gnulib/lib/libgnu.la
+GNULIB_CFLAGS= -I $(top_srcdir)/gnulib/lib
+
+AM_CFLAGS = @AUGEAS_CFLAGS@ @WARN_CFLAGS@ $(GNULIB_CFLAGS)
 
 AM_YFLAGS=-d -p spec_
 
@@ -18,13 +21,13 @@ libaugeas_la_SOURCES = augeas.h augeas.c
         syntax.c syntax.h parser.y builtin.c lens.c lens.h regexp.c \
 	transform.c get.c put.c list.h
 libaugeas_la_LDFLAGS = -Wl,--version-script=$(srcdir)/augeas_sym.version
-libaugeas_la_LIBADD = liblexer.la libfa.la
+libaugeas_la_LIBADD = liblexer.la libfa.la $(GNULIB)
 
 augtool_SOURCES = augtool.c
-augtool_LDADD = libaugeas.la $(READLINE_LIBS)
+augtool_LDADD = libaugeas.la $(READLINE_LIBS) $(GNULIB)
 
 augparse_SOURCES = augparse.c
-augparse_LDADD = libaugeas.la
+augparse_LDADD = libaugeas.la $(GNULIB)
 
 libfa_la_SOURCES = fa.c fa.h hash.c hash.h memory.c memory.h ref.h
 
diff -r d86534b6dc33 -r 010976c03f1e src/augeas.c
--- a/src/augeas.c	Thu May 29 16:42:57 2008 -0700
+++ b/src/augeas.c	Thu May 29 16:47:35 2008 -0700
@@ -28,6 +28,7 @@
 
 #include <fnmatch.h>
 #include <argz.h>
+#include <string.h>
 
 /* We always have a toplevel entry for P_ROOT */
 #define P_ROOT   "augeas"
diff -r d86534b6dc33 -r 010976c03f1e tests/Makefile.am
--- a/tests/Makefile.am	Thu May 29 16:42:57 2008 -0700
+++ b/tests/Makefile.am	Thu May 29 16:47:35 2008 -0700
@@ -1,6 +1,9 @@ AUGTESTS=$(wildcard *.rb)
 AUGTESTS=$(wildcard *.rb)
 
-AM_CFLAGS = @AUGEAS_CFLAGS@ @WARN_CFLAGS@
+GNULIB= ../gnulib/lib/libgnu.la
+GNULIB_CFLAGS= -I $(top_srcdir)/gnulib/lib
+
+AM_CFLAGS = @AUGEAS_CFLAGS@ @WARN_CFLAGS@ $(GNULIB_CFLAGS)
 
 valgrind: fatest
 	libtool --mode=execute valgrind --quiet --leak-check=full ./fatest
@@ -24,4 +27,4 @@ INCLUDES = -I$(top_srcdir)/src
 INCLUDES = -I$(top_srcdir)/src
 
 fatest_SOURCES = fatest.c cutest.c cutest.h
-fatest_LDADD = @top_builddir@/src/libaugeas.la
+fatest_LDADD = @top_builddir@/src/libaugeas.la $(GNULIB)




More information about the augeas-devel mailing list