Convert lib/Makefile.am into lib/local.mk.

The real problem is rather gnulib.mk, which itself is extracted from a
Makefile.am that gnulib expects to the "recursive".  The tool
prefix-gnulib-mk converts such a gnulib.mk to be non-recursive.  Also,
some AC_SUBST variables need to be adjusted.

	* etc/prefix-gnulib-mk: New.
	* bootstrap (slurp): Use it to convert further gnulib.mk.
	* lib/Makefile.am: Rename as...
	* lib/local.mk: this.
	Adjust to be prefixed.
	* Makefile.am, configure.ac: Adjust.
	* src/local.mk (AM_CPPFLAGS): Extend it, don't define it.
This commit is contained in:
Akim Demaille
2008-11-19 08:24:47 +01:00
parent 56ddee7f8d
commit feda5527b3
8 changed files with 249 additions and 60 deletions

View File

@@ -1,3 +1,21 @@
2008-11-26 Akim Demaille <demaille@gostai.com>
Convert lib/Makefile.am into lib/local.mk.
The real problem is rather gnulib.mk, which itself is extracted
from a Makefile.am that gnulib expects to the "recursive". The
tool prefix-gnulib-mk converts such a gnulib.mk to be
non-recursive. Also, some AC_SUBST variables need to be adjusted.
* etc/prefix-gnulib-mk: New.
* bootstrap (slurp): Use it to convert further gnulib.mk.
No longer try to avoid re-creation of lib/gnulib.mk as the changes
are deeper.
* lib/Makefile.am: Rename as...
* lib/local.mk: this.
Adjust to be prefixed.
* Makefile.am, configure.ac: Adjust.
* src/local.mk (AM_CPPFLAGS): Extend it, don't define it.
2008-11-26 Akim Demaille <demaille@gostai.com> 2008-11-26 Akim Demaille <demaille@gostai.com>
s/_FLAGS/FLAGS/. s/_FLAGS/FLAGS/.
@@ -64,7 +82,7 @@
Get rid of (yy)rhs and (yy)prhs. Get rid of (yy)rhs and (yy)prhs.
These tables are no longer needed in the parsers, and they don't seem to These tables are no longer needed in the parsers, and they don't seem to
be useful. They are not documented either. be useful. They are not documented either.
* src/output.c (prepare_rules): Get rid of rhs and prhs. * src/output.c (prepare_rules): Get rid of rhs and prhs.
Adjust the computation of (yy)r2. Adjust the computation of (yy)r2.
@@ -77,7 +95,7 @@
Get rid of lalr1-split.cc. Get rid of lalr1-split.cc.
It was no longer maintainer. It was no longer maintainer.
* data/lalr1-split.cc: Remove. * data/lalr1-split.cc: Remove.
* etc/bench.pl.in (bench_fusion_parser): Remove. * etc/bench.pl.in (bench_fusion_parser): Remove.
Adjust. Adjust.
@@ -105,7 +123,7 @@
Prefer TESTSUITE_FLAGS. Prefer TESTSUITE_FLAGS.
TESTSUITEFLAGS is barely readable. TESTSUITEFLAGS is barely readable.
* tests/local.mk (TESTSUITE_FLAGS): Default to $(TESTSUITEFLAGS) * tests/local.mk (TESTSUITE_FLAGS): Default to $(TESTSUITEFLAGS)
for backward compatibility. for backward compatibility.
Use the former instead of the latter. Use the former instead of the latter.
@@ -128,7 +146,7 @@
is available from the state stack. This has two be benefits: two tables is available from the state stack. This has two be benefits: two tables
less in the parser (making it smaller), and a more consistent use of the less in the parser (making it smaller), and a more consistent use of the
three stacks which will help to fuse them. three stacks which will help to fuse them.
* data/yacc.c (yyprhs, yyrhs): Remove. * data/yacc.c (yyprhs, yyrhs): Remove.
(YY_REDUCE_PRINT): Pass yyssp to yy_reduce_print. (YY_REDUCE_PRINT): Pass yyssp to yy_reduce_print.
(yy_reduce_print): Take yyssp as argument. (yy_reduce_print): Take yyssp as argument.
@@ -141,7 +159,7 @@
b4_tables_map. b4_tables_map.
The point is to factor the generation of the tables across skeletons. The point is to factor the generation of the tables across skeletons.
This is language dependant. This is language dependant.
* data/c.m4 (b4_comment_): New. * data/c.m4 (b4_comment_): New.
Should be usable to define how to generate tables independently of Should be usable to define how to generate tables independently of
the language. the language.
@@ -201,7 +219,7 @@
(Option Cross Key): Implement FIXME: listing directives also. (Option Cross Key): Implement FIXME: listing directives also.
* build-aux/cross-options.pl: Read from <STDIN> rather than <>. * build-aux/cross-options.pl: Read from <STDIN> rather than <>.
(Short Option): Special case -d. Put arguments inside @option. (Short Option): Special case -d. Put arguments inside @option.
(Bison Directive): Add column, automatically extracted from (Bison Directive): Add column, automatically extracted from
src/scan-gram.l (actual name passed as the first argument) src/scan-gram.l (actual name passed as the first argument)
with special case for %define. with special case for %define.
* doc/local.mk (doc/cross-options.texi): Pass src/scan-gram.l * doc/local.mk (doc/cross-options.texi): Pass src/scan-gram.l

View File

@@ -17,7 +17,7 @@
ACLOCAL_AMFLAGS = -I m4 ACLOCAL_AMFLAGS = -I m4
SUBDIRS = po runtime-po lib . SUBDIRS = po runtime-po .
if BISON_CXX_WORKS if BISON_CXX_WORKS
SUBDIRS += examples/calc++ SUBDIRS += examples/calc++
endif endif
@@ -31,6 +31,7 @@ EXTRA_DIST = .prev-version .version \
OChangeLog PACKAGING OChangeLog PACKAGING
# Initialization before completion by local.mk's. # Initialization before completion by local.mk's.
AM_CPPFLAGS =
BUILT_SOURCES = BUILT_SOURCES =
DISTCLEANFILES = DISTCLEANFILES =
MOSTLYCLEANFILES = MOSTLYCLEANFILES =
@@ -40,6 +41,7 @@ include djgpp/local.mk
include doc/local.mk include doc/local.mk
include etc/local.mk include etc/local.mk
include examples/local.mk include examples/local.mk
include lib/local.mk
include src/local.mk include src/local.mk
include tests/local.mk include tests/local.mk

View File

@@ -505,11 +505,10 @@ slurp() {
if test $file = Makefile.am; then if test $file = Makefile.am; then
copied=$copied${sep}$gnulib_mk; sep=$nl copied=$copied${sep}$gnulib_mk; sep=$nl
remove_intl='/^[^#].*\/intl/s/^/#/;'"s!$bt_regex/!!g" remove_intl='/^[^#].*\/intl/s/^/#/;'"s!$bt_regex/!!g"
sed "$remove_intl" $1/$dir/$file | cmp -s - $dir/$gnulib_mk || { echo "$0: Copying $1/$dir/$file to $dir/$gnulib_mk ..."
echo "$0: Copying $1/$dir/$file to $dir/$gnulib_mk ..." && rm -f $dir/$gnulib_mk
rm -f $dir/$gnulib_mk && sed "$remove_intl" $1/$dir/$file >$dir/$gnulib_mk
sed "$remove_intl" $1/$dir/$file >$dir/$gnulib_mk etc/prefix-gnulib-mk $dir/$gnulib_mk
}
elif { test "${2+set}" = set && test -r $2/$dir/$file; } || elif { test "${2+set}" = set && test -r $2/$dir/$file; } ||
version_controlled_file $dir $file; then version_controlled_file $dir $file; then
echo "$0: $dir/$file overrides $1/$dir/$file" echo "$0: $dir/$file overrides $1/$dir/$file"

View File

@@ -80,7 +80,7 @@ AC_ARG_ENABLE([yacc],
case $enable_yacc in case $enable_yacc in
yes) yes)
YACC_SCRIPT=src/yacc YACC_SCRIPT=src/yacc
YACC_LIBRARY=liby.a;; YACC_LIBRARY=lib/liby.a;;
*) *)
YACC_SCRIPT= YACC_SCRIPT=
YACC_LIBRARY=;; YACC_LIBRARY=;;
@@ -148,9 +148,14 @@ AC_SUBST([O0CXXFLAGS], [`echo $CXXFLAGS | sed 's/-O[[0-9]] *//'`])
gt_JAVACOMP([1.3], [1.4]) gt_JAVACOMP([1.3], [1.4])
gt_JAVAEXEC gt_JAVAEXEC
AC_SUBST([gl_PREFIXED_LIBOBJS],
[$(echo "$gl_LIBOBJS" | sed -e 's, , lib/,g')])
for ac_var in ERRNO_H GETOPT_H INTTYPES_H STDBOOL_H STDINT_H WCHAR_H WCTYPE_H
do
eval "$ac_var=lib/\$$ac_var"
done
AC_CONFIG_FILES([Makefile AC_CONFIG_FILES([Makefile
po/Makefile.in po/Makefile.in
examples/calc++/Makefile examples/calc++/Makefile
lib/Makefile
doc/yacc.1]) doc/yacc.1])
AC_OUTPUT AC_OUTPUT

149
etc/prefix-gnulib-mk Executable file
View File

@@ -0,0 +1,149 @@
#! /usr/bin/perl -w
use strict;
use IO::File;
my $prefix = "lib/";
# 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";
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_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/(libbison)/lib_$1/g;
# Do not use gl_LIBOBJS, but its prefixed version.
$rhs =~ s/gl_LIBOBJS/gl_PREFIXED_LIBOBJS/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.*)$}
{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{lib/lib/}{lib/}g;
# $(srcdir) is actually $(top_srcdir)/lib.
s{\$\(srcdir\)}{\$(top_srcdir)/lib}g;
# Sometimes, t-$@ is used instead of $@-t, which, of course, does
# not work when we have a $@ with a directory in it.
s{t-\$\@}{\$\@-t}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;
}
process ("lib/gnulib.mk")
### 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
## End:

View File

@@ -1,45 +0,0 @@
# Make bison/lib.
# Copyright (C) 2001, 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# 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 gnulib.mk
AM_CFLAGS = $(WARN_CFLAGS)
# Implementation of bitsets.
bitsets_sources = \
abitset.c abitset.h bbitset.h bitset.c bitset.h bitset_stats.c \
bitset_stats.h bitsetv.c bitsetv.h ebitset.c ebitset.h lbitset.c \
lbitset.h libiberty.h vbitset.c vbitset.h
# Additional bitset operations.
additional_bitsets_sources = \
bitsetv-print.h bitsetv-print.c
# timevars, stolen from GCC.
timevars_sources = \
timevar.h timevar.c timevar.def
# Non-gnulib sources in Bison's internal library.
libbison_a_SOURCES += \
get-errno.h get-errno.c \
subpipe.h subpipe.c \
$(bitsets_sources) $(additional_bitsets_sources) $(timevars_sources)
# The Yacc compatibility library.
lib_LIBRARIES = $(YACC_LIBRARY)
EXTRA_LIBRARIES = liby.a
liby_a_SOURCES = main.c yyerror.c

61
lib/local.mk Normal file
View File

@@ -0,0 +1,61 @@
# Make bison/lib.
# Copyright (C) 2001, 2002, 2003, 2004, 2006, 2008 Free Software
# Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# 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 lib/gnulib.mk
# Implementation of bitsets.
lib_libbison_a_SOURCES += \
lib/abitset.c \
lib/abitset.h \
lib/bbitset.h \
lib/bitset.c \
lib/bitset.h \
lib/bitset_stats.c \
lib/bitset_stats.h \
lib/bitsetv.c \
lib/bitsetv.h \
lib/ebitset.c \
lib/ebitset.h \
lib/lbitset.c \
lib/lbitset.h \
lib/libiberty.h \
lib/vbitset.c \
lib/vbitset.h
# Additional bitset operations.
lib_libbison_a_SOURCES += \
lib/bitsetv-print.h \
lib/bitsetv-print.c
# timevars, stolen from GCC.
lib_libbison_a_SOURCES += \
lib/timevar.h \
lib/timevar.c \
lib/timevar.def
# Non-gnulib sources in Bison's internal library.
lib_libbison_a_SOURCES += \
lib/get-errno.h \
lib/get-errno.c \
lib/subpipe.h \
lib/subpipe.c
# The Yacc compatibility library.
lib_LIBRARIES = $(YACC_LIBRARY)
EXTRA_LIBRARIES = lib/liby.a
lib_liby_a_SOURCES = lib/main.c lib/yyerror.c

View File

@@ -16,7 +16,7 @@
AUTOMAKE_OPTIONS = subdir-objects AUTOMAKE_OPTIONS = subdir-objects
AM_CPPFLAGS = -I$(top_srcdir)/lib AM_CPPFLAGS += -I$(top_srcdir)/lib
# Find builddir/src/scan-code.c etc. # Find builddir/src/scan-code.c etc.
AM_CPPFLAGS += -I$(top_builddir) AM_CPPFLAGS += -I$(top_builddir)