+Sun Aug 11 00:20:16 1996 Tom Tromey <tromey@creche.cygnus.com>
+
+ * automake.in (handle_yacc_lex_cxx): Renamed.
+
+ * automake.in (handle_dependencies): Handle %cxx_extensions.
+ Include depend2.am when appropriate.
+
+ * depend2.am: New file; contents from depend.am but templatized.
+
+ * automake.in (initialize_per_input): Initialize
+ %cxx_extensions.
+ (handle_source_transform): Set %cxx_extensions.
+
Sat Aug 10 10:29:30 1996 Tom Tromey <tromey@creche.cygnus.com>
+ * interlock: New file.
+
+ * automake.in (handle_yacc_lex): New sub.
+ (handle_source_transform): Removed most yacc/lex handling.
+ (initialize_per_input): Init yacc_sources, lex_sources.
+ (generate_makefile): Run handle_yacc_lex.
+ (handle_merge_targets): Use `scalar' and not $# to find length of
+ array.
+
* m4/AM_FEATURE_EXIT.m4: Wrote.
* m4/AM_FEATURE_CTYPE.m4: Wrote.
* m4/AM_FEATURE_ERRNO.m4: Wrote.
# CONFIG_HEADER = config.h
pkgdata_DATA = clean-kr.am clean.am compile-kr.am compile-vars.am \
-compile.am data.am dejagnu.am depend.am dist-vars.am footer.am \
+compile.am data.am dejagnu.am depend.am depend2.am dist-vars.am footer.am \
header.am header-vars.am kr-extra.am libraries.am library.am \
mans-vars.am program.am programs.am remake-hdr.am remake-subd.am \
remake.am scripts.am subdirs.am tags.am tags-subd.am tags-clean.am \
ansi2knr.1 aclocal.m4 lisp.am lisp-clean.am
## These must all be executable when installed.
-pkgdata_SCRIPTS = config.guess config.sub install-sh mdate-sh \
+pkgdata_SCRIPTS = config.guess config.sub install-sh interlock mdate-sh \
mkinstalldirs elisp-comp
CLEANFILES = automake aclocal
# CONFIG_HEADER = config.h
pkgdata_DATA = clean-kr.am clean.am compile-kr.am compile-vars.am \
-compile.am data.am dejagnu.am depend.am dist-vars.am footer.am \
+compile.am data.am dejagnu.am depend.am depend2.am dist-vars.am footer.am \
header.am header-vars.am kr-extra.am libraries.am library.am \
mans-vars.am program.am programs.am remake-hdr.am remake-subd.am \
remake.am scripts.am subdirs.am tags.am tags-subd.am tags-clean.am \
programs-clean.am data-clean.am COPYING INSTALL texinfo.tex ansi2knr.c \
ansi2knr.1 aclocal.m4 lisp.am lisp-clean.am
-pkgdata_SCRIPTS = config.guess config.sub install-sh mdate-sh \
+pkgdata_SCRIPTS = config.guess config.sub install-sh interlock mdate-sh \
mkinstalldirs elisp-comp
CLEANFILES = automake aclocal
* Automake will now generate rules to regenerate aclocal.m4, if appropriate
* Now uses `AM_' macro names everywhere
* ansi2knr option can have directory prefix (eg `../lib/ansi2knr')
+* Better C++, yacc, lex support
\f
New in 1.0:
* Bug fixes
* require AC_DECL_YYTEXT for lex
* Actually use $seen_prog_yacc
* Require AC_PROG_LEX or equivalent
-* Consider using implicit .y.c and .l.c rules instead of current
- lex/yacc trickery
require AC_PROG_CXX if any C++ source files found?
&handle_programs;
&handle_scripts;
+ # This must be run after all the sources are scanned.
+ &handle_yacc_lex_cxx;
+
# Re-init SOURCES and OBJECTS. FIXME other code shouldn't depend
# on this (but currently does).
$contents{'SOURCES'} = join (' ', @sources);
return $dir_holds_sources;
}
+# Handle yacc and lex.
+sub handle_yacc_lex_cxx
+{
+ local ($yacc_count) = scalar (keys %yacc_sources);
+ local ($lex_count) = scalar (keys %lex_sources);
+ local ($cxx_count) = scalar (keys %cxx_extensions);
+
+ if ($yacc_count)
+ {
+ push (@suffixes, '.y');
+ $output_vars .= "YACC = \@YACC\@\n";
+ $output_rules .= ".y.c:\n\t";
+ if ($yacc_count > 1)
+ {
+ $output_rules .= '$(INTERLOCK) y.tab.c $@ $(YACC) $(YFLAGS) $<';
+ }
+ else
+ {
+ $output_rules .= '$(YACC) $(YFLAGS) $< && mv y.tab.c $@';
+ }
+ $output_rules .= "\n";
+ }
+ if ($lex_count)
+ {
+ push (@suffixes, '.l');
+ $output_vars .= "LEX = \@LEX\@\n";
+ $output_rules .= (".l.c:\n\t"
+ . "\n");
+ if ($lex_count > 1)
+ {
+ $output_rules .= '$(INTERLOCK) lex.yy.c $@ $(LEX) $(LFLAGS) $<';
+ }
+ else
+ {
+ $output_rules .= '$(LEX) $(LFLAGS) $< && mv lex.yy.c $@';
+ }
+ $output_rules .= "\n";
+ }
+ if ($cxx_count)
+ {
+ $output_vars .= ("CXX = \@CXX\@\n"
+ . "CXXFLAGS = \@CXXFLAGS\@\n"
+ . "CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)\n"
+ . "CXXLINK = $(CXX) $(LDFLAGS) -o $@\n");
+
+ local ($ext);
+ foreach $ext (keys %cxx_extensions)
+ {
+ $output_rules .= ("$ext.o:\n"
+ . "\t\$(CXXCOMPILE) -c \$<\n");
+ }
+ }
+
+ if ($yacc_count > 1 || $lex_count > 1)
+ {
+ # If there is more than one distinct yacc (resp lex) source
+ # file in a given directory, then the `interlock' program is
+ # required to allow parallel builds to work correctly. FIXME
+ # for now, no line number.
+ &require_config_file ($FOREIGN, 'interlock');
+ $output_vars .= 'INTERLOCK = ';
+ if ($config_aux_dir ne '.' && $config_aux_dir ne '')
+ {
+ $output_vars .= $config_aux_dir;
+ }
+ else
+ {
+ $output_vars .= '$(top_srcdir)';
+ }
+ $output_vars .= "/interlock\n";
+ }
+}
+
# Handle SOURCE->OBJECT transform for one program or library.
sub handle_source_transform
{
{
# Yacc source.
&push_dist_common ($1 . '.c');
- if (! defined $targets{$1 . '.c'})
- {
- # Generate a target.
- $output_rules .= ($1 . '.c: ' . $_ . "\n"
- . "\t"
- . 'cd $(srcdir) && $(YACC) $(YFLAGS) $< && mv y.tab.c '
- . $1 . '.c' . "\n");
- }
-
- if (! &variable_defined ('YACC'))
- {
- $output_vars .= "YACC = \@YACC\@\n";
- $targets{'YACC'} = 1;
- }
+ $yacc_sources{$_} = 1;
}
elsif (/^(.*)\.l$/)
{
# Lex source.
&push_dist_common ($1 . '.c');
- if (! defined $targets{$1 . '.c'})
- {
- $output_rules .= ($1 . '.c: ' . $_ . "\n"
- . "\t"
- . 'cd $(srcdir) && $(LEX) $(LFLAGS) $< && mv lex.yy.c '
- . $1 . '.c' . "\n");
- }
-
- if (! &variable_defined ('LEX'))
- {
- $output_vars .= "LEX = \@YACC\@\n";
- $targets{'LEX'} = 1;
- }
+ $lex_sources{$_} = 1;
}
# Transform source files into .o files. List of C++
# extensions comes from Emacs 19.32 etags.
- s/\.c\+\+$/$obj/g;
- s/\.cc$/$obj/g;
- s/\.cpp$/$obj/g;
- s/\.cxx$/$obj/g;
+ if (s/\.c\+\+$/$obj/g
+ || s/\.cc$/$obj/g
+ || s/\.cpp$/$obj/g
+ || s/\.cxx$/$obj/g
+ || s/\.C$/$obj/g)
+ {
+ $cxx_extensions{$&} = 1;
+ }
# FORTRAN support.
s/\.f90$/$obj/g;
s/\.for$/$obj/g;
- # .C is C++. .y is yacc. .l is lex. .f and .F is
- # fortran. .s is assembly. .M is Objective-C++. .m
- # is Objective-C.
- s/\.[cCylfFsmM]$/$obj/g;
+ # .y is yacc. .l is lex. .f and .F is fortran. .s
+ # is assembly. .M is Objective-C++. .m is
+ # Objective-C.
+ s/\.[cylfFsmM]$/$obj/g;
push (@result, $_)
unless $prefix eq 'EXTRA_';
{
&pretty_print ('DEP_FILES =', "", sort keys %dep_files);
$output_rules .= &file_contents ('depend');
+ $output_rules .=
+ &file_contents_with_transform ('s/\@EXT\@/.c/g;'
+ . 's/\@MKDEP\@/MKDEP/g',
+ 'depend2');
+ local ($ext);
+ local ($need_cxx) = 0;
+ foreach $ext (keys %cxx_extensions)
+ {
+ $output_rules .=
+ &file_contents_with_transform ('s/\@EXT\@/' . $ext .'/g;'
+ . 's/\@MKDEP\@/CXXMKDEP/g',
+ 'depend2');
+ $need_cxx = 1;
+ }
+ if ($need_cxx)
+ {
+ $output_vars .= 'CXXMKDEP = $(CXX) -MM $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)' . "\n";
+ }
}
}
else
# If no dependencies for 'install', add 'all'. Why? That way
# "make install" at top level of distclean'd distribution won't
# fail because stuff in 'lib' fails to build.
- if (! @install || ($#install == 1
+ if (! @install || (scalar (@install) == 2
&& $install[0] eq 'install-exec'
&& $install[1] eq 'install-data'))
{
# Per Makefile.am.
$local_maint_charset = $maint_charset;
+
+ # All yacc and lex source filenames for this directory. Use
+ # filenames instead of raw count so that multiple instances are
+ # counted correctly (eg one yacc file can appear in multiple
+ # programs without harm).
+ %yacc_sources = ();
+ %lex_sources = ();
+
+ # C++ source extensions we've seen.
+ %cxx_extensions = ();
}
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
## 02111-1307, USA.
-# This fragment is probably only useful for maintainers. It relies on
-# GNU make and gcc. It is only included in the generated Makefile.in
-# if `automake' is not passed the `--include-deps' flag.
+
+## This fragment is probably only useful for maintainers. It relies
+## on GNU make and gcc. It is only included in the generated
+## Makefile.in if `automake' is not passed the `--include-deps' flag.
MKDEP = gcc -MM $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
-include $(DEP_FILES)
$(DEP_FILES): $(srcdir)/.deps/.P
-
-$(srcdir)/.deps/%.P: $(srcdir)/%.c
- @echo "mkdeps $< > $@"
-## Use funny regexp because otherwise too much can be matched when
-## srcdir begins with ".". Can't use \< since sed doesn't recognize
-## "." as a word start. Regexp-quote srcdir because "." is a matching
-## operator which commonly appears in filenames. Need "//*" in
-## regexps because otherwise the regexp will fail when srcdir=. and
-## the path to the file is relative (eg ../lib/error.c matches "./*").
- @top=`echo $(srcdir) | sed 's,^$(top_srcdir),,;s,[^/],,g;s,/,../,g'` ; \
- re=`echo "s,^$(srcdir)//*,,g;s, $(srcdir)//*, ,g;s,$(top_srcdir)//*,$$top,g" | sed 's,\.,\\\\.,g'`; \
- $(MKDEP) $< | sed "$$re" > $@-tmp
- @if test -n "$o"; then \
- sed 's/\.o:/$$o:/' $@-tmp > $@; \
- rm $@-tmp; \
- else \
- mv $@-tmp $@; \
- fi
-
-# End of maintainer-only section
--- /dev/null
+## automake - create Makefile.in from Makefile.am
+## Copyright (C) 1994, 1995, 1996 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 2, 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, write to the Free Software
+## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+## 02111-1307, USA.
+$(srcdir)/.deps/%.P: $(srcdir)/%@EXT@
+ @echo "mkdeps $< > $@"
+## Use funny regexp because otherwise too much can be matched when
+## srcdir begins with ".". Can't use \< since sed doesn't recognize
+## "." as a word start. Regexp-quote srcdir because "." is a matching
+## operator which commonly appears in filenames. Need "//*" in
+## regexps because otherwise the regexp will fail when srcdir=. and
+## the path to the file is relative (eg ../lib/error.c matches "./*").
+ @top=`echo $(srcdir) | sed 's,^$(top_srcdir),,;s,[^/],,g;s,/,../,g'` ; \
+ re=`echo "s,^$(srcdir)//*,,g;s, $(srcdir)//*, ,g;s,$(top_srcdir)//*,$$top,g" | sed 's,\.,\\\\.,g'`; \
+ $(@MKDEP@) $< | sed "$$re" > $@-tmp
+ @if test -n "$o"; then \
+ sed 's/\.o:/$$o:/' $@-tmp > $@; \
+ rm $@-tmp; \
+ else \
+ mv $@-tmp $@; \
+ fi
--- /dev/null
+#! /bin/sh
+# interlock - wrap program invocation in lock to allow
+# parallel builds to work.
+# Written by Tom Tromey <tromey@cygnus.com>, Aug 10 1996
+#
+# 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 2, 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# Pick a filename. Hopefully no-one actually uses this name.
+dirname='=interlockdir'
+
+while (mkdir $dirname > /dev/null 2>&1 && exit 1 || exit 0); do
+ # Nothing.
+ :
+done
+
+# We have the lock.
+prog="$1"
+progoutput="$2"
+realoutput="$3"
+shift
+shift
+shift
+
+$prog ${1+"$@"}
+ret=$?
+
+if test -f "$progoutput"; then
+ mv "$progoutput" "$realoutput" || ret=$?
+fi
+
+# Release the lock.
+rmdir $dirname > /dev/null 2>&1
+
+exit $ret
# CONFIG_HEADER = config.h
pkgdata_DATA = clean-kr.am clean.am compile-kr.am compile-vars.am \
-compile.am data.am dejagnu.am depend.am dist-vars.am footer.am \
+compile.am data.am dejagnu.am depend.am depend2.am dist-vars.am footer.am \
header.am header-vars.am kr-extra.am libraries.am library.am \
mans-vars.am program.am programs.am remake-hdr.am remake-subd.am \
remake.am scripts.am subdirs.am tags.am tags-subd.am tags-clean.am \
ansi2knr.1 aclocal.m4 lisp.am lisp-clean.am
## These must all be executable when installed.
-pkgdata_SCRIPTS = config.guess config.sub install-sh mdate-sh \
+pkgdata_SCRIPTS = config.guess config.sub install-sh interlock mdate-sh \
mkinstalldirs elisp-comp
CLEANFILES = automake aclocal
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
## 02111-1307, USA.
-# This fragment is probably only useful for maintainers. It relies on
-# GNU make and gcc. It is only included in the generated Makefile.in
-# if `automake' is not passed the `--include-deps' flag.
+
+## This fragment is probably only useful for maintainers. It relies
+## on GNU make and gcc. It is only included in the generated
+## Makefile.in if `automake' is not passed the `--include-deps' flag.
MKDEP = gcc -MM $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
-include $(DEP_FILES)
$(DEP_FILES): $(srcdir)/.deps/.P
-
-$(srcdir)/.deps/%.P: $(srcdir)/%.c
- @echo "mkdeps $< > $@"
-## Use funny regexp because otherwise too much can be matched when
-## srcdir begins with ".". Can't use \< since sed doesn't recognize
-## "." as a word start. Regexp-quote srcdir because "." is a matching
-## operator which commonly appears in filenames. Need "//*" in
-## regexps because otherwise the regexp will fail when srcdir=. and
-## the path to the file is relative (eg ../lib/error.c matches "./*").
- @top=`echo $(srcdir) | sed 's,^$(top_srcdir),,;s,[^/],,g;s,/,../,g'` ; \
- re=`echo "s,^$(srcdir)//*,,g;s, $(srcdir)//*, ,g;s,$(top_srcdir)//*,$$top,g" | sed 's,\.,\\\\.,g'`; \
- $(MKDEP) $< | sed "$$re" > $@-tmp
- @if test -n "$o"; then \
- sed 's/\.o:/$$o:/' $@-tmp > $@; \
- rm $@-tmp; \
- else \
- mv $@-tmp $@; \
- fi
-
-# End of maintainer-only section
--- /dev/null
+## automake - create Makefile.in from Makefile.am
+## Copyright (C) 1994, 1995, 1996 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 2, 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, write to the Free Software
+## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+## 02111-1307, USA.
+$(srcdir)/.deps/%.P: $(srcdir)/%@EXT@
+ @echo "mkdeps $< > $@"
+## Use funny regexp because otherwise too much can be matched when
+## srcdir begins with ".". Can't use \< since sed doesn't recognize
+## "." as a word start. Regexp-quote srcdir because "." is a matching
+## operator which commonly appears in filenames. Need "//*" in
+## regexps because otherwise the regexp will fail when srcdir=. and
+## the path to the file is relative (eg ../lib/error.c matches "./*").
+ @top=`echo $(srcdir) | sed 's,^$(top_srcdir),,;s,[^/],,g;s,/,../,g'` ; \
+ re=`echo "s,^$(srcdir)//*,,g;s, $(srcdir)//*, ,g;s,$(top_srcdir)//*,$$top,g" | sed 's,\.,\\\\.,g'`; \
+ $(@MKDEP@) $< | sed "$$re" > $@-tmp
+ @if test -n "$o"; then \
+ sed 's/\.o:/$$o:/' $@-tmp > $@; \
+ rm $@-tmp; \
+ else \
+ mv $@-tmp $@; \
+ fi
+Sun Aug 11 00:10:42 1996 Tom Tromey <tromey@creche.cygnus.com>
+
+ * yacc.test: Fixed test for new yacc code.
+
Sat Aug 10 10:09:45 1996 Tom Tromey <tromey@creche.cygnus.com>
* defun.test: New file.
$AUTOMAKE || exit 1
-grep '^zardoz.c:' Makefile.in
+grep 'zardoz.c' Makefile.in