13
0
Fork 0
This repository has been archived on 2024-07-04. You can view files and clone it, but cannot push or open issues or pull requests.
mysql-admtools/bin/automake

7524 lines
216 KiB
Plaintext
Raw Permalink Normal View History

2007-02-13 22:11:55 +01:00
#!/usr/bin/perl -w
# -*- perl -*-
# Generated from automake.in; do not edit by hand.
eval 'case $# in 0) exec /usr/bin/perl -S "$0";; *) exec /usr/bin/perl -S "$0" "$@";; esac'
if 0;
# automake - create Makefile.in from Makefile.am
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005 Free Software Foundation, Inc.
# 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.
# Originally written by David Mackenzie <djm@gnu.ai.mit.edu>.
# Perl reimplementation by Tom Tromey <tromey@redhat.com>.
package Language;
BEGIN
{
my $perllibdir = $ENV{'perllibdir'} || '/usr/local/share/automake19';
unshift @INC, (split ':', $perllibdir);
# Override SHELL. This is required on DJGPP so that system() uses
# bash, not COMMAND.COM which doesn't quote arguments properly.
# Other systems aren't expected to use $SHELL when Automake
# runs, but it should be safe to drop the `if DJGPP' guard if
# it turns up other systems need the same thing. After all,
# if SHELL is used, ./configure's SHELL is always better than
# the user's SHELL (which may be something like tcsh).
$ENV{'SHELL'} = '/bin/sh' if exists $ENV{'DJGPP'};
}
use Automake::Struct;
struct (# Short name of the language (c, f77...).
'name' => "\$",
# Nice name of the language (C, Fortran 77...).
'Name' => "\$",
# List of configure variables which must be defined.
'config_vars' => '@',
'ansi' => "\$",
# `pure' is `1' or `'. 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.
'pure' => "\$",
'autodep' => "\$",
# Name of the compiling variable (COMPILE).
'compiler' => "\$",
# Content of the compiling variable.
'compile' => "\$",
# Flag to require compilation without linking (-c).
'compile_flag' => "\$",
'extensions' => '@',
# A subroutine to compute a list of possible extensions of
# the product given the input extensions.
# (defaults to a subroutine which returns ('.$(OBJEXT)', '.lo'))
'output_extensions' => "\$",
# A list of flag variables used in 'compile'.
# (defaults to [])
'flags' => "@",
# Any tag to pass to libtool while compiling.
'libtool_tag' => "\$",
# The file to use when generating rules for this language.
# The default is 'depend2'.
'rule_file' => "\$",
# Name of the linking variable (LINK).
'linker' => "\$",
# Content of the linking variable.
'link' => "\$",
# Name of the linker variable (LD).
'lder' => "\$",
# Content of the linker variable ($(CC)).
'ld' => "\$",
# Flag to specify the output file (-o).
'output_flag' => "\$",
'_finish' => "\$",
# This is a subroutine which is called whenever we finally
# determine the context in which a source file will be
# compiled.
'_target_hook' => "\$");
sub finish ($)
{
my ($self) = @_;
if (defined $self->_finish)
{
&{$self->_finish} ();
}
}
sub target_hook ($$$$%)
{
my ($self) = @_;
if (defined $self->_target_hook)
{
&{$self->_target_hook} (@_);
}
}
package Automake;
use strict;
use Automake::Config;
use Automake::General;
use Automake::XFile;
use Automake::Channels;
use Automake::ChannelDefs;
use Automake::Configure_ac;
use Automake::FileUtils;
use Automake::Location;
use Automake::Condition qw/TRUE FALSE/;
use Automake::DisjConditions;
use Automake::Options;
use Automake::Version;
use Automake::Variable;
use Automake::VarDef;
use Automake::Rule;
use Automake::RuleDef;
use Automake::Wrap 'makefile_wrap';
use File::Basename;
use Carp;
## ----------- ##
## Constants. ##
## ----------- ##
# Some regular expressions. One reason to put them here is that it
# makes indentation work better in Emacs.
# Writing singled-quoted-$-terminated regexes is a pain because
# perl-mode thinks of $' as the ${'} variable (instead of a $ followed
# by a closing quote. Letting perl-mode think the quote is not closed
# leads to all sort of misindentations. On the other hand, defining
# regexes as double-quoted strings is far less readable. So usually
# we will write:
#
# $REGEX = '^regex_value' . "\$";
my $IGNORE_PATTERN = '^\s*##([^#\n].*)?\n';
my $WHITE_PATTERN = '^\s*' . "\$";
my $COMMENT_PATTERN = '^#';
my $TARGET_PATTERN='[$a-zA-Z_.@%][-.a-zA-Z0-9_(){}/$+@%]*';
# A rule has three parts: a list of targets, a list of dependencies,
# and optionally actions.
my $RULE_PATTERN =
"^($TARGET_PATTERN(?:(?:\\\\\n|\\s)+$TARGET_PATTERN)*) *:([^=].*|)\$";
# Only recognize leading spaces, not leading tabs. If we recognize
# leading tabs here then we need to make the reader smarter, because
# otherwise it will think rules like `foo=bar; \' are errors.
my $ASSIGNMENT_PATTERN = '^ *([^ \t=:+]*)\s*([:+]?)=\s*(.*)' . "\$";
# This pattern recognizes a Gnits version id and sets $1 if the
# release is an alpha release. We also allow a suffix which can be
# used to extend the version number with a "fork" identifier.
my $GNITS_VERSION_PATTERN = '\d+\.\d+([a-z]|\.\d+)?(-[A-Za-z0-9]+)?';
my $IF_PATTERN = '^if\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*)\s*(?:#.*)?' . "\$";
my $ELSE_PATTERN =
'^else(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?' . "\$";
my $ENDIF_PATTERN =
'^endif(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?' . "\$";
my $PATH_PATTERN = '(\w|[+/.-])+';
# This will pass through anything not of the prescribed form.
my $INCLUDE_PATTERN = ('^include\s+'
. '((\$\(top_srcdir\)/' . $PATH_PATTERN . ')'
. '|(\$\(srcdir\)/' . $PATH_PATTERN . ')'
. '|([^/\$]' . $PATH_PATTERN . '))\s*(#.*)?' . "\$");
# Match `-d' as a command-line argument in a string.
my $DASH_D_PATTERN = "(^|\\s)-d(\\s|\$)";
# Directories installed during 'install-exec' phase.
my $EXEC_DIR_PATTERN =
'^(?:bin|sbin|libexec|sysconf|localstate|lib|pkglib|.*exec.*)' . "\$";
# Values for AC_CANONICAL_*
use constant AC_CANONICAL_BUILD => 1;
use constant AC_CANONICAL_HOST => 2;
use constant AC_CANONICAL_TARGET => 3;
# Values indicating when something should be cleaned.
use constant MOSTLY_CLEAN => 0;
use constant CLEAN => 1;
use constant DIST_CLEAN => 2;
use constant MAINTAINER_CLEAN => 3;
# Libtool files.
my @libtool_files = qw(ltmain.sh config.guess config.sub);
# ltconfig appears here for compatibility with old versions of libtool.
my @libtool_sometimes = qw(ltconfig ltcf-c.sh ltcf-cxx.sh ltcf-gcj.sh);
# Commonly found files we look for and automatically include in
# DISTFILES.
my @common_files =
(qw(ABOUT-GNU ABOUT-NLS AUTHORS BACKLOG COPYING COPYING.DOC COPYING.LIB
COPYING.LESSER ChangeLog INSTALL NEWS README THANKS TODO
ansi2knr.1 ansi2knr.c compile config.guess config.rpath config.sub
depcomp elisp-comp install-sh libversion.in mdate-sh missing
mkinstalldirs py-compile texinfo.tex ylwrap),
@libtool_files, @libtool_sometimes);
# Commonly used files we auto-include, but only sometimes. This list
# is used for the --help output only.
my @common_sometimes =
qw(aclocal.m4 acconfig.h config.h.top config.h.bot configure
configure.ac configure.in stamp-vti);
# Standard directories from the GNU Coding Standards, and additional
# pkg* directories from Automake. Stored in a hash for fast member check.
my %standard_prefix =
map { $_ => 1 } (qw(bin data exec include info lib libexec lisp
localstate man man1 man2 man3 man4 man5 man6
man7 man8 man9 oldinclude pkgdatadir
pkgincludedir pkglibdir sbin sharedstate
sysconf));
# Copyright on generated Makefile.ins.
my $gen_copyright = "\
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
";
# These constants are returned by lang_*_rewrite functions.
# LANG_SUBDIR means that the resulting object file should be in a
# subdir if the source file is. In this case the file name cannot
# have `..' components.
use constant LANG_IGNORE => 0;
use constant LANG_PROCESS => 1;
use constant LANG_SUBDIR => 2;
# These are used when keeping track of whether an object can be built
# by two different paths.
use constant COMPILE_LIBTOOL => 1;
use constant COMPILE_ORDINARY => 2;
# We can't always associate a location to a variable or a rule,
# when its defined by Automake. We use INTERNAL in this case.
use constant INTERNAL => new Automake::Location;
## ---------------------------------- ##
## Variables related to the options. ##
## ---------------------------------- ##
# TRUE if we should always generate Makefile.in.
my $force_generation = 1;
# From the Perl manual.
my $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
# TRUE if missing standard files should be installed.
my $add_missing = 0;
# TRUE if we should copy missing files; otherwise symlink if possible.
my $copy_missing = 0;
# TRUE if we should always update files that we know about.
my $force_missing = 0;
## ---------------------------------------- ##
## Variables filled during files scanning. ##
## ---------------------------------------- ##
# Name of the configure.ac file.
my $configure_ac;
# Files found by scanning configure.ac for LIBOBJS.
my %libsources = ();
# Names used in AC_CONFIG_HEADER call.
my @config_headers = ();
# Names used in AC_CONFIG_LINKS call.
my @config_links = ();
# Directory where output files go. Actually, output files are
# relative to this directory.
my $output_directory;
# List of Makefile.am's to process, and their corresponding outputs.
my @input_files = ();
my %output_files = ();
# Complete list of Makefile.am's that exist.
my @configure_input_files = ();
# List of files in AC_CONFIG_FILES/AC_OUTPUT without Makefile.am's,
# and their outputs.
my @other_input_files = ();
# Where each AC_CONFIG_FILES/AC_OUTPUT/AC_CONFIG_LINK/AC_CONFIG_HEADER appears.
# The keys are the files created by these macros.
my %ac_config_files_location = ();
# Directory to search for configure-required files. This
# will be computed by &locate_aux_dir and can be set using
# AC_CONFIG_AUX_DIR in configure.ac.
# $CONFIG_AUX_DIR is the `raw' directory, valid only in the source-tree.
my $config_aux_dir = '';
my $config_aux_dir_set_in_configure_ac = 0;
# $AM_CONFIG_AUX_DIR is prefixed with $(top_srcdir), so it can be used
# in Makefiles.
my $am_config_aux_dir = '';
# Whether AM_GNU_GETTEXT has been seen in configure.ac.
my $seen_gettext = 0;
# Whether AM_GNU_GETTEXT([external]) is used.
my $seen_gettext_external = 0;
# Where AM_GNU_GETTEXT appears.
my $ac_gettext_location;
# Lists of tags supported by Libtool.
my %libtool_tags = ();
# Most important AC_CANONICAL_* macro seen so far.
my $seen_canonical = 0;
# Location of that macro.
my $canonical_location;
# Where AM_MAINTAINER_MODE appears.
my $seen_maint_mode;
# Actual version we've seen.
my $package_version = '';
# Where version is defined.
my $package_version_location;
# TRUE if we've seen AC_ENABLE_MULTILIB.
my $seen_multilib = 0;
# TRUE if we've seen AM_PROG_CC_C_O
my $seen_cc_c_o = 0;
# Where AM_INIT_AUTOMAKE is called;
my $seen_init_automake = 0;
# TRUE if we've seen AM_AUTOMAKE_VERSION.
my $seen_automake_version = 0;
# Hash table of discovered configure substitutions. Keys are names,
# values are `FILE:LINE' strings which are used by error message
# generation.
my %configure_vars = ();
# Files included by $configure_ac.
my @configure_deps = ();
# Greatest timestamp of configure's dependencies.
my $configure_deps_greatest_timestamp = 0;
# Hash table of AM_CONDITIONAL variables seen in configure.
my %configure_cond = ();
# This maps extensions onto language names.
my %extension_map = ();
# List of the DIST_COMMON files we discovered while reading
# configure.in
my $configure_dist_common = '';
# This maps languages names onto objects.
my %languages = ();
# List of targets we must always output.
# FIXME: Complete, and remove falsely required targets.
my %required_targets =
(
'all' => 1,
'dvi' => 1,
'pdf' => 1,
'ps' => 1,
'info' => 1,
'install-info' => 1,
'install' => 1,
'install-data' => 1,
'install-exec' => 1,
'uninstall' => 1,
# FIXME: Not required, temporary hacks.
# Well, actually they are sort of required: the -recursive
# targets will run them anyway...
'dvi-am' => 1,
'pdf-am' => 1,
'ps-am' => 1,
'info-am' => 1,
'install-data-am' => 1,
'install-exec-am' => 1,
'installcheck-am' => 1,
'uninstall-am' => 1,
'install-man' => 1,
);
# Set to 1 if this run will create the Makefile.in that distribute
# the files in config_aux_dir.
my $automake_will_process_aux_dir = 0;
# The name of the Makefile currently being processed.
my $am_file = 'BUG';
################################################################
## ------------------------------------------ ##
## Variables reset by &initialize_per_input. ##
## ------------------------------------------ ##
# Basename and relative dir of the input file.
my $am_file_name;
my $am_relative_dir;
# Same but wrt Makefile.in.
my $in_file_name;
my $relative_dir;
# Greatest timestamp of the output's dependencies (excluding
# configure's dependencies).
my $output_deps_greatest_timestamp;
# These two variables are used when generating each Makefile.in.
# They hold the Makefile.in until it is ready to be printed.
my $output_rules;
my $output_vars;
my $output_trailer;
my $output_all;
my $output_header;
# This is the conditional stack, updated on if/else/endif, and
# used to build Condition objects.
my @cond_stack;
# This holds the set of included files.
my @include_stack;
# This holds a list of directories which we must create at `dist'
# time. This is used in some strange scenarios involving weird
# AC_OUTPUT commands.
my %dist_dirs;
# List of dependencies for the obvious targets.
my @all;
my @check;
my @check_tests;
# Keys in this hash table are files to delete. The associated
# value tells when this should happen (MOSTLY_CLEAN, DIST_CLEAN, etc.)
my %clean_files;
# Keys in this hash table are object files or other files in
# subdirectories which need to be removed. This only holds files
# which are created by compilations. The value in the hash indicates
# when the file should be removed.
my %compile_clean_files;
# Keys in this hash table are directories where we expect to build a
# libtool object. We use this information to decide what directories
# to delete.
my %libtool_clean_directories;
# Value of `$(SOURCES)', used by tags.am.
my @sources;
# Sources which go in the distribution.
my @dist_sources;
# This hash maps object file names onto their corresponding source
# file names. This is used to ensure that each object is created
# by a single source file.
my %object_map;
# This hash maps object file names onto an integer value representing
# whether this object has been built via ordinary compilation or
# libtool compilation (the COMPILE_* constants).
my %object_compilation_map;
# This keeps track of the directories for which we've already
# created dirstamp code.
my %directory_map;
# All .P files.
my %dep_files;
# This is a list of all targets to run during "make dist".
my @dist_targets;
# Keys in this hash are the basenames of files which must depend on
# ansi2knr. Values are either the empty string, or the directory in
# which the ANSI source file appears; the directory must have a
# trailing `/'.
my %de_ansi_files;
# This is the name of the redirect `all' target to use.
my $all_target;
# This keeps track of which extensions we've seen (that we care
# about).
my %extension_seen;
# This is random scratch space for the language finish functions.
# Don't randomly overwrite it; examine other uses of keys first.
my %language_scratch;
# We keep track of which objects need special (per-executable)
# handling on a per-language basis.
my %lang_specific_files;
# This is set when `handle_dist' has finished. Once this happens,
# we should no longer push on dist_common.
my $handle_dist_run;
# Used to store a set of linkers needed to generate the sources currently
# under consideration.
my %linkers_used;
# True if we need `LINK' defined. This is a hack.
my $need_link;
# Was get_object_extension run?
# FIXME: This is a hack. a better switch should be found.
my $get_object_extension_was_run;
# Record each file processed by make_paragraphs.
my %transformed_files;
################################################################
# var_SUFFIXES_trigger ($TYPE, $VALUE)
# ------------------------------------
# This is called by Automake::Variable::define() when SUFFIXES
# is defined ($TYPE eq '') or appended ($TYPE eq '+').
# The work here needs to be performed as a side-effect of the
# macro_define() call because SUFFIXES definitions impact
# on $KNOWN_EXTENSIONS_PATTERN which is used used when parsing
# the input am file.
sub var_SUFFIXES_trigger ($$)
{
my ($type, $value) = @_;
accept_extensions (split (' ', $value));
}
Automake::Variable::hook ('SUFFIXES', \&var_SUFFIXES_trigger);
################################################################
## --------------------------------- ##
## Forward subroutine declarations. ##
## --------------------------------- ##
sub register_language (%);
sub file_contents_internal ($$$%);
sub define_files_variable ($\@$$);
# &initialize_per_input ()
# ------------------------
# (Re)-Initialize per-Makefile.am variables.
sub initialize_per_input ()
{
reset_local_duplicates ();
$am_file_name = '';
$am_relative_dir = '';
$in_file_name = '';
$relative_dir = '';
$output_deps_greatest_timestamp = 0;
$output_rules = '';
$output_vars = '';
$output_trailer = '';
$output_all = '';
$output_header = '';
Automake::Options::reset;
Automake::Variable::reset;
Automake::Rule::reset;
@cond_stack = ();
@include_stack = ();
%dist_dirs = ();
@all = ();
@check = ();
@check_tests = ();
%clean_files = ();
@sources = ();
@dist_sources = ();
%object_map = ();
%object_compilation_map = ();
%directory_map = ();
%dep_files = ();
@dist_targets = ();
%de_ansi_files = ();
$all_target = '';
%extension_seen = ();
%language_scratch = ();
%lang_specific_files = ();
$handle_dist_run = 0;
$need_link = 0;
$get_object_extension_was_run = 0;
%compile_clean_files = ();
# We always include `.'. This isn't strictly correct.
%libtool_clean_directories = ('.' => 1);
%transformed_files = ();
}
################################################################
# Initialize our list of languages that are internally supported.
# C.
register_language ('name' => 'c',
'Name' => 'C',
'config_vars' => ['CC'],
'ansi' => 1,
'autodep' => '',
'flags' => ['CFLAGS', 'CPPFLAGS'],
'compiler' => 'COMPILE',
'compile' => '$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)',
'lder' => 'CCLD',
'ld' => '$(CC)',
'linker' => 'LINK',
'link' => '$(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
'compile_flag' => '-c',
'libtool_tag' => 'CC',
'extensions' => ['.c'],
'_finish' => \&lang_c_finish);
# C++.
register_language ('name' => 'cxx',
'Name' => 'C++',
'config_vars' => ['CXX'],
'linker' => 'CXXLINK',
'link' => '$(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
'autodep' => 'CXX',
'flags' => ['CXXFLAGS', 'CPPFLAGS'],
'compile' => '$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)',
'compiler' => 'CXXCOMPILE',
'compile_flag' => '-c',
'output_flag' => '-o',
'libtool_tag' => 'CXX',
'lder' => 'CXXLD',
'ld' => '$(CXX)',
'pure' => 1,
'extensions' => ['.c++', '.cc', '.cpp', '.cxx', '.C']);
# Objective C.
register_language ('name' => 'objc',
'Name' => 'Objective C',
'config_vars' => ['OBJC'],
'linker' => 'OBJCLINK',,
'link' => '$(OBJCLD) $(AM_OBJCFLAGS) $(OBJCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
'autodep' => 'OBJC',
'flags' => ['OBJCFLAGS', 'CPPFLAGS'],
'compile' => '$(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS)',
'compiler' => 'OBJCCOMPILE',
'compile_flag' => '-c',
'output_flag' => '-o',
'lder' => 'OBJCLD',
'ld' => '$(OBJC)',
'pure' => 1,
'extensions' => ['.m']);
# Headers.
register_language ('name' => 'header',
'Name' => 'Header',
'extensions' => ['.h', '.H', '.hxx', '.h++', '.hh',
'.hpp', '.inc'],
# No output.
'output_extensions' => sub { return () },
# Nothing to do.
'_finish' => sub { });
# Yacc (C & C++).
register_language ('name' => 'yacc',
'Name' => 'Yacc',
'config_vars' => ['YACC'],
'flags' => ['YFLAGS'],
'compile' => '$(YACC) $(YFLAGS) $(AM_YFLAGS)',
'compiler' => 'YACCCOMPILE',
'extensions' => ['.y'],
'output_extensions' => sub { (my $ext = $_[0]) =~ tr/y/c/;
return ($ext,) },
'rule_file' => 'yacc',
'_finish' => \&lang_yacc_finish,
'_target_hook' => \&lang_yacc_target_hook);
register_language ('name' => 'yaccxx',
'Name' => 'Yacc (C++)',
'config_vars' => ['YACC'],
'rule_file' => 'yacc',
'flags' => ['YFLAGS'],
'compiler' => 'YACCCOMPILE',
'compile' => '$(YACC) $(YFLAGS) $(AM_YFLAGS)',
'extensions' => ['.y++', '.yy', '.yxx', '.ypp'],
'output_extensions' => sub { (my $ext = $_[0]) =~ tr/y/c/;
return ($ext,) },
'_finish' => \&lang_yacc_finish,
'_target_hook' => \&lang_yacc_target_hook);
# Lex (C & C++).
register_language ('name' => 'lex',
'Name' => 'Lex',
'config_vars' => ['LEX'],
'rule_file' => 'lex',
'flags' => ['LFLAGS'],
'compile' => '$(LEX) $(LFLAGS) $(AM_LFLAGS)',
'compiler' => 'LEXCOMPILE',
'extensions' => ['.l'],
'output_extensions' => sub { (my $ext = $_[0]) =~ tr/l/c/;
return ($ext,) },
'_finish' => \&lang_lex_finish,
'_target_hook' => \&lang_lex_target_hook);
register_language ('name' => 'lexxx',
'Name' => 'Lex (C++)',
'config_vars' => ['LEX'],
'rule_file' => 'lex',
'flags' => ['LFLAGS'],
'compile' => '$(LEX) $(LFLAGS) $(AM_LFLAGS)',
'compiler' => 'LEXCOMPILE',
'extensions' => ['.l++', '.ll', '.lxx', '.lpp'],
'output_extensions' => sub { (my $ext = $_[0]) =~ tr/l/c/;
return ($ext,) },
'_finish' => \&lang_lex_finish,
'_target_hook' => \&lang_lex_target_hook);
# Assembler.
register_language ('name' => 'asm',
'Name' => 'Assembler',
'config_vars' => ['CCAS', 'CCASFLAGS'],
'flags' => ['CCASFLAGS'],
# Users can set AM_ASFLAGS to includes DEFS, INCLUDES,
# or anything else required. They can also set AS.
'compile' => '$(CCAS) $(AM_CCASFLAGS) $(CCASFLAGS)',
'compiler' => 'CCASCOMPILE',
'compile_flag' => '-c',
'extensions' => ['.s', '.S'],
# With assembly we still use the C linker.
'_finish' => \&lang_c_finish);
# Fortran 77
register_language ('name' => 'f77',
'Name' => 'Fortran 77',
'linker' => 'F77LINK',
'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
'flags' => ['FFLAGS'],
'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS)',
'compiler' => 'F77COMPILE',
'compile_flag' => '-c',
'output_flag' => '-o',
'libtool_tag' => 'F77',
'lder' => 'F77LD',
'ld' => '$(F77)',
'pure' => 1,
'extensions' => ['.f', '.for']);
# Fortran
register_language ('name' => 'fc',
'Name' => 'Fortran',
'linker' => 'FCLINK',
'link' => '$(FCLD) $(AM_FCFLAGS) $(FCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
'flags' => ['FCFLAGS'],
'compile' => '$(FC) $(AM_FCFLAGS) $(FCFLAGS)',
'compiler' => 'FCCOMPILE',
'compile_flag' => '-c',
'output_flag' => '-o',
'lder' => 'FCLD',
'ld' => '$(FC)',
'pure' => 1,
'extensions' => ['.f90', '.f95']);
# Preprocessed Fortran
register_language ('name' => 'ppfc',
'Name' => 'Preprocessed Fortran',
'config_vars' => ['FC'],
'linker' => 'FCLINK',
'link' => '$(FCLD) $(AM_FCFLAGS) $(FCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
'lder' => 'FCLD',
'ld' => '$(FC)',
'flags' => ['FCFLAGS', 'CPPFLAGS'],
'compiler' => 'PPFCCOMPILE',
'compile' => '$(FC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS)',
'compile_flag' => '-c',
'output_flag' => '-o',
'libtool_tag' => 'FC',
'pure' => 1,
'extensions' => ['.F90','.F95']);
# Preprocessed Fortran 77
#
# The current support for preprocessing Fortran 77 just involves
# passing `$(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS)
# $(CPPFLAGS)' as additional flags to the Fortran 77 compiler, since
# this is how GNU Make does it; see the `GNU Make Manual, Edition 0.51
# for `make' Version 3.76 Beta' (specifically, from info file
# `(make)Catalogue of Rules').
#
# A better approach would be to write an Autoconf test
# (i.e. AC_PROG_FPP) for a Fortran 77 preprocessor, because not all
# Fortran 77 compilers know how to do preprocessing. The Autoconf
# macro AC_PROG_FPP should test the Fortran 77 compiler first for
# preprocessing capabilities, and then fall back on cpp (if cpp were
# available).
register_language ('name' => 'ppf77',
'Name' => 'Preprocessed Fortran 77',
'config_vars' => ['F77'],
'linker' => 'F77LINK',
'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
'lder' => 'F77LD',
'ld' => '$(F77)',
'flags' => ['FFLAGS', 'CPPFLAGS'],
'compiler' => 'PPF77COMPILE',
'compile' => '$(F77) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)',
'compile_flag' => '-c',
'output_flag' => '-o',
'libtool_tag' => 'F77',
'pure' => 1,
'extensions' => ['.F']);
# Ratfor.
register_language ('name' => 'ratfor',
'Name' => 'Ratfor',
'config_vars' => ['F77'],
'linker' => 'F77LINK',
'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
'lder' => 'F77LD',
'ld' => '$(F77)',
'flags' => ['RFLAGS', 'FFLAGS'],
# FIXME also FFLAGS.
'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)',
'compiler' => 'RCOMPILE',
'compile_flag' => '-c',
'output_flag' => '-o',
'libtool_tag' => 'F77',
'pure' => 1,
'extensions' => ['.r']);
# Java via gcj.
register_language ('name' => 'java',
'Name' => 'Java',
'config_vars' => ['GCJ'],
'linker' => 'GCJLINK',
'link' => '$(GCJLD) $(AM_GCJFLAGS) $(GCJFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
'autodep' => 'GCJ',
'flags' => ['GCJFLAGS'],
'compile' => '$(GCJ) $(AM_GCJFLAGS) $(GCJFLAGS)',
'compiler' => 'GCJCOMPILE',
'compile_flag' => '-c',
'output_flag' => '-o',
'libtool_tag' => 'GCJ',
'lder' => 'GCJLD',
'ld' => '$(GCJ)',
'pure' => 1,
'extensions' => ['.java', '.class', '.zip', '.jar']);
################################################################
# Error reporting functions.
# err_am ($MESSAGE, [%OPTIONS])
# -----------------------------
# Uncategorized errors about the current Makefile.am.
sub err_am ($;%)
{
msg_am ('error', @_);
}
# err_ac ($MESSAGE, [%OPTIONS])
# -----------------------------
# Uncategorized errors about configure.ac.
sub err_ac ($;%)
{
msg_ac ('error', @_);
}
# msg_am ($CHANNEL, $MESSAGE, [%OPTIONS])
# ---------------------------------------
# Messages about about the current Makefile.am.
sub msg_am ($$;%)
{
my ($channel, $msg, %opts) = @_;
msg $channel, "${am_file}.am", $msg, %opts;
}
# msg_ac ($CHANNEL, $MESSAGE, [%OPTIONS])
# ---------------------------------------
# Messages about about configure.ac.
sub msg_ac ($$;%)
{
my ($channel, $msg, %opts) = @_;
msg $channel, $configure_ac, $msg, %opts;
}
################################################################
# subst ($TEXT)
# -------------
# Return a configure-style substitution using the indicated text.
# We do this to avoid having the substitutions directly in automake.in;
# when we do that they are sometimes removed and this causes confusion
# and bugs.
sub subst ($)
{
my ($text) = @_;
return '@' . $text . '@';
}
################################################################
# $BACKPATH
# &backname ($REL-DIR)
# --------------------
# If I `cd $REL-DIR', then to come back, I should `cd $BACKPATH'.
# For instance `src/foo' => `../..'.
# Works with non strictly increasing paths, i.e., `src/../lib' => `..'.
sub backname ($)
{
my ($file) = @_;
my @res;
foreach (split (/\//, $file))
{
next if $_ eq '.' || $_ eq '';
if ($_ eq '..')
{
pop @res;
}
else
{
push (@res, '..');
}
}
return join ('/', @res) || '.';
}
################################################################
# Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.
sub handle_options
{
my $var = var ('AUTOMAKE_OPTIONS');
if ($var)
{
# FIXME: We should disallow conditional definitions of AUTOMAKE_OPTIONS.
if (process_option_list ($var->rdef (TRUE)->location,
$var->value_as_list_recursive (cond_filter =>
TRUE)))
{
return 1;
}
}
if ($strictness == GNITS)
{
set_option ('readme-alpha', INTERNAL);
set_option ('std-options', INTERNAL);
set_option ('check-news', INTERNAL);
}
return 0;
}
# shadow_unconditionally ($varname, $where)
# -----------------------------------------
# Return a $(variable) that contains all possible values
# $varname can take.
# If the VAR wasn't defined conditionally, return $(VAR).
# Otherwise we create a am__VAR_DIST variable which contains
# all possible values, and return $(am__VAR_DIST).
sub shadow_unconditionally ($$)
{
my ($varname, $where) = @_;
my $var = var $varname;
if ($var->has_conditional_contents)
{
$varname = "am__${varname}_DIST";
my @files = uniq ($var->value_as_list_recursive);
define_pretty_variable ($varname, TRUE, $where, @files);
}
return "\$($varname)"
}
# get_object_extension ($EXTENSION)
# ---------------------------------
# Prefix $EXTENSION with $U if ansi2knr is in use.
sub get_object_extension ($)
{
my ($extension) = @_;
# Check for automatic de-ANSI-fication.
$extension = '$U' . $extension
if option 'ansi2knr';
$get_object_extension_was_run = 1;
return $extension;
}
# Call finish function for each language that was used.
sub handle_languages
{
if (! option 'no-dependencies')
{
# Include auto-dep code. Don't include it if DEP_FILES would
# be empty.
if (&saw_sources_p (0) && keys %dep_files)
{
# Set location of depcomp.
&define_variable ('depcomp',
"\$(SHELL) $am_config_aux_dir/depcomp",
INTERNAL);
&define_variable ('am__depfiles_maybe', 'depfiles', INTERNAL);
require_conf_file ("$am_file.am", FOREIGN, 'depcomp');
my @deplist = sort keys %dep_files;
# Generate each `include' individually. Irix 6 make will
# not properly include several files resulting from a
# variable expansion; generating many separate includes
# seems safest.
$output_rules .= "\n";
foreach my $iter (@deplist)
{
$output_rules .= (subst ('AMDEP_TRUE')
. subst ('am__include')
. ' '
. subst ('am__quote')
. $iter
. subst ('am__quote')
. "\n");
}
# Compute the set of directories to remove in distclean-depend.
my @depdirs = uniq (map { dirname ($_) } @deplist);
$output_rules .= &file_contents ('depend',
new Automake::Location,
DEPDIRS => "@depdirs");
}
}
else
{
&define_variable ('depcomp', '', INTERNAL);
&define_variable ('am__depfiles_maybe', '', INTERNAL);
}
my %done;
# Is the c linker needed?
my $needs_c = 0;
foreach my $ext (sort keys %extension_seen)
{
next unless $extension_map{$ext};
my $lang = $languages{$extension_map{$ext}};
my $rule_file = $lang->rule_file || 'depend2';
# Get information on $LANG.
my $pfx = $lang->autodep;
my $fpfx = ($pfx eq '') ? 'CC' : $pfx;
my ($AMDEP, $FASTDEP) =
(option 'no-dependencies' || $lang->autodep eq 'no')
? ('FALSE', 'FALSE') : ('AMDEP', "am__fastdep$fpfx");
my %transform = ('EXT' => $ext,
'PFX' => $pfx,
'FPFX' => $fpfx,
'AMDEP' => $AMDEP,
'FASTDEP' => $FASTDEP,
'-c' => $lang->compile_flag || '',
'MORE-THAN-ONE'
=> (count_files_for_language ($lang->name) > 1));
# Generate the appropriate rules for this extension.
if (((! option 'no-dependencies') && $lang->autodep ne 'no')
|| defined $lang->compile)
{
# Some C compilers don't support -c -o. Use it only if really
# needed.
my $output_flag = $lang->output_flag || '';
$output_flag = '-o'
if (! $output_flag
&& $lang->name eq 'c'
&& option 'subdir-objects');
# Compute a possible derived extension.
# This is not used by depend2.am.
my $der_ext = (&{$lang->output_extensions} ($ext))[0];
# When we output an inference rule like `.c.o:' we
# have two cases to consider: either subdir-objects
# is used, or it is not.
#
# In the latter case the rule is used to build objects
# in the current directory, and dependencies always
# go into `./$(DEPDIR)/'. We can hard-code this value.
#
# In the former case the rule can be used to build
# objects in sub-directories too. Dependencies should
# go into the appropriate sub-directories, e.g.,
# `sub/$(DEPDIR)/'. The value of this directory
# need the be computed on-the-fly.
#
# DEPBASE holds the name of this directory, plus the
# basename part of the object file (extensions Po, TPo,
# Plo, TPlo will be added later as appropriate). It is
# either hardcoded, or a shell variable (`$depbase') that
# will be computed by the rule.
my $depbase =
option ('subdir-objects') ? '$$depbase' : '$(DEPDIR)/$*';
$output_rules .=
file_contents ($rule_file,
new Automake::Location,
%transform,
GENERIC => 1,
'DERIVED-EXT' => $der_ext,
DEPBASE => $depbase,
BASE => '$*',
SOURCE => '$<',
OBJ => '$@',
OBJOBJ => '$@',
LTOBJ => '$@',
COMPILE => '$(' . $lang->compiler . ')',
LTCOMPILE => '$(LT' . $lang->compiler . ')',
-o => $output_flag,
SUBDIROBJ => !! option 'subdir-objects');
}
# Now include code for each specially handled object with this
# language.
my %seen_files = ();
foreach my $file (@{$lang_specific_files{$lang->name}})
{
my ($derived, $source, $obj, $myext, %file_transform) = @$file;
# We might see a given object twice, for instance if it is
# used under different conditions.
next if defined $seen_files{$obj};
$seen_files{$obj} = 1;
prog_error ("found " . $lang->name .
" in handle_languages, but compiler not defined")
unless defined $lang->compile;
my $obj_compile = $lang->compile;
# Rewrite each occurrence of `AM_$flag' in the compile
# rule into `${derived}_$flag' if it exists.
for my $flag (@{$lang->flags})
{
my $val = "${derived}_$flag";
$obj_compile =~ s/\(AM_$flag\)/\($val\)/
if set_seen ($val);
}
my $libtool_tag = '';
if ($lang->libtool_tag && exists $libtool_tags{$lang->libtool_tag})
{
$libtool_tag = '--tag=' . $lang->libtool_tag . ' '
}
my $obj_ltcompile =
"\$(LIBTOOL) $libtool_tag--mode=compile $obj_compile";
# We _need_ `-o' for per object rules.
my $output_flag = $lang->output_flag || '-o';
my $depbase = dirname ($obj);
$depbase = ''
if $depbase eq '.';
$depbase .= '/'
unless $depbase eq '';
$depbase .= '$(DEPDIR)/' . basename ($obj);
# Support for deansified files in subdirectories is ugly
# enough to deserve an explanation.
#
# A Note about normal ansi2knr processing first. On
#
# AUTOMAKE_OPTIONS = ansi2knr
# bin_PROGRAMS = foo
# foo_SOURCES = foo.c
#
# we generate rules similar to:
#
# foo: foo$U.o; link ...
# foo$U.o: foo$U.c; compile ...
# foo_.c: foo.c; ansi2knr ...
#
# this is fairly compact, and will call ansi2knr depending
# on the value of $U (`' or `_').
#
# It's harder with subdir sources. On
#
# AUTOMAKE_OPTIONS = ansi2knr
# bin_PROGRAMS = foo
# foo_SOURCES = sub/foo.c
#
# we have to create foo_.c in the current directory.
# (Unless the user asks 'subdir-objects'.) This is important
# in case the same file (`foo.c') is compiled from other
# directories with different cpp options: foo_.c would
# be preprocessed for only one set of options if it were
# put in the subdirectory.
#
# Because foo$U.o must be built from either foo_.c or