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.
** 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!
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.
# 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;
# 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');
$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)
$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");
}
}
$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_';
$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=/;
# C++ source extensions we've seen.
%cxx_extensions = ();
+
+ # TRUE if we've seen any non-C++ sources.
+ $seen_c_source = 0;
}
## 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 $@
# 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+"$@"}
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.
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)
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
. $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
--- /dev/null
+#! /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
. $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
. $srcdir/defs || exit 1
+cat >> configure.in << 'END'
+AC_PROG_YACC
+END
+
cat > Makefile.am <<'END'
bin_PROGRAMS = zardoz
zardoz_SOURCES = zardoz.y