From d6acedf6c735a57ecfae81651520ddd1ba051e40 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sun, 11 Aug 1996 16:01:01 +0000 Subject: [PATCH] Fixed up interlock. Better C++ support. --- ChangeLog | 10 ++++++++++ Makefile.am | 2 +- Makefile.in | 2 +- automake.in | 33 +++++++++++++++++---------------- interlock | 31 +++++++++++++++---------------- lib/am/Makefile.am | 2 +- lib/ylwrap | 40 ++++++++++++++++++++++++++++++++++++++++ tests/ChangeLog | 2 ++ tests/Makefile.am | 2 +- tests/Makefile.in | 2 +- tests/cxxlink.test | 19 +++++++++++++++++++ ylwrap | 40 ++++++++++++++++++++++++++++++++++++++++ 12 files changed, 148 insertions(+), 37 deletions(-) create mode 100755 lib/ylwrap create mode 100755 tests/cxxlink.test create mode 100755 ylwrap diff --git a/ChangeLog b/ChangeLog index bef8d477..7e69ab3f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ Sun Aug 11 00:20:16 1996 Tom Tromey + * automake.in (handle_yacc_lex_cxx): Require ylwrap in + multi-lex/yacc case. + (handle_source_transform): Changed return result. + (handle_programs): Use linker returned by + handle_source_transform. + + * interlock: Changed usage. + + * ylwrap: New file. + * automake.in (handle_yacc_lex_cxx): Renamed. * automake.in (handle_dependencies): Handle %cxx_extensions. diff --git a/Makefile.am b/Makefile.am index 78c5bbbe..3231fb43 100644 --- a/Makefile.am +++ b/Makefile.am @@ -22,7 +22,7 @@ ansi2knr.1 aclocal.m4 lisp.am lisp-clean.am ## These must all be executable when installed. pkgdata_SCRIPTS = config.guess config.sub install-sh interlock mdate-sh \ -mkinstalldirs elisp-comp +mkinstalldirs elisp-comp ylwrap CLEANFILES = automake aclocal diff --git a/Makefile.in b/Makefile.in index e5526841..734cd8db 100644 --- a/Makefile.in +++ b/Makefile.in @@ -59,7 +59,7 @@ 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 interlock mdate-sh \ -mkinstalldirs elisp-comp +mkinstalldirs elisp-comp ylwrap CLEANFILES = automake aclocal diff --git a/automake.in b/automake.in index a58971e3..c43a4b02 100755 --- a/automake.in +++ b/automake.in @@ -583,7 +583,7 @@ sub handle_yacc_lex_cxx $output_rules .= ".y.c:\n\t"; if ($yacc_count > 1) { - $output_rules .= '$(INTERLOCK) y.tab.c $@ $(YACC) $(YFLAGS) $<'; + $output_rules .= '$(INTERLOCK) =yacclockdir $(YLWRAP) y.tab.c $@ $(YACC) $(YFLAGS) $<'; } else { @@ -599,7 +599,7 @@ sub handle_yacc_lex_cxx . "\n"); if ($lex_count > 1) { - $output_rules .= '$(INTERLOCK) lex.yy.c $@ $(LEX) $(LFLAGS) $<'; + $output_rules .= '$(INTERLOCK) =lexlockdir $(YLWRAP) lex.yy.c $@ $(LEX) $(LFLAGS) $<'; } else { @@ -628,21 +628,19 @@ sub handle_yacc_lex_cxx # 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"; + &require_config_file ($FOREIGN, 'interlock', 'ylwrap'); + $output_vars .= ('INTERLOCK = ' . $config_aux_dir . "/interlock\n" + . 'YLWRAP = ' . $config_aux_dir . "/ylwrap\n"); } } # Handle SOURCE->OBJECT transform for one program or library. +# Arguments are: +# canonical (transformed) name of object to build +# actual name of object to build +# object extension (ie either `.o' or `$o'. +# Return result is name of linker variable that must be used. +# Empty return means just use `LINK'. sub handle_source_transform { # one_file is canonical name. unxformed is given name. obj is @@ -651,6 +649,8 @@ sub handle_source_transform local ($objpat) = $obj; $objpat =~ s/(\W)/\\$1/g; + local ($linker) = ''; + if (&variable_defined ($one_file . "_OBJECTS")) { &am_line_error ($one_file . '_OBJECTS', @@ -727,6 +727,7 @@ sub handle_source_transform || s/\.C$/$obj/g) { $cxx_extensions{$&} = 1; + $linker = 'CXXLINK'; } # FORTRAN support. @@ -757,7 +758,7 @@ sub handle_source_transform . $contents{'CONFIG_HEADER'} . "\n"); } - return @result; + return $linker; } # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables. @@ -834,7 +835,7 @@ sub handle_programs } } - &handle_source_transform ($xname, $one_file, $obj); + local ($linker) = &handle_source_transform ($xname, $one_file, $obj); if (&variable_defined ($xname . "_LDADD")) { @@ -854,7 +855,7 @@ sub handle_programs } else { - $xlink = 'LINK'; + $xlink = $linker ? $linker : 'LINK'; } $output_rules .= diff --git a/interlock b/interlock index a35eb98e..60f9fbf3 100755 --- a/interlock +++ b/interlock @@ -17,28 +17,27 @@ # 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' +# Usage: +# interlock lock-dir-name program args-to-program... -while (mkdir $dirname > /dev/null 2>&1 && exit 1 || exit 0); do - # Nothing. - : -done +dirname="$1" +program="$2" -# We have the lock. -prog="$1" -progoutput="$2" -realoutput="$3" -shift shift shift -$prog ${1+"$@"} -ret=$? +while (mkdir $dirname > /dev/null 2>&1 && exit 1 || exit 0); do + # Wait a bit. + sleep 1 +done -if test -f "$progoutput"; then - mv "$progoutput" "$realoutput" || ret=$? -fi +# Race condition here: if interrupted after the loop but before this +# trap, the lock can be left around. +trap "rmdir $dirname > /dev/null 2>&1" 1 2 + +# We have the lock, so run the program. +$program ${1+"$@"} +ret=$? # Release the lock. rmdir $dirname > /dev/null 2>&1 diff --git a/lib/am/Makefile.am b/lib/am/Makefile.am index 78c5bbbe..3231fb43 100644 --- a/lib/am/Makefile.am +++ b/lib/am/Makefile.am @@ -22,7 +22,7 @@ ansi2knr.1 aclocal.m4 lisp.am lisp-clean.am ## These must all be executable when installed. pkgdata_SCRIPTS = config.guess config.sub install-sh interlock mdate-sh \ -mkinstalldirs elisp-comp +mkinstalldirs elisp-comp ylwrap CLEANFILES = automake aclocal diff --git a/lib/ylwrap b/lib/ylwrap new file mode 100755 index 00000000..83ce13fc --- /dev/null +++ b/lib/ylwrap @@ -0,0 +1,40 @@ +#! /bin/sh +# ylwrap - wrapper for lex/yacc invocations. +# Written by Tom Tromey , Aug 11 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. + +# The program to run. +prog="$1" + +# The output file the program generates, eg `y.tab.c'. +progoutput="$2" + +# The output file we actually want. +realoutput="$3" + +# Strip arguments we've used; remaining arguments go to PROG. +shift +shift +shift + +$prog ${1+"$@"} || exit $? + +if test -f "$progoutput"; then + mv "$progoutput" "$realoutput" || exit $? +else + exit 1 +fi +exit 0 diff --git a/tests/ChangeLog b/tests/ChangeLog index d5346370..14b67c71 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,5 +1,7 @@ Sun Aug 11 00:10:42 1996 Tom Tromey + * cxxlink.test: New file. + * yacc.test: Fixed test for new yacc code. Sat Aug 10 10:09:45 1996 Tom Tromey diff --git a/tests/Makefile.am b/tests/Makefile.am index 3994ee58..52168ac0 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -12,6 +12,6 @@ insh2.test outdir.test fpinstall.test fpinst2.test texinfo.test dejagnu.test \ yacc.test mkinstall2.test texinfo2.test ansi.test depacl.test depacl2.test \ error.test colon.test vtexi2.test tags.test comment.test libfiles.test \ man.test info.test obsolete.test lex.test scripts.test subdir2.test \ -exsource.test canon4.test dup.test defun.test +exsource.test canon4.test dup.test defun.test cxxlink.test EXTRA_DIST = defs $(TESTS) diff --git a/tests/Makefile.in b/tests/Makefile.in index 8ba411da..bd817744 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -50,7 +50,7 @@ insh2.test outdir.test fpinstall.test fpinst2.test texinfo.test dejagnu.test \ yacc.test mkinstall2.test texinfo2.test ansi.test depacl.test depacl2.test \ error.test colon.test vtexi2.test tags.test comment.test libfiles.test \ man.test info.test obsolete.test lex.test scripts.test subdir2.test \ -exsource.test canon4.test dup.test defun.test +exsource.test canon4.test dup.test defun.test cxxlink.test EXTRA_DIST = defs $(TESTS) mkinstalldirs = $(top_srcdir)/mkinstalldirs diff --git a/tests/cxxlink.test b/tests/cxxlink.test new file mode 100755 index 00000000..c06acb8d --- /dev/null +++ b/tests/cxxlink.test @@ -0,0 +1,19 @@ +#! /bin/sh + +# Test to make sure C++ linker is used when appropriate. + +. $srcdir/defs || exit 1 + +cat > Makefile.am << 'END' +bin_PROGRAMS = lavalamp +lavalamp_SOURCES = lava.c lamp.cxx +END + +: > lava.c +: > lamp.cxx + +$AUTOMAKE || exit 1 + +# Look for this macro not at the beginning of any line; that will have +# to be good enough for now. +grep '.CXXLINK' Makefile.in diff --git a/ylwrap b/ylwrap new file mode 100755 index 00000000..83ce13fc --- /dev/null +++ b/ylwrap @@ -0,0 +1,40 @@ +#! /bin/sh +# ylwrap - wrapper for lex/yacc invocations. +# Written by Tom Tromey , Aug 11 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. + +# The program to run. +prog="$1" + +# The output file the program generates, eg `y.tab.c'. +progoutput="$2" + +# The output file we actually want. +realoutput="$3" + +# Strip arguments we've used; remaining arguments go to PROG. +shift +shift +shift + +$prog ${1+"$@"} || exit $? + +if test -f "$progoutput"; then + mv "$progoutput" "$realoutput" || exit $? +else + exit 1 +fi +exit 0 -- 2.43.5