]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
Better C++ support
authorTom Tromey <tromey@redhat.com>
Sun, 11 Aug 1996 18:02:21 +0000 (18:02 +0000)
committerTom Tromey <tromey@redhat.com>
Sun, 11 Aug 1996 18:02:21 +0000 (18:02 +0000)
12 files changed:
ChangeLog
TODO
automake.in
compile-vars.am
interlock
tests/ChangeLog
tests/Makefile.am
tests/Makefile.in
tests/cxxlink.test
tests/cxxnoc.test [new file with mode: 0755]
tests/lex.test
tests/yacc.test

index 7e69ab3f0b175a74423ae4a993693cce7f62fb89..b57e862b9df0e3fefbe86e0556a53abe8c24a380 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,25 @@
 Sun Aug 11 00:20:16 1996  Tom Tromey  <tromey@creche.cygnus.com>
 
+       * compile-vars.am (CC, CFLAGS, COMPILE, LINK): Removed.
+
        * 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.
+       (seen_prog_cc, seen_prog_cxx): New globals.
+       (scan_configure): Recognize AC_PROG_CC and AC_PROG_CXX.
+       (handle_yacc_lex_cxx): Error message if AC_PROG_CXX or
+       AC_PROG_YACC missing.
+       (seen_decl_yytext, seen_prog_lex): New globals.
+       (scan_configure): Set them.
+       (handle_yacc_lex_cxx): Warn about missing AC_PROG_LEX or
+       AC_DECL_YYTEXT.
+       (handle_yacc_lex_cxx): Use $(LEX_OUTPUT_ROOT).
+       (initialize_per_input): Initialize seen_c_source.
+       (handle_yacc_lex_cxx): Define CC, CFLAGS, COMPILE, LINK only when
+       C source seen.
+       (handle_source_transform): Set seen_c_source.
 
        * interlock: Changed usage.
 
diff --git a/TODO b/TODO
index 0bdbfa167435474ba3bc03c2fc6e1d93b42b867f..f8370b8176d4bb041a6a8715bbad47c1d0e0482d 100644 (file)
--- a/TODO
+++ b/TODO
@@ -3,13 +3,6 @@ Priorities for release:
 
 ** when can aclocal.m4 be auto-generated?
 
-multi-language support.  Gord's idea is to have _FORTRAN_PROGRAMS,
-_CXX_PROGRAMS, etc, and have the right linker used by each.
-* seems to handle multi-language stuff ok ?
-* maybe some kind of auto-detection would be better ?  with linker
-  overridable on per-program basis
-* what about EXTRA_PROGRAMS stuff?
-
 ** many requests for a way to omit a file from the distribution.
    Should be done like `!foo' or `~foo' in _SOURCES, etc.
    Such files should be removed explicitly after the copy step!
@@ -154,13 +147,12 @@ Lex, yacc support:
        y.tab.c:perly.y
   for yacc and lex source
 * if AC_PROG_LEX used, ensure (no, *PUT*) LEXLIB in foo_LDADD
-* require AC_DECL_YYTEXT for lex
-* Actually use $seen_prog_yacc
-* Require AC_PROG_LEX or equivalent
-
 
-require AC_PROG_CXX if any C++ source files found?
-Better support for C++ all around
+Multi-language support:
+* should have mapping of file extensions to languages
+* should automatically handle the linking issue (special-case C++)
+* must get compile rules for various languages; FORTRAN probably
+  most important unimplemented language
 
 'maintainer-clean' should "rm -rf .deps".  Ditto distclean
 Should look for clean-local targets in Makefile.am.
index c43a4b023b692e64e3103786a764a6f71c34bb30..27b245d248434d4b56268e6a0c84d95d902e8e6a 100755 (executable)
@@ -139,6 +139,17 @@ $seen_path_xtra = 0;
 # Whether YACC variable has been seen in configure.in.
 $seen_prog_yacc = 0;
 
+# Two variables to control lex use.  One is for AC_DECL_YYTEXT and the
+# other is for AC_PROG_LEX.
+$seen_decl_yytext = 0;
+$seen_prog_lex = 0;
+
+# TRUE if we've seen AC_PROG_CC.
+$seen_prog_cc = 0;
+
+# TRUE if we've seen AC_PROG_CXX.
+$seen_prog_cxx = 0;
+
 # TRUE if we've seen AC_CANONICAL_(HOST|SYSTEM).  The presence of
 # AC_CHECK_TOOL also sets this.
 $seen_canonical = 0;
@@ -572,10 +583,12 @@ sub get_object_extension
 # Handle yacc and lex.
 sub handle_yacc_lex_cxx
 {
+    #
+    # First do yacc and lex.
+    #
+
     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');
@@ -590,29 +603,64 @@ sub handle_yacc_lex_cxx
            $output_rules .= '$(YACC) $(YFLAGS) $< && mv y.tab.c $@';
        }
        $output_rules .= "\n";
+
+       if (! $seen_prog_yacc)
+       {
+           # FIXME should include a reference line.  FIXME maybe
+           # directly reference AC_PROG_YACC somehow?
+           &am_error ("yacc source seen but \`YACC' not defined in \`configure.in'\n");
+       }
     }
     if ($lex_count)
     {
        push (@suffixes, '.l');
-       $output_vars .= "LEX = \@LEX\@\n";
+       $output_vars .= ("LEX = \@LEX\@\n"
+                        . "LEX_OUTPUT_ROOT = \@LEX_OUTPUT_ROOT\@\n");
        $output_rules .= (".l.c:\n\t"
                          . "\n");
        if ($lex_count > 1)
        {
-           $output_rules .= '$(INTERLOCK) =lexlockdir $(YLWRAP) lex.yy.c $@ $(LEX) $(LFLAGS) $<';
+           $output_rules .= '$(INTERLOCK) =lexlockdir $(YLWRAP) $(LEX_OUTPUT_ROOT).c $@ $(LEX) $(LFLAGS) $<';
        }
        else
        {
-           $output_rules .= '$(LEX) $(LFLAGS) $< && mv lex.yy.c $@';
+           $output_rules .= '$(LEX) $(LFLAGS) $< && mv $(LEX_OUTPUT_ROOT).c $@';
        }
        $output_rules .= "\n";
+
+       if (! $seen_prog_lex)
+       {
+           &am_error ("lex source seen but \`AC_PROG_LEX' not in \`configure.in'\n");
+       }
+       if (! $seen_decl_yytext)
+       {
+           &am_error ("lex source seen but \`AC_DECL_YYTEXT' not in \`configure.in'\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', 'ylwrap');
+       $output_vars .= ('INTERLOCK = ' . $config_aux_dir . "/interlock\n"
+                        . 'YLWRAP = ' . $config_aux_dir . "/ylwrap\n");
+    }
+
+    #
+    # Now handle C++.
+    #
+    local ($cxx_count) = scalar (keys %cxx_extensions);
     if ($cxx_count)
     {
        $output_vars .= ("CXX = \@CXX\@\n"
                         . "CXXFLAGS = \@CXXFLAGS\@\n"
-                        . "CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)\n"
-                        . "CXXLINK = $(CXX) $(LDFLAGS) -o $@\n");
+                        . 'CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)'
+                        . "\n"
+                        . 'CXXLINK = $(CXX) $(LDFLAGS) -o $@'
+                        . "\n");
 
        local ($ext);
        foreach $ext (keys %cxx_extensions)
@@ -620,17 +668,24 @@ sub handle_yacc_lex_cxx
            $output_rules .= ("$ext.o:\n"
                              . "\t\$(CXXCOMPILE) -c \$<\n");
        }
+
+       if (! $seen_prog_cxx)
+       {
+           &am_error ("C++ source seen but \`AC_PROG_CXX' not in \`configure.in'\n");
+       }
     }
 
-    if ($yacc_count > 1 || $lex_count > 1)
+    #
+    # Last, handle some C cleanup.
+    #
+    if ($seen_c_source)
     {
-       # 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', 'ylwrap');
-       $output_vars .= ('INTERLOCK = ' . $config_aux_dir . "/interlock\n"
-                        . 'YLWRAP = ' . $config_aux_dir . "/ylwrap\n");
+       $output_vars .= ("CC = \@CC\@\n"
+                        . "CFLAGS = \@CFLAGS\@\n"
+                        . 'COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)'
+                        . "\n"
+                        . 'LINK = $(CC) $(LDFLAGS) -o $@'
+                        . "\n");
     }
 }
 
@@ -729,15 +784,23 @@ sub handle_source_transform
                    $cxx_extensions{$&} = 1;
                    $linker = 'CXXLINK';
                }
+               else
+               {
+                   # FORTRAN support.  FIXME not finished.
+                   s/\.f90$/$obj/g;
+                   s/\.for$/$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;
+
+                   # FIXME of course, this should only happen for C
+                   # source.  The multi-language support must really
+                   # be cleaned up more globally.
+                   $seen_c_source = 1;
+               }
 
-               # FORTRAN support.
-               s/\.f90$/$obj/g;
-               s/\.for$/$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_';
 
@@ -2490,6 +2553,10 @@ sub scan_configure
        $seen_make_set = 1 if /AC_PROG_MAKE_SET/;
        $seen_arg_prog = 1 if /AC_ARG_PROGRAM/;
        $seen_ranlib = 1 if /AC_PROG_RANLIB/;
+        $seen_prog_cc = 1 if /AC_PROG_CC/;
+        $seen_prog_cxx = 1 if /AC_PROG_CXX/;
+        $seen_prog_lex = 1 if /AC_PROG_LEX/;
+        $seen_decl_yytext = 1 if /AC_DECL_YYTEXT/;
         $seen_maint_mode = 1 if /AM_MAINTAINER_MODE/;
         $seen_package = 1 if /PACKAGE=/;
         $seen_version = 1 if /VERSION=/;
@@ -2983,6 +3050,9 @@ sub initialize_per_input
 
     # C++ source extensions we've seen.
     %cxx_extensions = ();
+
+    # TRUE if we've seen any non-C++ sources.
+    $seen_c_source = 0;
 }
 
 
index d732b30966f984cc0cfff1025e32b751b036b8f0..801b2351cb327cb24e98415daf26a95167f2569e 100644 (file)
 ## along with this program; if not, write to the Free Software
 ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 ## 02111-1307, USA.
-CC = @CC@
 
 DEFS = @DEFS@ -I. -I$(srcdir) @CONFIG_INCLUDE_SPEC@
 CPPFLAGS = @CPPFLAGS@
-CFLAGS = @CFLAGS@
 LDFLAGS = @LDFLAGS@
 LIBS = @LIBS@
-
-COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
-LINK = $(CC) $(LDFLAGS) -o $@
index 60f9fbf3e7b503fae55e59c471371d9f4cdf41d5..88e27332e6b06d20073b5796501c13261f679ba1 100755 (executable)
--- a/interlock
+++ b/interlock
@@ -33,7 +33,7 @@ done
 
 # 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
+trap "rmdir $dirname > /dev/null 2>&1" 1 2 3 15
 
 # We have the lock, so run the program.
 $program ${1+"$@"}
index 14b67c7153da3ec3e36d7695385330820daeffc0..26419d5f6e010baed75e368535be43c013dc1013 100644 (file)
@@ -1,5 +1,13 @@
 Sun Aug 11 00:10:42 1996  Tom Tromey  <tromey@creche.cygnus.com>
 
+       * cxxnoc.test: New file.
+
+       * cxxlink.test: Use AC_PROG_CXX.
+
+       * lex.test: Use AC_PROG_LEX, AC_DECL_YYTEXT.
+
+       * yacc.test: Use AC_PROG_YACC in configure.in.
+
        * cxxlink.test: New file.
 
        * yacc.test: Fixed test for new yacc code.
index 52168ac02ba2dafb91abe77327cced4cc8129e2d..ca0394973c4321e748dc2373fbba559a79c07d8d 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 cxxlink.test
+exsource.test canon4.test dup.test defun.test cxxlink.test cxxnoc.test
 
 EXTRA_DIST = defs $(TESTS)
index bd8177444553f3b224a503f2adb8d9b2cc6f86ae..3a0eb54195b122a02d12b3eb8b26b15982fed693 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 cxxlink.test
+exsource.test canon4.test dup.test defun.test cxxlink.test cxxnoc.test
 
 EXTRA_DIST = defs $(TESTS)
 mkinstalldirs = $(top_srcdir)/mkinstalldirs
index c06acb8d10c1d639113af86705f38c45fcb2213a..6de9974e6ef8d4756bd2d9f3b09245cdf3a53ba6 100755 (executable)
@@ -4,6 +4,10 @@
 
 . $srcdir/defs || exit 1
 
+cat >> configure.in << 'END'
+AC_PROG_CXX
+END
+
 cat > Makefile.am << 'END'
 bin_PROGRAMS = lavalamp
 lavalamp_SOURCES = lava.c lamp.cxx
diff --git a/tests/cxxnoc.test b/tests/cxxnoc.test
new file mode 100755 (executable)
index 0000000..a4f5b00
--- /dev/null
@@ -0,0 +1,22 @@
+#! /bin/sh
+
+# Test to make sure pure C++ sources don't include C-specific code.
+
+. $srcdir/defs || exit 1
+
+cat >> configure.in << 'END'
+AC_PROG_CXX
+END
+
+cat > Makefile.am << 'END'
+sbin_PROGRAMS = anonymous
+anonymous_SOURCES = doe.C jane.C
+END
+
+: > doe.C
+: > jane.C
+
+$AUTOMAKE || exit 1
+
+grep CC Makefile.in && exit 1
+exit 0
index 42505fa44d5aa3908453ab8824368c1625f4284b..d6ea7c6e01f9ca8c57132d6dc2b847b828db4894 100755 (executable)
@@ -4,6 +4,11 @@
 
 . $srcdir/defs || exit 1
 
+cat >> configure.in << 'END'
+AC_PROG_LEX
+AC_DECL_YYTEXT
+END
+
 cat > Makefile.am << 'END'
 bin_PROGRAMS = zot
 zot_SOURCES = joe.l
index 3c8e37ce202ddbb354b8696b6ac4339f88a39069..366c975e84560436b57a316db6a37c05abff8aec 100755 (executable)
@@ -5,6 +5,10 @@
 
 . $srcdir/defs || exit 1
 
+cat >> configure.in << 'END'
+AC_PROG_YACC
+END
+
 cat > Makefile.am <<'END'
 bin_PROGRAMS = zardoz
 zardoz_SOURCES = zardoz.y