[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-cppi] [PATCH 02/19] update bootstrap; don't recurse into lib/ or sr
From: |
Jim Meyering |
Subject: |
[bug-cppi] [PATCH 02/19] update bootstrap; don't recurse into lib/ or src/ |
Date: |
Wed, 25 Jan 2012 09:22:39 +0100 |
From: Jim Meyering <address@hidden>
* bootstrap.conf (gnulib_modules): Remove alloca, not used.
(gnulib_tool_option_extras): Adapt to new bootstrap.
(bootstrap_post_import_hook): Define, now that make does not
recurse into lib/
* configure.ac (AM_PROG_CC_C_O): Use this, not AC_PROC_CC.
(AC_CONFIG_FILES): Remove lib/Makefile and src/Makefile.
* lib/local.mk: Renamed from lib/Makefile.am, with modifications.
* src/local.mk: Renamed from src/Makefile.am, with modifications.
* etc/prefix-gnulib-mk: New file, from bison. Its job is to
rewrite the rules in lib/gnulib.mk to work with automake's
subdir-objects option.
* man/Makefile.am (programs): Adjust, now that the $(bin_PROGRAMS)-
defining Makefile is in "..", not src/.
* src/system.h: Don't include <alloca.h>. Not needed.
---
.gitignore | 8 +-
Makefile.am | 19 ++-
bootstrap | 351 ++++++++++++++++++-----------------------
bootstrap.conf | 9 +-
configure.ac | 4 +-
etc/prefix-gnulib-mk | 220 ++++++++++++++++++++++++++
lib/Makefile.am | 9 -
lib/local.mk | 5 +
man/Makefile.am | 2 +-
src/{Makefile.am => local.mk} | 50 +++---
src/system.h | 2 -
11 files changed, 434 insertions(+), 245 deletions(-)
create mode 100755 etc/prefix-gnulib-mk
delete mode 100644 lib/Makefile.am
create mode 100644 lib/local.mk
rename src/{Makefile.am => local.mk} (69%)
diff --git a/.gitignore b/.gitignore
index 51c1ff7..4adfb48 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,11 +1,16 @@
*.o
-*/.deps
*~
+.deps
+.dirstamp
.tarball-version
.version
/ABOUT-NLS
/README-release
+/lib/glthread
+/m4
/maint.mk
+/tests/*.log
+/tests/*.trs
ABOUT-NLS
ChangeLog
GNUmakefile
@@ -42,4 +47,3 @@ po/POTFILES
po/cppi.pot
po/stamp-po
stamp-h1
-tests/*.log
diff --git a/Makefile.am b/Makefile.am
index 00153c5..582803e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,7 @@
## Process this file with automake to produce Makefile.in.
-SUBDIRS = lib po src tests man
+AUTOMAKE_OPTIONS = subdir-objects
+SUBDIRS = po . tests man
ACLOCAL_AMFLAGS = -I m4
@@ -27,3 +28,19 @@ BUILT_SOURCES = .version
distcheck-hook:
$(MAKE) my-distcheck
+
+###############################################
+# Initialization before completion by local.mk's.
+AM_CFLAGS = $(WARNING_CFLAGS) $(WERROR_CFLAGS)
+AM_CPPFLAGS =
+CLEANFILES =
+DISTCLEANFILES =
+MAINTAINERCLEANFILES =
+MOSTLYCLEANFILES =
+noinst_LIBRARIES =
+SUFFIXES =
+
+include lib/local.mk
+include src/local.mk
+# FIXME include man/local.mk
+# FIXME include tests/local.mk
diff --git a/bootstrap b/bootstrap
index ba580d4..6910abf 100755
--- a/bootstrap
+++ b/bootstrap
@@ -1,6 +1,6 @@
#! /bin/sh
# Print a version string.
-scriptversion=2011-01-21.16; # UTC
+scriptversion=2012-01-21.16; # UTC
# Bootstrap this package from checked-out sources.
@@ -38,10 +38,6 @@ export LC_ALL
local_gl_dir=gl
-# Temporary directory names.
-bt='._bootmp'
-bt_regex=`echo "$bt"| sed 's/\./[.]/g'`
-bt2=${bt}2
me=$0
usage() {
@@ -88,9 +84,12 @@ gnulib_modules=
# Any gnulib files needed that are not in modules.
gnulib_files=
-# A function to be called to edit gnulib.mk right after it's created.
+: ${AUTOPOINT=autopoint}
+: ${AUTORECONF=autoreconf}
+
+# A function to be called right after gnulib-tool is run.
# Override it via your own definition in bootstrap.conf.
-gnulib_mk_hook() { :; }
+bootstrap_post_import_hook() { :; }
# A function to be called after everything else in this script.
# Override it via your own definition in bootstrap.conf.
@@ -105,6 +104,11 @@ po_download_command_format=\
"rsync --delete --exclude '*.s1' -Lrtvz \
'translationproject.org::tp/latest/%s/' '%s'"
+# Fallback for downloading .po files (if rsync fails).
+po_download_command_format2=\
+"wget --mirror -nd -q -np -A.po -P '%s' \
+ http://translationproject.org/latest/%s/"
+
extract_package_name='
/^AC_INIT(/{
/.*,.*,.*, */{
@@ -130,18 +134,7 @@ source_base=lib
m4_base=m4
doc_base=doc
tests_base=tests
-
-# Extra files from gnulib, which override files from other sources.
-gnulib_extra_files="
- $build_aux/install-sh
- $build_aux/missing
- $build_aux/mdate-sh
- $build_aux/texinfo.tex
- $build_aux/depcomp
- $build_aux/config.guess
- $build_aux/config.sub
- doc/INSTALL
-"
+gnulib_extra_files=''
# Additional gnulib-tool options to use. Use "\newline" to break lines.
gnulib_tool_option_extras=
@@ -229,6 +222,18 @@ case "$0" in
*) test -r "$0.conf" && . ./"$0.conf" ;;
esac
+# Extra files from gnulib, which override files from other sources.
+test -z "${gnulib_extra_files}" && \
+ gnulib_extra_files="
+ $build_aux/install-sh
+ $build_aux/missing
+ $build_aux/mdate-sh
+ $build_aux/texinfo.tex
+ $build_aux/depcomp
+ $build_aux/config.guess
+ $build_aux/config.sub
+ doc/INSTALL
+"
if test "$vc_ignore" = auto; then
vc_ignore=
@@ -278,14 +283,29 @@ if test -n "$checkout_only_file" && test ! -r
"$checkout_only_file"; then
exit 1
fi
+# Ensure that lines starting with ! sort last, per gitignore conventions
+# for whitelisting exceptions after a more generic blacklist pattern.
+sort_patterns() {
+ sort -u "$@" | sed '/^!/ {
+ H
+ d
+ }
+ $ {
+ P
+ x
+ s/^\n//
+ }' | sed '/^$/d'
+}
+
# If $STR is not already on a line by itself in $FILE, insert it,
# sorting the new contents of the file and replacing $FILE with the result.
insert_sorted_if_absent() {
file=$1
str=$2
test -f $file || touch $file
- echo "$str" | sort -u - $file | cmp - $file > /dev/null \
- || echo "$str" | sort -u - $file -o $file \
+ echo "$str" | sort_patterns - $file | cmp - $file > /dev/null \
+ || { echo "$str" | sort_patterns - $file > $file.bak \
+ && mv $file.bak $file; } \
|| exit 1
}
@@ -296,8 +316,8 @@ insert_vc_ignore() {
pattern="$2"
case $vc_ignore_file in
*.gitignore)
- # A .gitignore entry that does not start with `/' applies
- # recursively to subdirectories, so prepend `/' to every
+ # A .gitignore entry that does not start with '/' applies
+ # recursively to subdirectories, so prepend '/' to every
# .gitignore entry.
pattern=`echo "$pattern" | sed s,^,/,`;;
esac
@@ -405,18 +425,32 @@ check_versions() {
# Honor $APP variables ($TAR, $AUTOCONF, etc.)
appvar=`echo $app | tr '[a-z]-' '[A-Z]_'`
test "$appvar" = TAR && appvar=AMTAR
- eval "app=\${$appvar-$app}"
- inst_ver=$(get_version $app)
- if [ ! "$inst_ver" ]; then
- echo "$me: Error: '$app' not found" >&2
- ret=1
- elif [ ! "$req_ver" = "-" ]; then
- latest_ver=$(sort_ver $req_ver $inst_ver | cut -d' ' -f2)
- if [ ! "$latest_ver" = "$inst_ver" ]; then
- echo "$me: Error: '$app' version == $inst_ver is too old" >&2
- echo " '$app' version >= $req_ver is required" >&2
+ case $appvar in
+ GZIP) ;; # Do not use $GZIP: it contains gzip options.
+ *) eval "app=\${$appvar-$app}" ;;
+ esac
+ if [ "$req_ver" = "-" ]; then
+ # Merely require app to exist; not all prereq apps are well-behaved
+ # so we have to rely on $? rather than get_version.
+ $app --version >/dev/null 2>&1
+ if [ 126 -le $? ]; then
+ echo "$me: Error: '$app' not found" >&2
ret=1
fi
+ else
+ # Require app to produce a new enough version string.
+ inst_ver=$(get_version $app)
+ if [ ! "$inst_ver" ]; then
+ echo "$me: Error: '$app' not found" >&2
+ ret=1
+ else
+ latest_ver=$(sort_ver $req_ver $inst_ver | cut -d' ' -f2)
+ if [ ! "$latest_ver" = "$inst_ver" ]; then
+ echo "$me: Error: '$app' version == $inst_ver is too old" >&2
+ echo " '$app' version >= $req_ver is required" >&2
+ ret=1
+ fi
+ fi
fi
done
@@ -443,6 +477,32 @@ if test $use_libtool = 1; then
find_tool LIBTOOLIZE glibtoolize libtoolize
fi
+# gnulib-tool requires at least automake and autoconf.
+# If either is not listed, add it (with minimum version) as a prerequisite.
+case $buildreq in
+ *automake*) ;;
+ *) buildreq="automake 1.9
+$buildreq" ;;
+esac
+case $buildreq in
+ *autoconf*) ;;
+ *) buildreq="autoconf 2.59
+$buildreq" ;;
+esac
+
+# When we can deduce that gnulib-tool will require patch,
+# and when patch is not already listed as a prerequisite, add it, too.
+if test ! -d "$local_gl_dir" \
+ || find "$local_gl_dir" -name '*.diff' -exec false {} +; then
+ :
+else
+ case $buildreq in
+ *patch*) ;;
+ *) buildreq="patch -
+$buildreq" ;;
+ esac
+fi
+
if ! printf "$buildreq" | check_versions; then
echo >&2
if test -f README-prereq; then
@@ -553,6 +613,9 @@ download_po_files() {
domain=$2
echo "$me: getting translations into $subdir for $domain..."
cmd=`printf "$po_download_command_format" "$domain" "$subdir"`
+ eval "$cmd" && return
+ # Fallback to HTTP.
+ cmd=`printf "$po_download_command_format2" "$subdir" "$domain"`
eval "$cmd"
}
@@ -640,10 +703,18 @@ symlink_to_dir()
cp -fp "$src" "$dst"
}
else
+ # Leave any existing symlink alone, if it already points to the source,
+ # so that broken build tools that care about symlink times
+ # aren't confused into doing unnecessary builds. Conversely, if the
+ # existing symlink's time stamp is older than the source, make it afresh,
+ # so that broken tools aren't confused into skipping needed builds. See
+ # <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00326.html>.
test -h "$dst" &&
src_ls=`ls -diL "$src" 2>/dev/null` && set $src_ls && src_i=$1 &&
dst_ls=`ls -diL "$dst" 2>/dev/null` && set $dst_ls && dst_i=$1 &&
- test "$src_i" = "$dst_i" || {
+ test "$src_i" = "$dst_i" &&
+ both_ls=`ls -dt "$src" "$dst"` &&
+ test "X$both_ls" = "X$dst$nl$src" || {
dot_dots=
case $src in
/*) ;;
@@ -665,56 +736,32 @@ symlink_to_dir()
}
}
-cp_mark_as_generated()
-{
- cp_src=$1
- cp_dst=$2
+# NOTE: we have to be careful to run both autopoint and libtoolize
+# before gnulib-tool, since gnulib-tool is likely to provide newer
+# versions of files "installed" by these two programs.
+# Then, *after* gnulib-tool (see below), we have to be careful to
+# run autoreconf in such a way that it does not run either of these
+# two just-pre-run programs.
- if cmp -s "$cp_src" "$GNULIB_SRCDIR/$cp_dst"; then
- symlink_to_dir "$GNULIB_SRCDIR" "$cp_dst"
- elif cmp -s "$cp_src" "$local_gl_dir/$cp_dst"; then
- symlink_to_dir $local_gl_dir "$cp_dst"
- else
- case $cp_dst in
- *.[ch]) c1='/* '; c2=' */';;
- *.texi) c1='@c '; c2= ;;
- *.m4|*/Make*|Make*) c1='# ' ; c2= ;;
- *) c1= ; c2= ;;
- esac
+# Import from gettext.
+with_gettext=yes
+grep '^[ ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \
+ with_gettext=no
- # If the destination directory doesn't exist, create it.
- # This is required at least for "lib/uniwidth/cjk.h".
- dst_dir=`dirname "$cp_dst"`
- test -d "$dst_dir" || mkdir -p "$dst_dir"
-
- if test -z "$c1"; then
- cmp -s "$cp_src" "$cp_dst" || {
- # Copy the file first to get proper permissions if it
- # doesn't already exist. Then overwrite the copy.
- echo "$me: cp -f $cp_src $cp_dst" &&
- rm -f "$cp_dst" &&
- cp "$cp_src" "$cp_dst-t" &&
- sed "s!$bt_regex/!!g" "$cp_src" > "$cp_dst-t" &&
- mv -f "$cp_dst-t" "$cp_dst"
- }
- else
- # Copy the file first to get proper permissions if it
- # doesn't already exist. Then overwrite the copy.
- cp "$cp_src" "$cp_dst-t" &&
- (
- echo "$c1-*- buffer-read-only: t -*- vi: set ro:$c2" &&
- echo "${c1}DO NOT EDIT! GENERATED AUTOMATICALLY!$c2" &&
- sed "s!$bt_regex/!!g" "$cp_src"
- ) > $cp_dst-t &&
- if cmp -s "$cp_dst-t" "$cp_dst"; then
- rm -f "$cp_dst-t"
- else
- echo "$me: cp $cp_src $cp_dst # with edits" &&
- mv -f "$cp_dst-t" "$cp_dst"
- fi
- fi
- fi
-}
+if test $with_gettext = yes; then
+ # Released autopoint has the tendency to install macros that have been
+ # obsoleted in current gnulib, so run this before gnulib-tool.
+ echo "$0: $AUTOPOINT --force"
+ $AUTOPOINT --force || exit
+fi
+
+# Autoreconf runs aclocal before libtoolize, which causes spurious
+# warnings if the initial aclocal is confused by the libtoolized
+# (or worse out-of-date) macro directory.
+if test $use_libtool = 1; then
+ echo "running: $LIBTOOLIZE --copy --install"
+ $LIBTOOLIZE --copy --install
+fi
version_controlled_file() {
dir=$1
@@ -733,96 +780,17 @@ version_controlled_file() {
test $found = yes
}
-slurp() {
- for dir in . `(cd $1 && find * -type d -print)`; do
- copied=
- sep=
- for file in `ls -a $1/$dir`; do
- case $file in
- .|..) continue;;
- # FIXME: should all file names starting with "." be ignored?
- .*) continue;;
- esac
- test -d $1/$dir/$file && continue
- for excluded_file in $excluded_files; do
- test "$dir/$file" = "$excluded_file" && continue 2
- done
- if test $file = Makefile.am && test "X$gnulib_mk" != XMakefile.am; then
- copied=$copied${sep}$gnulib_mk; sep=$nl
- remove_intl='/^[^#].*\/intl/s/^/#/;'"s!$bt_regex/!!g"
- sed "$remove_intl" $1/$dir/$file |
- cmp - $dir/$gnulib_mk > /dev/null || {
- echo "$me: Copying $1/$dir/$file to $dir/$gnulib_mk ..." &&
- rm -f $dir/$gnulib_mk &&
- sed "$remove_intl" $1/$dir/$file >$dir/$gnulib_mk &&
- gnulib_mk_hook $dir/$gnulib_mk
- }
- elif { test "${2+set}" = set && test -r $2/$dir/$file; } ||
- version_controlled_file $dir $file; then
- echo "$me: $dir/$file overrides $1/$dir/$file"
- else
- copied=$copied$sep$file; sep=$nl
- if test $file = gettext.m4; then
- echo "$me: patching m4/gettext.m4 to remove need for intl/* ..."
- rm -f $dir/$file
- sed '
- /^AC_DEFUN(\[AM_INTL_SUBDIR],/,/^]/c\
- AC_DEFUN([AM_INTL_SUBDIR], [])
- /^AC_DEFUN(\[gt_INTL_SUBDIR_CORE],/,/^]/c\
- AC_DEFUN([gt_INTL_SUBDIR_CORE], [])
- $a\
- AC_DEFUN([gl_LOCK_EARLY], [])
- ' $1/$dir/$file >$dir/$file
- else
- cp_mark_as_generated $1/$dir/$file $dir/$file
- fi
- fi || exit
- done
-
- for dot_ig in x $vc_ignore; do
- test $dot_ig = x && continue
- ig=$dir/$dot_ig
- if test -n "$copied"; then
- insert_vc_ignore $ig "$copied"
- # If an ignored file name ends with .in.h, then also add
- # the name with just ".h". Many gnulib headers are generated,
- # e.g., stdint.in.h -> stdint.h, dirent.in.h ->..., etc.
- # Likewise for .gperf -> .h, .y -> .c, and .sin -> .sed
- f=`echo "$copied" |
- sed '
- s/\.in\.h$/.h/
- s/\.sin$/.sed/
- s/\.y$/.c/
- s/\.gperf$/.h/
- '
- `
- insert_vc_ignore $ig "$f"
-
- # For files like sys_stat.in.h and sys_time.in.h, record as
- # ignorable the directory we might eventually create: sys/.
- f=`echo "$copied"|sed 's/sys_.*\.in\.h$/sys/'`
- insert_vc_ignore $ig "$f"
- fi
- done
- done
-}
-
-
-# Create boot temporary directories to import from gnulib and gettext.
-rm -fr $bt $bt2 &&
-mkdir $bt $bt2 || exit
-
# Import from gnulib.
gnulib_tool_options="\
--import\
--no-changelog\
- --aux-dir $bt/$build_aux\
- --doc-base $bt/$doc_base\
+ --aux-dir $build_aux\
+ --doc-base $doc_base\
--lib $gnulib_name\
- --m4-base $bt/$m4_base/\
- --source-base $bt/$source_base/\
- --tests-base $bt/$tests_base\
+ --m4-base $m4_base/\
+ --source-base $source_base/\
+ --tests-base $tests_base\
--local-dir $local_gl_dir\
$gnulib_tool_option_extras\
"
@@ -834,25 +802,13 @@ if test $use_libtool = 1; then
fi
echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
$gnulib_tool $gnulib_tool_options --import $gnulib_modules &&
-slurp $bt || exit
for file in $gnulib_files; do
symlink_to_dir "$GNULIB_SRCDIR" $file || exit
done
-
-# Import from gettext.
-with_gettext=yes
-grep '^[ ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \
- with_gettext=no
-
-if test $with_gettext = yes; then
- echo "$0: (cd $bt2; ${AUTOPOINT-autopoint}) ..."
- cp configure.ac $bt2 &&
- (cd $bt2 && ${AUTOPOINT-autopoint} && rm configure.ac) &&
- slurp $bt2 $bt || exit
-fi
-rm -fr $bt $bt2 || exit
+bootstrap_post_import_hook \
+ || { echo >&2 "$me: bootstrap_post_import_hook failed"; exit 1; }
# Remove any dangling symlink matching "*.m4" or "*.[ch]" in some
# gnulib-populated directories. Such .m4 files would cause aclocal to fail.
@@ -866,28 +822,21 @@ find "$m4_base" "$source_base" \
-depth \( -name '*.m4' -o -name '*.[ch]' \) \
-type l -xtype l -delete > /dev/null 2>&1
-# Reconfigure, getting other files.
-
-# Skip autoheader if it's not needed.
-grep -E '^[ ]*AC_CONFIG_HEADERS?\>' configure.ac >/dev/null ||
- AUTOHEADER=true
-
-for command in \
- libtool \
- "${ACLOCAL-aclocal} --force -I m4 $ACLOCAL_FLAGS" \
- "${AUTOCONF-autoconf} --force" \
- "${AUTOHEADER-autoheader} --force" \
- "${AUTOMAKE-automake} --add-missing --copy --force-missing"
-do
- if test "$command" = libtool; then
- test $use_libtool = 0 \
- && continue
- command="${LIBTOOLIZE-libtoolize} -c -f"
- fi
- echo "$0: $command ..."
- $command || exit
-done
+# Some systems (RHEL 5) are using ancient autotools, for which the
+# --no-recursive option had not been invented. Detect that lack and
+# omit the option when it's not supported. FIXME in 2017: remove this
+# hack when RHEL 5 autotools are updated, or when they become irrelevant.
+no_recursive=
+case $($AUTORECONF --help) in
+ *--no-recursive*) no_recursive=--no-recursive;;
+esac
+# Tell autoreconf not to invoke autopoint or libtoolize; they were run above.
+echo "running: AUTOPOINT=true LIBTOOLIZE=true " \
+ "$AUTORECONF --verbose --install $no_recursive -I $m4_base $ACLOCAL_FLAGS"
+AUTOPOINT=true LIBTOOLIZE=true \
+ $AUTORECONF --verbose --install $no_recursive -I $m4_base $ACLOCAL_FLAGS \
+ || exit 1
# Get some extra files from gnulib, overriding existing files.
for file in $gnulib_extra_files; do
diff --git a/bootstrap.conf b/bootstrap.conf
index e51703b..1549eb0 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -21,7 +21,6 @@ avoided_gnulib_modules='
# gnulib modules used by this package.
gnulib_modules="
$avoided_gnulib_modules
- alloca
announce-gen
autobuild
calloc
@@ -109,6 +108,8 @@ if test $gettext_external = 1; then
'
fi
+gnulib_tool_option_extras='--symlink --makefile-name=gnulib.mk'
+
# Build prerequisites
buildreq="\
autoconf 2.61
@@ -126,6 +127,12 @@ rsync -
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
+}
+
bootstrap_epilogue()
{
perl -pi -e "s/address@hidden@/$package/g" README-release
diff --git a/configure.ac b/configure.ac
index d215787..abad6e4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -11,7 +11,7 @@ AM_INIT_AUTOMAKE([1.11 no-dist-gzip dist-xz color-tests
parallel-tests])
AM_SILENT_RULES([yes]) # make --enable-silent-rules the default.
AM_MISSING_PROG([HELP2MAN], [help2man])
-AC_PROG_CC
+AM_PROG_CC_C_O
gl_EARLY
AC_PROG_INSTALL
AC_PROG_MAKE_SET
@@ -85,9 +85,7 @@ AM_GNU_GETTEXT_VERSION([0.17])
AC_CONFIG_FILES(
Makefile
- lib/Makefile
po/Makefile.in
- src/Makefile
tests/Makefile
man/Makefile)
diff --git a/etc/prefix-gnulib-mk b/etc/prefix-gnulib-mk
new file mode 100755
index 0000000..81c0924
--- /dev/null
+++ b/etc/prefix-gnulib-mk
@@ -0,0 +1,220 @@
+#! /usr/bin/perl -w
+
+use strict;
+use IO::File;
+use Getopt::Long;
+use File::Basename; # for dirname
+
+my $VERSION = '2012-01-21 17:13'; # UTC
+(my $ME = $0) =~ s|.*/||;
+
+my $prefix;
+my $lib_name;
+
+sub usage ($)
+{
+ my ($exit_code) = @_;
+ my $STREAM = ($exit_code == 0 ? *STDOUT : *STDERR);
+ if ($exit_code != 0)
+ {
+ print $STREAM "Try '$ME --help' for more information.\n";
+ }
+ else
+ {
+ print $STREAM <<EOF;
+Usage: $ME --lib-name=NAME FILE
+ or: $ME [--help|--version]
+Rewrite a gnulib-tool-generated FILE like lib/gnulib.mk to work with
+automake's subdir-objects.
+
+OPTIONS:
+
+This option must be specified:
+
+ --lib-name=NAME library name, often "lib\$project"
+
+The following are optional:
+
+ --help display this help and exit
+ --version output version information and exit
+
+EOF
+ }
+ exit $exit_code;
+}
+
+# contents ($FILE_NAME)
+# ---------------------
+sub contents ($)
+{
+ my ($file) = @_;
+ local $/; # Turn on slurp-mode.
+ my $f = new IO::File "< $file" or die "$file";
+ my $contents = $f->getline or die "$file";
+ $f->close;
+ return $contents;
+}
+
+# prefix_word ($WORD)
+# -------------------
+# Do not prefix special words such as variable dereferences. Also,
+# "Makefile" is really "Makefile", since precisely there is no
+# lib/Makefile.
+sub prefix_word ($)
+{
+ local ($_) = @_;
+ $_ = $prefix . $_
+ unless /^-/ || m{^\$\(\w+\)} || $_ eq "Makefile" || $_ eq '\\';
+ return $_;
+}
+
+
+# prefix_words ($TEXT)
+# --------------------
+sub prefix_words ($)
+{
+ local ($_) = @_;
+ s{(\S+)}{prefix_word($1)}gem;
+ return $_;
+}
+
+
+# prefix_assignment ($LHS-AND-ASSIGN-OP, $RHS)
+# --------------------------------------------
+sub prefix_assignment ($$)
+{
+ my ($lhs_and_assign_op, $rhs) = @_;
+ my $res;
+
+ # 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)
=/)
+ {
+ $lhs_and_assign_op =~ s/=/+=/;
+ }
+ # We don't want to inherit gnulib's AUTOMAKE_OPTIONS, comment them.
+ elsif ($lhs_and_assign_op =~ /^AUTOMAKE_OPTIONS =/)
+ {
+ $lhs_and_assign_op =~ s/^/# /;
+ }
+ # Don't touch suffixes.
+ elsif ($lhs_and_assign_op =~ /^SUFFIXES /)
+ {
+ }
+ # The words are (probably) paths to files in lib/: prefix them.
+ else
+ {
+ $rhs = prefix_words($rhs)
+ }
+
+ # Variables which name depend on the location: libbison_a_SOURCES =>
+ # lib_libbison_a_SOURCES.
+ $lhs_and_assign_op =~ s/($lib_name)/lib_$1/g;
+
+ return $lhs_and_assign_op . $rhs;
+}
+
+# prefix $CONTENTS
+# ----------------
+# $CONTENTS is a Makefile content. Post-process it so that each file-name
+# is prefixed with $prefix (e.g., "lib/").
+#
+# Relies heavily on the regularity of the file generated by gnulib-tool.
+sub prefix ($)
+{
+ # Work on $_.
+ local ($_) = @_;
+
+ # Prefix all the occurrence of files in rules. If there is nothing
+ # after in the :, it's probably a phony target, or a suffix rule.
+ # Don't touch it.
+ s{^([-\w+/]+\.[-\w.]+ *: *\S.*)$}
+ {prefix_words($1)}gem;
+
+ # Prefix files in variables.
+ s{^([\w.]+\s*\+?=)(.*)$}
+ {prefix_assignment($1, $2)}gem;
+
+ # These three guys escape all the other regular rules.
+ s{(charset\.alias|ref-add\.sed|ref-del\.sed)}{$prefix$1}g;
+ # 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;
+
+ # Sometimes, t-$@ is used instead of address@hidden, which, of course, does
+ # not work when we have a $@ with a directory in it.
+ address@hidden@-t}g;
+
+ # Some AC_SUBST patterns remain and would better be Make macros.
+ s{\@(MKDIR_P)address@hidden($1)}g;
+
+ # Adjust paths in mkdir.
+ s{(\$\(MKDIR_P\))\s*(\w+)}{$1 $prefix$2}g;
+
+ return $_;
+}
+
+# process ($IN)
+# -------------
+sub process ($)
+{
+ my ($file) = @_;
+ my ($bak) = "$file.bak";
+ rename ($file, $bak) or die;
+ my $contents = contents ($bak);
+ $contents = prefix ($contents);
+ my $out = new IO::File(">$file") or die;
+ print $out $contents;
+}
+
+{
+ GetOptions
+ (
+ 'lib-name=s' => \$lib_name,
+ help => sub { usage 0 },
+ version => sub { print "$ME version $VERSION\n"; exit },
+ ) or usage 1;
+
+ my $fail = 0;
+ defined $lib_name
+ or (warn "$ME: no library name; use --lib-name=NAME\n"), $fail = 1;
+
+ # There must be exactly one argument.
+ @ARGV == 0
+ and (warn "$ME: missing FILE argument\n"), $fail = 1;
+ 1 < @ARGV
+ and (warn "$ME: too many arguments:\n", join ("\n", @ARGV), "\n"),
+ $fail = 1;
+ $fail
+ and usage 1;
+
+ my $file = $ARGV[0];
+ $prefix = (dirname $file) . '/';
+ warn "prefix=$prefix\n";
+
+ process $file;
+}
+
+### Setup "GNU" style for perl-mode and cperl-mode.
+## Local Variables:
+## perl-indent-level: 2
+## perl-continued-statement-offset: 2
+## perl-continued-brace-offset: 0
+## perl-brace-offset: 0
+## perl-brace-imaginary-offset: 0
+## perl-label-offset: -2
+## cperl-indent-level: 2
+## cperl-brace-offset: 0
+## cperl-continued-brace-offset: 0
+## cperl-label-offset: -2
+## cperl-extra-newline-before-brace: t
+## cperl-merge-trailing-else: nil
+## cperl-continued-statement-offset: 2
+## eval: (add-hook 'write-file-hooks 'time-stamp)
+## time-stamp-start: "my $VERSION = '"
+## time-stamp-format: "%:y-%02m-%02d %02H:%02M"
+## time-stamp-time-zone: "UTC"
+## time-stamp-end: "'; # UTC"
+## End:
diff --git a/lib/Makefile.am b/lib/Makefile.am
deleted file mode 100644
index 65480b5..0000000
--- a/lib/Makefile.am
+++ /dev/null
@@ -1,9 +0,0 @@
-## Process this file with automake to produce Makefile.in.
-
-include gnulib.mk
-
-AM_CFLAGS += $(WARNING_CFLAGS) $(WERROR_CFLAGS)
-
-# Allow "make distdir" to succeed before "make all" has run.
-dist-hook: $(noinst_LIBRARIES)
-.PHONY: dist-hook
diff --git a/lib/local.mk b/lib/local.mk
new file mode 100644
index 0000000..decbad6
--- /dev/null
+++ b/lib/local.mk
@@ -0,0 +1,5 @@
+include lib/gnulib.mk
+
+# Allow "make distdir" to succeed before "make all" has run.
+dist-hook: $(noinst_LIBRARIES)
+.PHONY: dist-hook
diff --git a/man/Makefile.am b/man/Makefile.am
index 753a516..5b170d3 100644
--- a/man/Makefile.am
+++ b/man/Makefile.am
@@ -47,7 +47,7 @@ check-x-vs-1:
programs = \
echo 'spy:;@echo $$(all_programs)' \
- | MAKEFLAGS= $(MAKE) -s -C ../src -f Makefile -f - spy \
+ | MAKEFLAGS= $(MAKE) -s -C .. -f Makefile -f - spy \
| fmt -1 | $(ASSORT) -u | grep -v '\['
.PHONY: check-programs-vs-x
diff --git a/src/Makefile.am b/src/local.mk
similarity index 69%
rename from src/Makefile.am
rename to src/local.mk
index 22ea6fb..95d3143 100644
--- a/src/Makefile.am
+++ b/src/local.mk
@@ -1,30 +1,30 @@
-## Process this file with automake to produce Makefile.in -*-Makefile-*-
-
-bin_PROGRAMS = cppi
-cppi_SOURCES = \
- cppi.l \
- system.h
-noinst_HEADERS = cpp.h
-
-AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)
+bin_PROGRAMS = src/cppi
+src_cppi_SOURCES = \
+ src/cppi.l \
+ src/system.h
# Tell the linker to omit references to unused shared libraries.
AM_LDFLAGS = $(IGNORE_UNUSED_LIBRARIES_CFLAGS)
-EXTRA_DIST = cpp.gp cpp-indent.pl cppi.l cpp-cond.c
-MAINTAINERCLEANFILES = cpp-cond.c
-DISTCLEANFILES = cpp.h lex.backup
+EXTRA_DIST += \
+ src/cpp.gp \
+ src/cpp-indent.pl \
+ src/cppi.l \
+ src/cpp-cond.c
+
+MAINTAINERCLEANFILES += src/cpp-cond.c
+DISTCLEANFILES += src/cpp.h src/lex.backup
GPERF = gperf
-AM_CPPFLAGS = -I$(top_srcdir)/lib
+AM_CPPFLAGS += -I$(top_srcdir)/lib -Isrc
-LDADD = ../lib/libcppi.a $(LIBINTL) ../lib/libcppi.a
+LDADD = $(top_builddir)/lib/libcppi.a $(LIBINTL) $(top_builddir)/lib/libcppi.a
GPERF_OPTIONS = \
-C -N cpp_cond_lookup -n -t -s 6 -k '*' --language=ANSI-C
-cpp-cond.c: cpp.gp
+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' \
@@ -33,9 +33,9 @@ cpp-cond.c: cpp.gp
$(AM_V_at)mv address@hidden $@
localedir = $(datadir)/locale
-BUILT_SOURCES = localedir.h
-DISTCLEANFILES = localedir.h
-localedir.h: Makefile
+BUILT_SOURCES += src/localedir.h
+DISTCLEANFILES += src/localedir.h
+src/localedir.h: src/local.mk
$(AM_V_GEN)rm -f address@hidden
$(AM_V_at)echo '#define LOCALEDIR "$(localedir)"' >address@hidden
$(AM_V_at)chmod a-w address@hidden
@@ -55,26 +55,26 @@ AM_LFLAGS = $(flex_debug) $(flex_optimize) $(flex_8_bit)
# Don't use automake's default .l.c rule.
# I prefer to make generated .c files unwritable.
-cppi.c: cppi.l
+src/cppi.c: src/cppi.l
$(AM_V_GEN)rm -f $@
- $(AM_V_at)$(LEXCOMPILE) $(srcdir)/cppi.l
+ $(AM_V_at)$(LEXCOMPILE) $(top_srcdir)/src/cppi.l
$(AM_V_at)chmod a-w $(LEX_OUTPUT_ROOT).c
$(AM_V_at)mv $(LEX_OUTPUT_ROOT).c $@
-cpp.h: cpp.gp Makefile.am
+src/cpp.h: src/cpp.gp src/local.mk
$(AM_V_GEN)rm -f address@hidden $@
$(AM_V_at)( \
echo '/* This file is generated automatically from cpp.gp. */'; \
echo; \
echo 'enum Eic_type'; \
echo '{'; \
- sed -n '/.*, /{s///;s/.*/ &,/;p;};' $(srcdir)/cpp.gp; \
+ sed -n '/.*, /{s///;s/.*/ &,/;p;};' $(srcdir)/src/cpp.gp; \
echo ' EIC_OTHER'; \
echo '};'; \
echo; \
echo 'static char const *const directive[] ='; \
echo '{'; \
- sed -n '/,.*/{s///;s/.*/ "&",/;p;};' $(srcdir)/cpp.gp; \
+ sed -n '/,.*/{s///;s/.*/ "&",/;p;};' $(srcdir)/src/cpp.gp; \
echo ' ""'; \
echo '};'; \
) \
@@ -85,7 +85,7 @@ cpp.h: cpp.gp Makefile.am
# This is required because we have broken inter-directory dependencies:
# in order to generate all man pages, require that cppi be built at
# distribution time.
-dist-hook: cppi
+dist-hook: src/cppi
.PHONY: dist-hook
-BUILT_SOURCES += cpp-cond.c cpp.h
+BUILT_SOURCES += src/cpp-cond.c src/cpp.h
diff --git a/src/system.h b/src/system.h
index 73952dd..1ff5fa3 100644
--- a/src/system.h
+++ b/src/system.h
@@ -14,8 +14,6 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#include <alloca.h>
-
/* Include sys/types.h before this file. */
#if 2 <= __GLIBC__ && 2 <= __GLIBC_MINOR__
--
1.7.9.rc2.2.g183d6
- [bug-cppi] use mostly-non-recursive make, Jim Meyering, 2012/01/25
- [bug-cppi] [PATCH 01/19] build: remove use of vestigial rm_subst, Jim Meyering, 2012/01/25
- [bug-cppi] [PATCH 04/19] maint: man: use dist_man1_MANS, rather than dist_man_MANS, Jim Meyering, 2012/01/25
- [bug-cppi] [PATCH 02/19] update bootstrap; don't recurse into lib/ or src/,
Jim Meyering <=
- [bug-cppi] [PATCH 08/19] maint: .gitignore: ignore/adjust a few more, Jim Meyering, 2012/01/25
- [bug-cppi] [PATCH 03/19] maint: remove useless artifacts copied from coreutils, Jim Meyering, 2012/01/25
- [bug-cppi] [PATCH 09/19] build: remove obsolete settings from cfg.mk, Jim Meyering, 2012/01/25
- [bug-cppi] [PATCH 10/19] maint: update init.sh from gnulib, Jim Meyering, 2012/01/25
- [bug-cppi] [PATCH 11/19] maint: remove redundant build output, Jim Meyering, 2012/01/25
- [bug-cppi] [PATCH 05/19] build: don't recurse into man/ when building, Jim Meyering, 2012/01/25
- [bug-cppi] [PATCH 07/19] build: don't recurse into tests/ when building, Jim Meyering, 2012/01/25
- [bug-cppi] [PATCH 12/19] maint: use gnulib's getopt-gnu, not the deprecated getopt module, Jim Meyering, 2012/01/25
- [bug-cppi] [PATCH 13/19] maint: tweak m4 quoting in AC_CONFIG_FILES, Jim Meyering, 2012/01/25
- [bug-cppi] [PATCH 06/19] tests: add the help-version test, Jim Meyering, 2012/01/25