'extensions' => '@',
'flags' => '$',
'linker' => '$',
+ 'name' => '$',
'output_arg' => '$',
'pure' => '$',
'_finish' => '$');
################################################################
# Initialize our list of languages that are internally supported.
-register_language ('c',
- ('ansi' => '1',
- 'autodep' => '',
- 'flags' => 'CFLAGS',
- 'compile' => '$(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)',
- 'compiler' => 'COMPILE',
- 'output-arg' => '-c',
- 'extensions' => ['c'],
- '_finish' => \&lang_c_finish));
-register_language ('cxx',
- ('linker' => 'CXXLINK',
- 'autodep' => 'CXX',
- 'flags' => 'CXXFLAGS',
+register_language ('name' => 'c',
+ 'ansi' => '1',
+ 'autodep' => '',
+ 'flags' => 'CFLAGS',
+ 'compile' => '$(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)',
+ 'compiler' => 'COMPILE',
+ 'output-arg' => '-c',
+ 'extensions' => ['c'],
+ '_finish' => \&lang_c_finish);
+register_language ('name' => 'cxx',
+ 'linker' => 'CXXLINK',
+ 'autodep' => 'CXX',
+ 'flags' => 'CXXFLAGS',
'compile' => '$(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)',
- 'compiler' => 'CXXCOMPILE',
- 'output-arg' => '-c -o $@',
- 'pure' => 'yes',
- 'extensions' => ['c++', 'cc', 'cpp', 'cxx', 'C'],
- '_finish' => \&lang_cxx_finish));
-register_language ('objc',
- ('linker' => 'OBJCLINK',
- 'autodep' => 'OBJC',
- 'flags' => 'OBJCFLAGS',
- 'compile' => '$(OBJC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS)',
- 'compiler' => 'OBJCCOMPILE',
- 'output-arg' => '-c -o $@',
- 'pure' => 'yes',
- 'extensions' => ['m'],
- '_finish' => \&lang_objc_finish));
-register_language ('header',
- ('extensions' => ['h', 'H', 'hxx', 'h++', 'hh', 'hpp', 'inc'],
- # Nothing to do.
- '_finish' => sub { }));
+ 'compiler' => 'CXXCOMPILE',
+ 'output-arg' => '-c -o $@',
+ 'pure' => 'yes',
+ 'extensions' => ['c++', 'cc', 'cpp', 'cxx', 'C'],
+ '_finish' => \&lang_cxx_finish);
+register_language ('name' => 'objc',
+ 'linker' => 'OBJCLINK',
+ 'autodep' => 'OBJC',
+ 'flags' => 'OBJCFLAGS',
+ 'compile' => '$(OBJC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS)',
+ 'compiler' => 'OBJCCOMPILE',
+ 'output-arg' => '-c -o $@',
+ 'pure' => 'yes',
+ 'extensions' => ['m'],
+ '_finish' => \&lang_objc_finish);
+register_language ('name' => 'header',
+ 'extensions' => ['h', 'H', 'hxx', 'h++', 'hh', 'hpp', 'inc'],
+ # Nothing to do.
+ '_finish' => sub { });
# For now, yacc and lex can't be handled on a per-exe basis.
-register_language ('yacc',
- ('ansi' => '1',
- 'derived-autodep' => 'yes',
- 'extensions' => ['y'],
- '_finish' => \&lang_yacc_finish));
-register_language ('yaccxx',
- ('linker' => 'CXXLINK',
- 'derived-autodep' => 'yes',
- 'extensions' => ['y++', 'yy', 'yxx', 'ypp'],
- '_finish' => \&lang_yacc_finish));
-register_language ('lex',
- ('ansi' => '1',
- 'derived-autodep' => 'yes',
- 'extensions' => ['l'],
- '_finish' => \&lang_lex_finish));
-register_language ('lexxx',
- ('linker' => 'CXXLINK',
- 'derived-autodep' => 'yes',
- 'extensions' => ['l++', 'll', 'lxx', 'lpp'],
- '_finish' => \&lang_lex_finish));
-register_language ('asm',
- ('flags' => 'CFLAGS',
- # FIXME: asmflags?
- 'compile' => '$(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)',
- # FIXME: a different compiler?
- 'compiler' => 'COMPILE',
- 'output-arg' => '-c',
- 'extensions' => ['s', 'S'],
- # We need the C code for assembly.
- '_finish' => \&lang_c_finish));
-
-register_language ('f77',
- ('linker' => 'F77LINK',
- 'flags' => 'FFLAGS',
- 'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS)',
- 'compiler' => 'F77COMPILE',
- 'output-arg' => '-c -o $@',
- 'pure' => 'yes',
- 'extensions' => ['f', 'for', 'f90'],
- '_finish' => \&lang_f77_finish));
-register_language ('ppf77',
- ('linker' => 'F77LINK',
- 'flags' => 'FFLAGS',
- 'compile' => '$(F77) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)',
- 'compiler' => 'PPF77COMPILE',
- 'output-arg' => '-c -o $@',
- 'pure' => 'yes',
- 'extensions' => ['F'],
- '_finish' => \&lang_ppf77_finish));
-register_language ('ratfor',
- ('linker' => 'F77LINK',
+register_language ('name' => 'yacc',
+ 'ansi' => '1',
+ 'derived-autodep' => 'yes',
+ 'extensions' => ['y'],
+ '_finish' => \&lang_yacc_finish);
+register_language ('name' => 'yaccxx',
+ 'linker' => 'CXXLINK',
+ 'derived-autodep' => 'yes',
+ 'extensions' => ['y++', 'yy', 'yxx', 'ypp'],
+ '_finish' => \&lang_yacc_finish);
+register_language ('name' => 'lex',
+ 'ansi' => '1',
+ 'derived-autodep' => 'yes',
+ 'extensions' => ['l'],
+ '_finish' => \&lang_lex_finish);
+register_language ('name' => 'lexxx',
+ 'linker' => 'CXXLINK',
+ 'derived-autodep' => 'yes',
+ 'extensions' => ['l++', 'll', 'lxx', 'lpp'],
+ '_finish' => \&lang_lex_finish);
+register_language ('name' => 'asm',
+ 'flags' => 'CFLAGS',
+ # FIXME: asmflags?
+ 'compile' => '$(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)',
+ # FIXME: a different compiler?
+ 'compiler' => 'COMPILE',
+ 'output-arg' => '-c',
+ 'extensions' => ['s', 'S'],
+ # We need the C code for assembly.
+ '_finish' => \&lang_c_finish);
+
+register_language ('name' => 'f77',
+ 'linker' => 'F77LINK',
+ 'flags' => 'FFLAGS',
+ 'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS)',
+ 'compiler' => 'F77COMPILE',
+ 'output-arg' => '-c -o $@',
+ 'pure' => 'yes',
+ 'extensions' => ['f', 'for', 'f90'],
+ '_finish' => \&lang_f77_finish);
+register_language ('name' => 'ppf77',
+ 'linker' => 'F77LINK',
+ 'flags' => 'FFLAGS',
+ 'compile' => '$(F77) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)',
+ 'compiler' => 'PPF77COMPILE',
+ 'output-arg' => '-c -o $@',
+ 'pure' => 'yes',
+ 'extensions' => ['F'],
+ '_finish' => \&lang_ppf77_finish);
+register_language ('name' => 'ratfor',
+ 'linker' => 'F77LINK',
'flags' => 'RFLAGS',
- # FIXME also FFLAGS.
- 'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)',
- 'compiler' => 'RCOMPILE',
- 'output-arg' => '-c -o $@',
- 'pure' => 'yes',
- 'extensions' => ['r'],
- '_finish' => \&lang_ratfor_finish));
+ # FIXME also FFLAGS.
+ 'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)',
+ 'compiler' => 'RCOMPILE',
+ 'output-arg' => '-c -o $@',
+ 'pure' => 'yes',
+ 'extensions' => ['r'],
+ '_finish' => \&lang_ratfor_finish);
# FIXME: for now we can't do dependency tracking for Java.
# autodep=GCJ
-register_language ('java',
- ('linker' => 'GCJLINK',
- 'flags' => 'GCJFLAGS',
- 'compile' => '$(GCJ) $(DEFS) $(INCLUDES) $(AM_GCJFLAGS) $(GCJFLAGS)',
- 'compiler' => 'GCJCOMPILE',
- 'output-arg' => '-c -o $@',
- 'pure' => 'yes',
- 'extensions' => ['java', 'class', 'zip', 'jar'],
- '_finish' => \&lang_java_finish));
+register_language ('name' => 'java',
+ 'linker' => 'GCJLINK',
+ 'flags' => 'GCJFLAGS',
+ 'compile' => '$(GCJ) $(DEFS) $(INCLUDES) $(AM_GCJFLAGS) $(GCJFLAGS)',
+ 'compiler' => 'GCJCOMPILE',
+ 'output-arg' => '-c -o $@',
+ 'pure' => 'yes',
+ 'extensions' => ['java', 'class', 'zip', 'jar'],
+ '_finish' => \&lang_java_finish);
################################################################
}
# The rest of the loop is done once per language.
- next if defined $done{$lang};
- $done{$lang} = 1;
+ next if defined $done{$lang_obj->name};
+ $done{$lang_obj} = 1;
# If the source to a program consists entirely of code from a
# `pure' language, for instance C++ for Fortran 77, then we
{
&saw_extension ($extension);
# Found the language, so see what it says.
- my $subr = 'lang_' . $lang . '_rewrite';
+ my $subr = 'lang_' . $lang_obj->name . '_rewrite';
# Note: computed subr call.
my $r = & $subr ($directory, $base, $extension);
# Skip this entry if we were asked not to process it.
$object = $dname . '-' . $object;
&require_file ($FOREIGN, 'compile')
- if $lang eq 'c';
+ if $lang_obj->name eq 'c';
- &prog_error ("$lang flags defined without compiler")
+ &prog_error ("$lang_obj->name flags defined without compiler")
if ! defined $lang_obj->compile;
# Compute the rule to compile this object.
$rule = '';
my $obj_sans_ext = substr ($object, 0,
- length ($this_obj_ext));
- push (@{$lang_specific_files{$lang}},
+ push (@{$lang_specific_files{$lang_obj->name}},
"$derived $full $obj_sans_ext");
}
}
# Transform .o or $o file into .P file (for automatic
# dependency code).
- if ($lang
+ if ($lang_obj->name
&& ($lang_obj->autodep ne 'no'
|| $lang_obj->derived_autodep eq 'yes'))
{
'COMPILE' => $compile,
'LTCOMPILE' => $ltcompile);
- foreach my $ext (&lang_extensions ($lang))
+ foreach my $ext (&lang_extensions ($lang_obj->name))
{
$output_rules .= (&file_contents ('depend2',
(%transform,
# Now include code for each specially handled object with this
# language.
my %seen_files = ();
- foreach my $file (@{$lang_specific_files{$lang}})
+ foreach my $file (@{$lang_specific_files{$lang_obj->name}})
{
my ($derived, $source, $obj) = split (' ', $file);
#
# Functions to handle files of each language.
-# Each `lang_X_rewrite' function follows a simple formula:
-# * Args are the directory, base name and extension of the file.
-# * Return value is 1 if file is to be dealt with, 0 otherwise.
-# Much of the actual processing is handled in handle_single_transform_list.
-# These functions exist so that auxiliary information can be recorded
-# for a later cleanup pass. Note that the calls to these functions
-# are computed, so don't bother searching for their precise names
-# in the source.
+# Each `lang_X_rewrite($DIRECTORY, $BASE, $EXT)' function follows a
+# simple formula: Return value is $LANG_SUBDIR if the resulting object
+# file should be in a subdir if the source file is, $LANG_PROCESS if
+# file is to be dealt with, $LANG_IGNORE otherwise.
+
+# Much of the actual processing is handled in
+# handle_single_transform_list. These functions exist so that
+# auxiliary information can be recorded for a later cleanup pass.
+# Note that the calls to these functions are computed, so don't bother
+# searching for their precise names in the source.
# This is just a convenience function that can be used to determine
# when a subdir object should be used.
}
-# register_language ($LANG, %OPTIONS)
-# -----------------------------------
+# register_language (%ATTRIBUTE)
+# ------------------------------
# Register a single language. LANGUAGE is the name of the language.
-# Each OPTION is either of the form ATTRIBUTE => VALUE.
+# Each %ATTRIBUTE is of the form ATTRIBUTE => VALUE.
sub register_language ($%)
{
- my ($lang, %option) = @_;
- my $lang_obj = new Language;
+ my (%option) = @_;
+ my $lang = new Language;
# Set the defaults.
- $lang_obj->ansi (0);
- $lang_obj->autodep ('no');
- $lang_obj->derived_autodep ('no');
- $lang_obj->linker ('');
+ $lang->ansi (0);
+ $lang->autodep ('no');
+ $lang->derived_autodep ('no');
+ $lang->linker ('');
# `pure' is `yes' or `no'. A `pure' language is one where, if all
# the files in a directory are of that language, then we do not
# require the C compiler or any code to call it.
- $lang_obj->pure ('no');
+ $lang->pure ('no');
while (my ($attr, $value) = each %option)
{
if ($attr eq 'ansi')
{
- $lang_obj->ansi ($value);
+ $lang->ansi ($value);
}
elsif ($attr eq 'autodep')
{
- $lang_obj->autodep ($value);
+ $lang->autodep ($value);
}
elsif ($attr eq 'compile')
{
- $lang_obj->compile ($value);
+ $lang->compile ($value);
}
elsif ($attr eq 'compiler')
{
- $lang_obj->compiler ($value);
+ $lang->compiler ($value);
}
elsif ($attr eq 'derived-autodep')
{
- $lang_obj->derived_autodep ($value);
+ $lang->derived_autodep ($value);
}
elsif ($attr eq 'extensions')
{
my $cnt = 0;
foreach (@{$value})
{
- $lang_obj->extensions ($cnt, $_);
+ $lang->extensions ($cnt, $_);
++$cnt;
}
}
elsif ($attr eq 'flags')
{
- $lang_obj->flags ($value);
+ $lang->flags ($value);
}
elsif ($attr eq 'linker')
{
- $lang_obj->linker ($value);
+ $lang->linker ($value);
+ }
+ elsif ($attr eq 'name')
+ {
+ $lang->name ($value);
}
elsif ($attr eq 'output-arg')
{
- $lang_obj->output_arg ($value);
+ $lang->output_arg ($value);
}
elsif ($attr eq 'pure')
{
- $lang_obj->pure ($value);
+ $lang->pure ($value);
}
elsif ($attr eq '_finish')
{
- $lang_obj->_finish ($value);
+ $lang->_finish ($value);
}
else
{
- prog_error ("register_language: $lang: invalid attribute: $attr");
+ prog_error ("register_language: "
+ . $lang->name
+ . ": invalid attribute: $attr");
}
}
# Fill indexes.
- grep ($extension_map{$_} = $lang, @{$lang_obj->extensions});
- $languages{$lang} = $lang_obj;
+ grep ($extension_map{$_} = $lang->name, @{$lang->extensions});
+ $languages{$lang->name} = $lang;
}
# This function is used to find a path from a user-specified suffix to