]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
Fixed up interlock. Better C++ support.
authorTom Tromey <tromey@redhat.com>
Sun, 11 Aug 1996 16:01:03 +0000 (16:01 +0000)
committerTom Tromey <tromey@redhat.com>
Sun, 11 Aug 1996 16:01:03 +0000 (16:01 +0000)
12 files changed:
ChangeLog
Makefile.am
Makefile.in
automake.in
interlock
lib/am/Makefile.am
lib/ylwrap [new file with mode: 0755]
tests/ChangeLog
tests/Makefile.am
tests/Makefile.in
tests/cxxlink.test [new file with mode: 0755]
ylwrap [new file with mode: 0755]

index bef8d477083feba7dff18d9a99a34922be51d741..7e69ab3f0b175a74423ae4a993693cce7f62fb89 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 Sun Aug 11 00:20:16 1996  Tom Tromey  <tromey@creche.cygnus.com>
 
+       * 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.
index 78c5bbbe8f0e40770baf7f3b99db196f35b7e19e..3231fb43ba1fc60b0ab16f459e63c85f8eb99710 100644 (file)
@@ -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
 
index e55268416461e5de1eb3a5307d4e04447eab627a..734cd8db97eb9d3cf70a8b2922ec9213693afca5 100644 (file)
@@ -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
 
index a58971e3e873e3cc99d78b27072844cc20e70880..c43a4b023b692e64e3103786a764a6f71c34bb30 100755 (executable)
@@ -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 .=
index a35eb98e116dcf0e4bb01712323be0728b6e0120..60f9fbf3e7b503fae55e59c471371d9f4cdf41d5 100755 (executable)
--- a/interlock
+++ b/interlock
 # 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
index 78c5bbbe8f0e40770baf7f3b99db196f35b7e19e..3231fb43ba1fc60b0ab16f459e63c85f8eb99710 100644 (file)
@@ -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 (executable)
index 0000000..83ce13f
--- /dev/null
@@ -0,0 +1,40 @@
+#! /bin/sh
+# ylwrap - wrapper for lex/yacc invocations.
+# Written by Tom Tromey <tromey@cygnus.com>, 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
index d5346370a25f38812a8fa2ae67195126370d8a0d..14b67c7153da3ec3e36d7695385330820daeffc0 100644 (file)
@@ -1,5 +1,7 @@
 Sun Aug 11 00:10:42 1996  Tom Tromey  <tromey@creche.cygnus.com>
 
+       * cxxlink.test: New file.
+
        * yacc.test: Fixed test for new yacc code.
 
 Sat Aug 10 10:09:45 1996  Tom Tromey  <tromey@creche.cygnus.com>
index 3994ee5819041f3b7b1611f34502b5f1c3956619..52168ac02ba2dafb91abe77327cced4cc8129e2d 100644 (file)
@@ -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)
index 8ba411da77d8317afec140456d73b1a545df4c17..bd8177444553f3b224a503f2adb8d9b2cc6f86ae 100644 (file)
@@ -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 (executable)
index 0000000..c06acb8
--- /dev/null
@@ -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 (executable)
index 0000000..83ce13f
--- /dev/null
+++ b/ylwrap
@@ -0,0 +1,40 @@
+#! /bin/sh
+# ylwrap - wrapper for lex/yacc invocations.
+# Written by Tom Tromey <tromey@cygnus.com>, 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