# Perl reimplementation by Tom Tromey <tromey@redhat.com>, and
# Alexandre Duret-Lutz <adl@gnu.org>.
-package Language;
+package Automake;
+
+use strict;
BEGIN
{
$ENV{'SHELL'} = '@SHELL@' if exists $ENV{'DJDIR'};
}
-use Class::Struct ();
-Class::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' => '@',
-
- # '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 compiler variable (CC).
- 'ccer' => "\$",
-
- # 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' => "\$",
-
- # If TRUE, nodist_ sources will be compiled using specific rules
- # (i.e. not inference rules). The default is FALSE.
- 'nodist_specific' => "\$");
-
-
-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;
BEGIN
{
use Automake::Rule;
use Automake::RuleDef;
use Automake::Wrap 'makefile_wrap';
+use Automake::Language;
use File::Basename;
use File::Spec;
use Carp;
+## ----------------------- ##
+## Subroutine prototypes. ##
+## ----------------------- ##
+
+#! Prototypes here will automatically be generated by the build system.
+
+
## ----------- ##
## Constants. ##
## ----------- ##
my %ac_config_files_condition = ();
# Directory to search for configure-required files. This
-# will be computed by &locate_aux_dir and can be set using
+# 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 = '';
# TRUE if we've seen AM_PROG_AR
my $seen_ar = 0;
-# TRUE if we've seen AM_PROG_CC_C_O
-my $seen_cc_c_o = 0;
-
# Location of AC_REQUIRE_AUX_FILE calls, indexed by their argument.
my %required_aux_file = ();
# 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 ($$)
+sub var_SUFFIXES_trigger
{
my ($type, $value) = @_;
accept_extensions (split (' ', $value));
################################################################
-## --------------------------------- ##
-## Forward subroutine declarations. ##
-## --------------------------------- ##
-sub register_language (%);
-sub file_contents_internal ($$$%);
-sub define_files_variable ($\@$$);
-
-# &initialize_per_input ()
-# ------------------------
+# initialize_per_input ()
+# -----------------------
# (Re)-Initialize per-Makefile.am variables.
sub initialize_per_input ()
{
# Initialize our list of languages that are internally supported.
+my @cpplike_flags =
+ qw{
+ $(DEFS)
+ $(DEFAULT_INCLUDES)
+ $(INCLUDES)
+ $(AM_CPPFLAGS)
+ $(CPPFLAGS)
+ };
+
# C.
register_language ('name' => 'c',
'Name' => 'C',
'flags' => ['CFLAGS', 'CPPFLAGS'],
'ccer' => 'CC',
'compiler' => 'COMPILE',
- 'compile' => '$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)',
+ 'compile' => "\$(CC) @cpplike_flags \$(AM_CFLAGS) \$(CFLAGS)",
'lder' => 'CCLD',
'ld' => '$(CC)',
'linker' => 'LINK',
'link' => '$(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
'compile_flag' => '-c',
+ 'output_flag' => '-o',
'libtool_tag' => 'CC',
'extensions' => ['.c']);
'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)',
+ 'compile' => "\$(CXX) @cpplike_flags \$(AM_CXXFLAGS) \$(CXXFLAGS)",
'ccer' => 'CXX',
'compiler' => 'CXXCOMPILE',
'compile_flag' => '-c',
'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)',
+ 'compile' => "\$(OBJC) @cpplike_flags \$(AM_OBJCFLAGS) \$(OBJCFLAGS)",
'ccer' => 'OBJC',
'compiler' => 'OBJCCOMPILE',
'compile_flag' => '-c',
'link' => '$(OBJCXXLD) $(AM_OBJCXXFLAGS) $(OBJCXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
'autodep' => 'OBJCXX',
'flags' => ['OBJCXXFLAGS', 'CPPFLAGS'],
- 'compile' => '$(OBJCXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCXXFLAGS) $(OBJCXXFLAGS)',
+ 'compile' => "\$(OBJCXX) @cpplike_flags \$(AM_OBJCXXFLAGS) \$(OBJCXXFLAGS)",
'ccer' => 'OBJCXX',
'compiler' => 'OBJCXXCOMPILE',
'compile_flag' => '-c',
'link' => '$(UPCLD) $(AM_UPCFLAGS) $(UPCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
'autodep' => 'UPC',
'flags' => ['UPCFLAGS', 'CPPFLAGS'],
- 'compile' => '$(UPC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_UPCFLAGS) $(UPCFLAGS)',
+ 'compile' => "\$(UPC) @cpplike_flags \$(AM_UPCFLAGS) \$(UPCFLAGS)",
'ccer' => 'UPC',
'compiler' => 'UPCCOMPILE',
'compile_flag' => '-c',
'autodep' => 'CCAS',
'flags' => ['CCASFLAGS', 'CPPFLAGS'],
- 'compile' => '$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS)',
+ 'compile' => "\$(CCAS) @cpplike_flags \$(AM_CCASFLAGS) \$(CCASFLAGS)",
'ccer' => 'CPPAS',
'compiler' => 'CPPASCOMPILE',
'compile_flag' => '-c',
'flags' => ['FCFLAGS', 'CPPFLAGS'],
'ccer' => 'PPFC',
'compiler' => 'PPFCCOMPILE',
- 'compile' => '$(FC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS)',
+ 'compile' => "\$(FC) @cpplike_flags \$(AM_FCFLAGS) \$(FCFLAGS)",
'compile_flag' => '-c',
'output_flag' => '-o',
'libtool_tag' => 'FC',
'flags' => ['FFLAGS', 'CPPFLAGS'],
'ccer' => 'PPF77',
'compiler' => 'PPF77COMPILE',
- 'compile' => '$(F77) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)',
+ 'compile' => "\$(F77) @cpplike_flags \$(AM_FFLAGS) \$(FFLAGS)",
'compile_flag' => '-c',
'output_flag' => '-o',
'libtool_tag' => 'F77',
# err_am ($MESSAGE, [%OPTIONS])
# -----------------------------
# Uncategorized errors about the current Makefile.am.
-sub err_am ($;%)
+sub err_am
{
msg_am ('error', @_);
}
# err_ac ($MESSAGE, [%OPTIONS])
# -----------------------------
# Uncategorized errors about configure.ac.
-sub err_ac ($;%)
+sub err_ac
{
msg_ac ('error', @_);
}
# msg_am ($CHANNEL, $MESSAGE, [%OPTIONS])
# ---------------------------------------
# Messages about about the current Makefile.am.
-sub msg_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 ($$;%)
+sub msg_ac
{
my ($channel, $msg, %opts) = @_;
msg $channel, $configure_ac, $msg, %opts;
# 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 ($)
+sub subst
{
my ($text) = @_;
return '@' . $text . '@';
# $BACKPATH
-# &backname ($RELDIR)
-# --------------------
+# backname ($RELDIR)
+# -------------------
# If I "cd $RELDIR", then to come back, I should "cd $BACKPATH".
# For instance 'src/foo' => '../..'.
# Works with non strictly increasing paths, i.e., 'src/../lib' => '..'.
-sub backname ($)
+sub backname
{
my ($file) = @_;
my @res;
# verbose_var (NAME)
# ------------------
# The public variable stem used to implement silent rules.
-sub verbose_var ($)
+sub verbose_var
{
my ($name) = @_;
return 'AM_V_' . $name;
# verbose_private_var (NAME)
# --------------------------
# The naming policy for the private variables for silent rules.
-sub verbose_private_var ($)
+sub verbose_private_var
{
my ($name) = @_;
return 'am__v_' . $name;
# For silent rules, setup VAR and dispatcher, to expand to
# VAL-IF-SILENT if silent, to VAL-IF-VERBOSE (defaulting to
# empty) if not.
-sub define_verbose_var ($$;$)
+sub define_verbose_var
{
my ($name, $silent_val, $verbose_val) = @_;
$verbose_val = '' unless defined $verbose_val;
if (! vardef ($verbose_var, TRUE));
}
-# Above should not be needed in the general automake code.
-
# verbose_flag (NAME)
# -------------------
-# Contents of %VERBOSE%: variable to expand before rule command.
-sub verbose_flag ($)
+# Contents of '%VERBOSE%' variable to expand before rule command.
+sub verbose_flag
{
my ($name) = @_;
return '$(' . verbose_var ($name) . ')';
}
-sub verbose_nodep_flag ($)
+sub verbose_nodep_flag
{
my ($name) = @_;
return '$(' . verbose_var ($name) . subst ('am__nodep') . ')';
# define_verbose_tagvar (NAME)
# ----------------------------
# Engage the needed silent rules machinery for tag NAME.
-sub define_verbose_tagvar ($)
+sub define_verbose_tagvar
{
my ($name) = @_;
define_verbose_var ($name, '@echo " '. $name . ' ' x (8 - length ($name)) . '" $@;');
}
-# define_verbose_texinfo
-# ----------------------
# Engage the needed silent rules machinery for assorted texinfo commands.
sub define_verbose_texinfo ()
{
define_verbose_var('texidevnull', '> /dev/null');
}
-# define_verbose_libtool
-# ----------------------
# Engage the needed silent rules machinery for 'libtool --silent'.
sub define_verbose_libtool ()
{
################################################################
-# Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.
-sub handle_options
+# Handle AUTOMAKE_OPTIONS variable. Return 0 on error, 1 otherwise.
+sub handle_options ()
{
my $var = var ('AUTOMAKE_OPTIONS');
if ($var)
my @options = map { { option => $_->[1], where => $_->[0] } }
$var->value_as_list_recursive (cond_filter => TRUE,
location => 1);
- return 1 if process_option_list (@options);
+ return 0 unless process_option_list (@options);
}
if ($strictness == GNITS)
set_option ('check-news', INTERNAL);
}
- return 0;
+ return 1;
}
# shadow_unconditionally ($varname, $where)
# If the VAR wasn't defined conditionally, return $(VAR).
# Otherwise we create an am__VAR_DIST variable which contains
# all possible values, and return $(am__VAR_DIST).
-sub shadow_unconditionally ($$)
+sub shadow_unconditionally
{
my ($varname, $where) = @_;
my $var = var $varname;
# ----------------------------
# Make sure each variable VAR in @LIST does not exist, suggest using AM_VAR
# otherwise.
-sub check_user_variables (@)
+sub check_user_variables
{
my @dont_override = @_;
foreach my $flag (@dont_override)
}
# Call finish function for each language that was used.
-sub handle_languages
+sub handle_languages ()
{
if (! option 'no-dependencies')
{
if (keys %extension_seen && keys %dep_files)
{
# Set location of depcomp.
- &define_variable ('depcomp',
- "\$(SHELL) $am_config_aux_dir/depcomp",
- INTERNAL);
- &define_variable ('am__depfiles_maybe', 'depfiles', INTERNAL);
+ 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');
# 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");
+ $output_rules .= file_contents ('depend',
+ new Automake::Location,
+ DEPDIRS => "@depdirs");
}
}
else
{
- &define_variable ('depcomp', '', INTERNAL);
- &define_variable ('am__depfiles_maybe', '', INTERNAL);
+ define_variable ('depcomp', '', INTERNAL);
+ define_variable ('am__depfiles_maybe', '', INTERNAL);
}
my %done;
'FASTDEP' => $FASTDEP,
'-c' => $lang->compile_flag || '',
# These are not used, but they need to be defined
- # so &transform do not complain.
+ # so transform() do not complain.
SUBDIROBJ => 0,
'DERIVED-EXT' => 'BUG',
DIST_SOURCE => 1,
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];
+ 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
COMPILE => '$(' . $lang->compiler . ')',
LTCOMPILE => '$(LT' . $lang->compiler . ')',
- -o => $output_flag,
+ -o => $lang->output_flag,
SUBDIROBJ => !! option 'subdir-objects');
}
$needs_c = 1 if @languages_seen > 1;
if ($need_link || $needs_c)
{
- &define_compiler_variable ($languages{'c'})
+ define_compiler_variable ($languages{'c'})
unless defined $done{$languages{'c'}};
define_linker_variable ($languages{'c'});
}
# when producing explicit rules
# Result is a list of the names of objects
# %linkers_used will be updated with any linkers needed
-sub handle_single_transform ($$$$$%)
+sub handle_single_transform
{
my ($var, $topparent, $derived, $obj, $_file, %transform) = @_;
my @files = ($_file);
# language function.
my $aggregate = 'AM';
- $extension = &derive_suffix ($extension, $obj);
+ $extension = derive_suffix ($extension, $obj);
my $lang;
if ($extension_map{$extension} &&
($lang = $languages{$extension_map{$extension}}))
{
# Found the language, so see what it says.
- &saw_extension ($extension);
+ saw_extension ($extension);
# Do we have per-executable flags for this executable?
my $have_per_exec_flags = 0;
# If rewrite said it was ok, put the object into a
# subdir.
- if ($r == LANG_SUBDIR && $directory ne '')
+ if ($directory ne '')
{
- $object = $directory . '/' . $object;
+ if ($r == LANG_SUBDIR)
+ {
+ $object = $directory . '/' . $object;
+ }
+ else
+ {
+ # Since the next major version of automake (2.0) will
+ # make the behaviour so far only activated with the
+ # 'subdir-object' option mandatory, it's better if we
+ # start warning users not using that option.
+ # As suggested by Peter Johansson, we strive to avoid
+ # the warning when it would be irrelevant, i.e., if
+ # all source files sit in "current" directory.
+ msg_var 'unsupported', $var,
+ "source file '$full' is in a subdirectory,"
+ . "\nbut option 'subdir-objects' is disabled";
+ msg 'unsupported', INTERNAL, <<'EOF', uniq_scope => US_GLOBAL;
+possible forward-incompatibility.
+At least a source file is in a subdirectory, but the 'subdir-objects'
+automake option hasn't been enabled. For now, the corresponding output
+object file(s) will be placed in the top-level directory. However,
+this behaviour will change in future Automake versions: they will
+unconditionally cause object files to be placed in the same subdirectory
+of the corresponding sources.
+You are advised to start using 'subdir-objects' option throughout your
+project, to avoid future incompatibilities.
+EOF
+ }
}
# If the object file has been renamed (because per-target
unshift (@files, $object);
# Distribute derived sources unless the source they are
# derived from is not.
- &push_dist_common ($object)
+ push_dist_common ($object)
unless ($topparent =~ /^(?:nobase_)?nodist_/);
next;
}
unless option 'no-dependencies';
}
- &pretty_print_rule ($object . ':', "\t", @dep_list)
+ pretty_print_rule ($object . ':', "\t", @dep_list)
if scalar @dep_list > 0;
}
#
# Result is a pair ($LINKER, $OBJVAR):
# $LINKER is a boolean, true if a linker is needed to deal with the objects
-sub define_objects_from_sources ($$$$$$$%)
+sub define_objects_from_sources
{
my ($var, $objvar, $nodefine, $one_file,
$obj, $topparent, $where, %transform) = @_;
# extra arguments to pass to file_contents when producing rules
# Return the name of the linker variable that must be used.
# Empty return means just use 'LINK'.
-sub handle_source_transform ($$$$%)
+sub handle_source_transform
{
# one_file is canonical name. unxformed is given name. obj is
# object extension.
$needlinker |=
define_objects_from_sources ($varname,
$xpfx . $one_file . '_OBJECTS',
- $prefix =~ /EXTRA_/,
+ !!($prefix =~ /EXTRA_/),
$one_file, $obj, $varname, $where,
DIST_SOURCE => ($prefix !~ /^nodist_/),
%transform);
}
if ($needlinker)
{
- $linker ||= &resolve_linker (%linkers_used);
+ $linker ||= resolve_linker (%linkers_used);
}
my @keys = sort keys %used_pfx;
$default_source = '$(srcdir)/' . $default_source;
}
- &define_variable ($one_file . "_SOURCES", $default_source, $where);
+ define_variable ($one_file . "_SOURCES", $default_source, $where);
push (@sources, $default_source);
push (@dist_sources, $default_source);
$one_file . '_SOURCES',
$one_file, $obj,
$default_source, %transform);
- $linker ||= &resolve_linker (%linkers_used);
+ $linker ||= resolve_linker (%linkers_used);
define_pretty_variable ($one_file . '_OBJECTS', TRUE, $where, @result);
}
else
# -------------------------------
# Definitions common to LIBOBJS and ALLOCA.
# VAR should be one of LIBOBJS, LTLIBOBJS, ALLOCA, or LTALLOCA.
-sub handle_LIBOBJS_or_ALLOCA ($)
+sub handle_LIBOBJS_or_ALLOCA
{
my ($var) = @_;
return $dir;
}
-sub handle_LIBOBJS ($$$)
+sub handle_LIBOBJS
{
my ($var, $cond, $lt) = @_;
my $myobjext = $lt ? 'lo' : 'o';
{
if ($iter =~ /\.[cly]$/)
{
- &saw_extension ($&);
- &saw_extension ('.c');
+ saw_extension ($&);
+ saw_extension ('.c');
}
if ($iter =~ /\.h$/)
}
}
-sub handle_ALLOCA ($$$)
+sub handle_ALLOCA
{
my ($var, $cond, $lt) = @_;
my $myobjext = $lt ? 'lo' : 'o';
$var->requires_variables ("\@${lt}ALLOCA\@ used", $lt . 'ALLOCA');
$dep_files{$dir . '$(DEPDIR)/alloca.P' . $myobjext} = 1;
require_libsource_with_macro ($cond, $var, FOREIGN, 'alloca.c');
- &saw_extension ('.c');
+ saw_extension ('.c');
}
-# Canonicalize the input parameter
+# Canonicalize the input parameter.
sub canonicalize
{
my ($string) = @_;
{
my ($name, @suffixes) = @_;
- my $xname = &canonicalize ($name);
+ my $xname = canonicalize ($name);
if ($xname ne $name)
{
foreach my $xt (@suffixes)
return $xname;
}
-
-# handle_compile ()
-# -----------------
# Set up the compile suite.
sub handle_compile ()
{
}
my ($coms, $vars, $rules) =
- &file_contents_internal (1, "$libdir/am/compile.am",
- new Automake::Location,
- ('DEFAULT_INCLUDES' => $default_includes,
- 'MOSTLYRMS' => join ("\n", @mostly_rms),
- 'DISTRMS' => join ("\n", @dist_rms)));
+ file_contents_internal (1, "$libdir/am/compile.am",
+ new Automake::Location,
+ 'DEFAULT_INCLUDES' => $default_includes,
+ 'MOSTLYRMS' => join ("\n", @mostly_rms),
+ 'DISTRMS' => join ("\n", @dist_rms));
$output_vars .= $vars;
$output_rules .= "$coms$rules";
}
-# handle_libtool ()
-# -----------------
# Handle libtool rules.
-sub handle_libtool
+sub handle_libtool ()
{
return unless var ('LIBTOOL');
check_user_variables 'LIBTOOLFLAGS';
# Output the libtool compilation rules.
- $output_rules .= &file_contents ('libtool',
- new Automake::Location,
+ $output_rules .= file_contents ('libtool',
+ new Automake::Location,
LTRMS => join ("\n", @libtool_rms));
}
-# handle_programs ()
-# ------------------
-# Handle C programs.
-sub handle_programs
+
+sub handle_programs ()
{
- my @proglist = &am_install_var ('progs', 'PROGRAMS',
- 'bin', 'sbin', 'libexec', 'pkglibexec',
- 'noinst', 'check');
+ my @proglist = am_install_var ('progs', 'PROGRAMS',
+ 'bin', 'sbin', 'libexec', 'pkglibexec',
+ 'noinst', 'check');
return if ! @proglist;
$must_handle_compiled_objects = 1;
my $seen_global_libobjs =
- var ('LDADD') && &handle_lib_objects ('', 'LDADD');
+ var ('LDADD') && handle_lib_objects ('', 'LDADD');
foreach my $pair (@proglist)
{
$known_programs{$one_file} = $where;
# Canonicalize names and check for misspellings.
- my $xname = &check_canonical_spelling ($one_file, '_LDADD', '_LDFLAGS',
- '_SOURCES', '_OBJECTS',
- '_DEPENDENCIES');
+ my $xname = check_canonical_spelling ($one_file, '_LDADD', '_LDFLAGS',
+ '_SOURCES', '_OBJECTS',
+ '_DEPENDENCIES');
$where->push_context ("while processing program '$one_file'");
$where->set (INTERNAL->get);
- my $linker = &handle_source_transform ($xname, $one_file, $obj, $where,
- NONLIBTOOL => 1, LIBTOOL => 0);
+ my $linker = handle_source_transform ($xname, $one_file, $obj, $where,
+ NONLIBTOOL => 1, LIBTOOL => 0);
if (var ($xname . "_LDADD"))
{
- $seen_libobjs = &handle_lib_objects ($xname, $xname . '_LDADD');
+ $seen_libobjs = handle_lib_objects ($xname, $xname . '_LDADD');
}
else
{
# User didn't define prog_LDADD override. So do it.
- &define_variable ($xname . '_LDADD', '$(LDADD)', $where);
+ define_variable ($xname . '_LDADD', '$(LDADD)', $where);
# This does a bit too much work. But we need it to
# generate _DEPENDENCIES when appropriate.
if (var ('LDADD'))
{
- $seen_libobjs = &handle_lib_objects ($xname, 'LDADD');
+ $seen_libobjs = handle_lib_objects ($xname, 'LDADD');
}
}
set_seen ($xname . '_LDFLAGS');
# Determine program to use for link.
- my($xlink, $vlink) = &define_per_target_linker_variable ($linker, $xname);
+ my($xlink, $vlink) = define_per_target_linker_variable ($linker, $xname);
$vlink = verbose_flag ($vlink || 'GEN');
# If the resulting program lies in a subdirectory,
$libtool_clean_directories{dirname ($one_file)} = 1;
- $output_rules .= &file_contents ('program',
- $where,
- PROGRAM => $one_file,
- XPROGRAM => $xname,
- XLINK => $xlink,
- VERBOSE => $vlink,
- DIRSTAMP => $dirstamp,
- EXEEXT => '$(EXEEXT)');
+ $output_rules .= file_contents ('program',
+ $where,
+ PROGRAM => $one_file,
+ XPROGRAM => $xname,
+ XLINK => $xlink,
+ VERBOSE => $vlink,
+ DIRSTAMP => $dirstamp,
+ EXEEXT => '$(EXEEXT)');
if ($seen_libobjs || $seen_global_libobjs)
{
if (var ($xname . '_LDADD'))
{
- &check_libobjs_sources ($xname, $xname . '_LDADD');
+ check_libobjs_sources ($xname, $xname . '_LDADD');
}
elsif (var ('LDADD'))
{
- &check_libobjs_sources ($xname, 'LDADD');
+ check_libobjs_sources ($xname, 'LDADD');
}
}
}
}
-# handle_libraries ()
-# -------------------
-# Handle libraries.
-sub handle_libraries
+sub handle_libraries ()
{
- my @liblist = &am_install_var ('libs', 'LIBRARIES',
- 'lib', 'pkglib', 'noinst', 'check');
+ my @liblist = am_install_var ('libs', 'LIBRARIES',
+ 'lib', 'pkglib', 'noinst', 'check');
return if ! @liblist;
$must_handle_compiled_objects = 1;
$var->requires_variables ('library used', 'RANLIB');
}
- &define_variable ('AR', 'ar', INTERNAL);
- &define_variable ('ARFLAGS', 'cru', INTERNAL);
- &define_verbose_tagvar ('AR');
+ define_variable ('AR', 'ar', INTERNAL);
+ define_variable ('ARFLAGS', 'cru', INTERNAL);
+ define_verbose_tagvar ('AR');
foreach my $pair (@liblist)
{
my $obj = '.$(OBJEXT)';
# Canonicalize names and check for misspellings.
- my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES',
- '_OBJECTS', '_DEPENDENCIES',
- '_AR');
+ my $xlib = check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES',
+ '_OBJECTS', '_DEPENDENCIES',
+ '_AR');
if (! var ($xlib . '_AR'))
{
- &define_variable ($xlib . '_AR', '$(AR) $(ARFLAGS)', $where);
+ define_variable ($xlib . '_AR', '$(AR) $(ARFLAGS)', $where);
}
# Generate support for conditional object inclusion in
# libraries.
if (var ($xlib . '_LIBADD'))
{
- if (&handle_lib_objects ($xlib, $xlib . '_LIBADD'))
+ if (handle_lib_objects ($xlib, $xlib . '_LIBADD'))
{
$seen_libobjs = 1;
}
}
else
{
- &define_variable ($xlib . "_LIBADD", '', $where);
+ define_variable ($xlib . "_LIBADD", '', $where);
}
reject_var ($xlib . '_LDADD',
set_seen ($xlib . '_DEPENDENCIES');
set_seen ('EXTRA_' . $xlib . '_DEPENDENCIES');
- &handle_source_transform ($xlib, $onelib, $obj, $where,
- NONLIBTOOL => 1, LIBTOOL => 0);
+ handle_source_transform ($xlib, $onelib, $obj, $where,
+ NONLIBTOOL => 1, LIBTOOL => 0);
# If the resulting library lies in a subdirectory,
# make sure this directory will exist.
my $verbose = verbose_flag ('AR');
my $silent = silent_flag ();
- $output_rules .= &file_contents ('library',
- $where,
- VERBOSE => $verbose,
- SILENT => $silent,
- LIBRARY => $onelib,
- XLIBRARY => $xlib,
- DIRSTAMP => $dirstamp);
+ $output_rules .= file_contents ('library',
+ $where,
+ VERBOSE => $verbose,
+ SILENT => $silent,
+ LIBRARY => $onelib,
+ XLIBRARY => $xlib,
+ DIRSTAMP => $dirstamp);
if ($seen_libobjs)
{
if (var ($xlib . '_LIBADD'))
{
- &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
+ check_libobjs_sources ($xlib, $xlib . '_LIBADD');
}
}
}
-# handle_ltlibraries ()
-# ---------------------
-# Handle shared libraries.
-sub handle_ltlibraries
+sub handle_ltlibraries ()
{
- my @liblist = &am_install_var ('ltlib', 'LTLIBRARIES',
- 'noinst', 'lib', 'pkglib', 'check');
+ my @liblist = am_install_var ('ltlib', 'LTLIBRARIES',
+ 'noinst', 'lib', 'pkglib', 'check');
return if ! @liblist;
$must_handle_compiled_objects = 1;
my $obj = '.lo';
# Canonicalize names and check for misspellings.
- my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS',
- '_SOURCES', '_OBJECTS',
- '_DEPENDENCIES');
+ my $xlib = check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS',
+ '_SOURCES', '_OBJECTS',
+ '_DEPENDENCIES');
# Check that the library fits the standard naming convention.
my $libname_rx = '^lib.*\.la';
# libraries.
if (var ($xlib . '_LIBADD'))
{
- if (&handle_lib_objects ($xlib, $xlib . '_LIBADD'))
+ if (handle_lib_objects ($xlib, $xlib . '_LIBADD'))
{
$seen_libobjs = 1;
}
}
else
{
- &define_variable ($xlib . "_LIBADD", '', $where);
+ define_variable ($xlib . "_LIBADD", '', $where);
}
reject_var ("${xlib}_LDADD",
"use '${xlib}_LIBADD', not '${xlib}_LDADD'");
- my $linker = &handle_source_transform ($xlib, $onelib, $obj, $where,
- NONLIBTOOL => 0, LIBTOOL => 1);
+ my $linker = handle_source_transform ($xlib, $onelib, $obj, $where,
+ NONLIBTOOL => 0, LIBTOOL => 1);
# Determine program to use for link.
- my($xlink, $vlink) = &define_per_target_linker_variable ($linker, $xlib);
+ my($xlink, $vlink) = define_per_target_linker_variable ($linker, $xlib);
$vlink = verbose_flag ($vlink || 'GEN');
my $rpathvar = "am_${xlib}_rpath";
my $dirname = dirname $onelib;
$libtool_clean_directories{$dirname} = 1;
- $output_rules .= &file_contents ('ltlibrary',
- $where,
- LTLIBRARY => $onelib,
- XLTLIBRARY => $xlib,
- RPATH => $rpath,
- XLINK => $xlink,
- VERBOSE => $vlink,
- DIRSTAMP => $dirstamp);
+ $output_rules .= file_contents ('ltlibrary',
+ $where,
+ LTLIBRARY => $onelib,
+ XLTLIBRARY => $xlib,
+ RPATH => $rpath,
+ XLINK => $xlink,
+ VERBOSE => $vlink,
+ DIRSTAMP => $dirstamp);
if ($seen_libobjs)
{
if (var ($xlib . '_LIBADD'))
{
- &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
+ check_libobjs_sources ($xlib, $xlib . '_LIBADD');
}
}
}
-# Handle scripts.
-sub handle_scripts
+sub handle_scripts ()
{
# NOTE we no longer automatically clean SCRIPTS, because it is
# useful to sometimes distribute scripts verbatim. This happens
# e.g. in Automake itself.
- &am_install_var ('-candist', 'scripts', 'SCRIPTS',
- 'bin', 'sbin', 'libexec', 'pkglibexec', 'pkgdata',
- 'noinst', 'check');
+ am_install_var ('-candist', 'scripts', 'SCRIPTS',
+ 'bin', 'sbin', 'libexec', 'pkglibexec', 'pkgdata',
+ 'noinst', 'check');
}
-
-
## ------------------------ ##
## Handling Texinfo files. ##
## ------------------------ ##
# ($OUTFILE, $VFILE)
-# &scan_texinfo_file ($FILENAME)
-# ------------------------------
+# scan_texinfo_file ($FILENAME)
+# -----------------------------
# $OUTFILE - name of the info file produced by $FILENAME.
# $VFILE - name of the version.texi file used (undef if none).
-sub scan_texinfo_file ($)
+sub scan_texinfo_file
{
my ($filename) = @_;
# DEST - the destination Info file
# INSRC - whether DEST should be built in the source tree
# DEPENDENCIES - known dependencies
-sub output_texinfo_build_rules ($$$@)
+sub output_texinfo_build_rules
{
my ($source, $dest, $insrc, @deps) = @_;
# ($MOSTLYCLEAN, $TEXICLEAN, $MAINTCLEAN)
# handle_texinfo_helper ($info_texinfos)
# --------------------------------------
-# Handle all Texinfo source; helper for handle_texinfo.
-sub handle_texinfo_helper ($)
+# Handle all Texinfo source; helper for 'handle_texinfo'.
+sub handle_texinfo_helper
{
my ($info_texinfos) = @_;
my (@infobase, @info_deps_list, @texi_deps);
# have a single variable ($INSRC) that controls whether
# the current .info file must be built in the source tree
# or in the build tree. Actually this variable is switched
- # off for .info files that appear to be cleaned; this is
- # for backward compatibility with package such as Texinfo,
- # which do things like
- # info_TEXINFOS = texinfo.txi info-stnd.texi info.texi
- # DISTCLEANFILES = texinfo texinfo-* info*.info*
- # # Do not create info files for distribution.
- # dist-info:
- # in order not to distribute .info files.
- my $insrc = ($out_file =~ $user_cleaned_files) ? 0 : 1;
-
+ # off in two cases:
+ # (1) For '.info' files that appear to be cleaned; this is for
+ # backward compatibility with package such as Texinfo,
+ # which do things like
+ # info_TEXINFOS = texinfo.txi info-stnd.texi info.texi
+ # DISTCLEANFILES = texinfo texinfo-* info*.info*
+ # # Do not create info files for distribution.
+ # dist-info:
+ # in order not to distribute .info files.
+ # (2) When the undocumented option 'info-in-builddir' is given.
+ # This is done to allow the developers of GCC, GDB, GNU
+ # binutils and the GNU bfd library to force the '.info' files
+ # to be generated in the builddir rather than the srcdir, as
+ # was once done when the (now removed) 'cygnus' option was
+ # given. See automake bug#11034 for more discussion.
+ my $insrc = 1;
my $soutdir = '$(srcdir)/' . $outdir;
+
+ if (option 'info-in-builddir')
+ {
+ $insrc = 0;
+ }
+ elsif ($out_file =~ $user_cleaned_files)
+ {
+ $insrc = 0;
+ msg 'obsolete', "$am_file.am", <<EOF;
+Oops!
+ It appears this file (or files included by it) are triggering
+ an undocumented, soon-to-be-removed automake hack.
+ Future automake versions will no longer place in the builddir
+ (rather than in the srcdir) the generated '.info' files that
+ appear to be cleaned, by e.g. being listed in CLEANFILES or
+ DISTCLEANFILES.
+ If you want your '.info' files to be placed in the builddir
+ rather than in the srcdir, you have to use the shiny new
+ 'info-in-builddir' automake option.
+EOF
+ }
+
$outdir = $soutdir if $insrc;
# If user specified file_TEXINFOS, then use that as explicit
# dependency list.
@texi_deps = ();
- push (@texi_deps, "$soutdir$vtexi") if $vtexi;
+ push (@texi_deps, "${soutdir}${vtexi}") if $vtexi;
my $canonical = canonicalize ($infobase);
if (var ($canonical . "_TEXINFOS"))
}
-# handle_texinfo ()
-# -----------------
-# Handle all Texinfo source.
sub handle_texinfo ()
{
reject_var 'TEXINFOS', "'TEXINFOS' is an anachronism; use 'info_TEXINFOS'";
}
-# Handle any man pages.
-sub handle_man_pages
+sub handle_man_pages ()
{
reject_var 'MANS', "'MANS' is an anachronism; use 'man_MANS'";
$trans_sect_vars{$varname} = 1;
}
- &push_dist_common ($varname)
+ push_dist_common ($varname)
if $pfx eq 'dist_';
}
}
{
$trans_vars{$varname} = 1;
}
- &push_dist_common ($varname)
+ push_dist_common ($varname)
if $pfx eq 'dist_';
}
}
@unsorted_deps = (keys %notrans_vars, keys %trans_vars,
keys %notrans_this_sect, keys %trans_this_sect);
my @deps = sort @unsorted_deps;
- $output_rules .= &file_contents ('mans',
- new Automake::Location,
- SECTION => $section,
- DEPS => "@deps",
- NOTRANS_MANS => $notrans_mans,
- NOTRANS_SECT_LIST => "@notrans_sect_list",
- HAVE_NOTRANS => $have_notrans,
- NOTRANS_LIST => "@notrans_list",
- TRANS_MANS => $trans_mans,
- TRANS_SECT_LIST => "@trans_sect_list",
- HAVE_TRANS => $have_trans,
- TRANS_LIST => "@trans_list");
+ $output_rules .= file_contents ('mans',
+ new Automake::Location,
+ SECTION => $section,
+ DEPS => "@deps",
+ NOTRANS_MANS => $notrans_mans,
+ NOTRANS_SECT_LIST => "@notrans_sect_list",
+ HAVE_NOTRANS => $have_notrans,
+ NOTRANS_LIST => "@notrans_list",
+ TRANS_MANS => $trans_mans,
+ TRANS_SECT_LIST => "@trans_sect_list",
+ HAVE_TRANS => $have_trans,
+ TRANS_LIST => "@trans_list");
}
@unsorted_deps = (keys %notrans_vars, keys %trans_vars,
unless option 'no-installman';
}
-# Handle DATA variables.
-sub handle_data
+
+sub handle_data ()
{
- &am_install_var ('-noextra', '-candist', 'data', 'DATA',
- 'data', 'dataroot', 'doc', 'dvi', 'html', 'pdf',
- 'ps', 'sysconf', 'sharedstate', 'localstate',
- 'pkgdata', 'lisp', 'noinst', 'check');
+ am_install_var ('-noextra', '-candist', 'data', 'DATA',
+ 'data', 'dataroot', 'doc', 'dvi', 'html', 'pdf',
+ 'ps', 'sysconf', 'sharedstate', 'localstate',
+ 'pkgdata', 'lisp', 'noinst', 'check');
}
-# Handle TAGS.
-sub handle_tags
+
+sub handle_tags ()
{
my @config;
foreach my $spec (@config_headers)
if (rvar('am__tagged_files')->value_as_list_recursive
|| var ('ETAGS_ARGS') || var ('SUBDIRS'))
{
- $output_rules .= &file_contents ('tags', new Automake::Location);
+ $output_rules .= file_contents ('tags', new Automake::Location);
set_seen 'TAGS_DEPENDENCIES';
}
else
# Return false if rule $NAME does not exist. Otherwise,
# declare it as phony, complete its definition (in case it is
# conditional), and return its Automake::Rule instance.
-sub user_phony_rule ($)
+sub user_phony_rule
{
my ($name) = @_;
my $rule = rule $name;
}
-# handle_dist
-# -----------
# Handle 'dist' target.
sub handle_dist ()
{
if ($relative_dir eq '.'
&& $config_aux_dir_set_in_configure_ac)
{
- if (! &is_make_dir ($config_aux_dir))
+ if (! is_make_dir ($config_aux_dir))
{
$check_aux = 1;
}
# The file might be absent, but if it can be built it's ok.
|| rule $cfile)
{
- &push_dist_common ($cfile);
+ push_dist_common ($cfile);
}
# Don't use 'elsif' here because a file might meaningfully
# appear in both directories.
if ($check_aux && dir_has_case_matching_file ($config_aux_dir, $cfile))
{
- &push_dist_common ("$config_aux_dir/$cfile")
+ push_dist_common ("$config_aux_dir/$cfile")
}
}
# Files to distributed. Don't use ->value_as_list_recursive
# as it recursively expands '$(dist_pkgdata_DATA)' etc.
my @dist_common = split (' ', rvar ('DIST_COMMON')->variable_value);
- @dist_common = uniq @dist_common;
+ @dist_common = uniq (@dist_common);
variable_delete 'DIST_COMMON';
define_pretty_variable ('DIST_COMMON', TRUE, INTERNAL, @dist_common);
my $flm = option ('filename-length-max');
my $filename_filter = $flm ? '.' x $flm->[1] : '';
- $output_rules .= &file_contents ('distdir',
- new Automake::Location,
- %transform,
- FILENAME_FILTER => $filename_filter);
+ $output_rules .= file_contents ('distdir',
+ new Automake::Location,
+ %transform,
+ FILENAME_FILTER => $filename_filter);
}
# -------------------------------------------------------
# Ensure $NAME is a directory (in $RELATIVE_DIR), and that it uses a sane
# name. Use $WHERE as a location in the diagnostic, if any.
-sub check_directory ($$;$)
+sub check_directory
{
my ($dir, $where, $reldir) = @_;
$reldir = '.' unless defined $reldir;
# check_directories_in_var ($VARIABLE)
# ------------------------------------
# Recursively check all items in variables $VARIABLE as directories
-sub check_directories_in_var ($)
+sub check_directories_in_var
{
my ($var) = @_;
$var->traverse_recursively
skip_ac_subst => 1);
}
-# &handle_subdirs ()
-# ------------------
-# Handle subdirectories.
+
sub handle_subdirs ()
{
my $subdirs = var ('SUBDIRS');
check_directories_in_var $dsubdirs
if $dsubdirs;
- $output_rules .= &file_contents ('subdirs', new Automake::Location);
+ $output_rules .= file_contents ('subdirs', new Automake::Location);
rvar ('RECURSIVE_TARGETS')->rdef (TRUE)->{'pretty'} = VAR_SORTED; # Gross!
}
# ($REGEN, @DEPENDENCIES)
-# &scan_aclocal_m4
-# ----------------
+# scan_aclocal_m4
+# ---------------
# If aclocal.m4 creation is automated, return the list of its dependencies.
sub scan_aclocal_m4 ()
{
if (-f 'aclocal.m4')
{
- &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4', INTERNAL);
+ define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4', INTERNAL);
my $aclocal = new Automake::XFile "< aclocal.m4";
my $line = $aclocal->getline;
}
-# Helper function for substitute_ac_subst_variables.
-sub substitute_ac_subst_variables_worker($)
+# Helper function for 'substitute_ac_subst_variables'.
+sub substitute_ac_subst_variables_worker
{
my ($token) = @_;
return "\@$token\@" if var $token;
# -------------------------------------
# Replace any occurrence of ${FOO} in $TEXT by @FOO@ if FOO is an AC_SUBST
# variable.
-sub substitute_ac_subst_variables ($)
+sub substitute_ac_subst_variables
{
my ($text) = @_;
- $text =~ s/\${([^ \t=:+{}]+)}/&substitute_ac_subst_variables_worker ($1)/ge;
+ $text =~ s/\${([^ \t=:+{}]+)}/substitute_ac_subst_variables_worker ($1)/ge;
return $text;
}
# @DEPENDENCIES
-# &prepend_srcdir (@INPUTS)
-# -------------------------
+# prepend_srcdir (@INPUTS)
+# ------------------------
# Prepend $(srcdir) or $(top_srcdir) to all @INPUTS. The idea is that
# if an input file has a directory part the same as the current
# directory, then the directory part is simply replaced by $(srcdir).
# But if the directory part is different, then $(top_srcdir) is
# prepended.
-sub prepend_srcdir (@)
+sub prepend_srcdir
{
my (@inputs) = @_;
my @newinputs;
# rule of
# AC_CONFIG_FILES($OUTPUT:$INPUT[0]:$INPUTS[1]:...)
# Also distribute $INPUTs which are not built by another AC_CONFIG_FOOs.
-sub rewrite_inputs_into_dependencies ($@)
+sub rewrite_inputs_into_dependencies
{
my ($file, @inputs) = @_;
my @res = ();
-# &handle_configure ($MAKEFILE_AM, $MAKEFILE_IN, $MAKEFILE, @INPUTS)
-# ------------------------------------------------------------------
+# handle_configure ($MAKEFILE_AM, $MAKEFILE_IN, $MAKEFILE, @INPUTS)
+# -----------------------------------------------------------------
# Handle remaking and configure stuff.
# We need the name of the input file, to do proper remaking rules.
-sub handle_configure ($$$@)
+sub handle_configure
{
my ($makefile_am, $makefile_in, $makefile, @inputs) = @_;
if ($relative_dir eq '.')
{
- &push_dist_common ('acconfig.h')
+ push_dist_common ('acconfig.h')
if -f 'acconfig.h';
}
# directory and the header's directory doesn't have a
# Makefile, then we also want to build the header.
if ($relative_dir eq $config_h_dir
- || ($relative_dir eq '.' && ! &is_make_dir ($config_h_dir)))
+ || ($relative_dir eq '.' && ! is_make_dir ($config_h_dir)))
{
my ($cn_sans_dir, $stamp_dir);
if ($relative_dir eq $config_h_dir)
my $fd = dirname ($file);
if ($fd ne $relative_dir)
{
- if ($relative_dir eq '.' && ! &is_make_dir ($fd))
+ if ($relative_dir eq '.' && ! is_make_dir ($fd))
{
$local = $file;
}
my $fd = dirname ($link);
if ($fd ne $relative_dir)
{
- if ($relative_dir eq '.' && ! &is_make_dir ($fd))
+ if ($relative_dir eq '.' && ! is_make_dir ($fd))
{
$local = $link;
}
# At the top-level ('.') we also distribute files whose
# directory does not have a Makefile.
if (($fd eq $relative_dir)
- || ($relative_dir eq '.' && ! &is_make_dir ($fd)))
+ || ($relative_dir eq '.' && ! is_make_dir ($fd)))
{
# The following will distribute $file as a side-effect when
# it is appropriate (i.e., when $file is not already an output).
@actual_other_vpath_files);
}
-# Handle C headers.
-sub handle_headers
+sub handle_headers ()
{
- my @r = &am_install_var ('-defaultdist', 'header', 'HEADERS', 'include',
- 'oldinclude', 'pkginclude',
- 'noinst', 'check');
+ my @r = am_install_var ('-defaultdist', 'header', 'HEADERS', 'include',
+ 'oldinclude', 'pkginclude',
+ 'noinst', 'check');
foreach (@r)
{
next unless $_->[1] =~ /\..*$/;
- &saw_extension ($&);
+ saw_extension ($&);
}
}
-sub handle_gettext
+sub handle_gettext ()
{
return if ! $seen_gettext || $relative_dir ne '.';
require_file ($ac_gettext_location, GNU, 'ABOUT-NLS');
}
-# Handle footer elements.
-sub handle_footer
+# Emit makefile footer.
+sub handle_footer ()
{
reject_rule ('.SUFFIXES',
"use variable 'SUFFIXES', not target '.SUFFIXES'");
# Generate 'make install' rules.
sub handle_install ()
{
- $output_rules .= &file_contents
+ $output_rules .= file_contents
('install',
new Automake::Location,
maybe_BUILT_SOURCES => (set_seen ('BUILT_SOURCES')
? (" \$(BUILT_SOURCES)\n"
. "\t\$(MAKE) \$(AM_MAKEFLAGS)")
: ''),
- 'installdirs-local' => (user_phony_rule 'installdirs-local'
+ 'installdirs-local' => (user_phony_rule ('installdirs-local')
? ' installdirs-local' : ''),
am__installdirs => variable_value ('am__installdirs') || '');
}
-# Deal with all and all-am.
-sub handle_all ($)
+# handle_all ($MAKEFILE)
+#-----------------------
+# Deal with 'all' and 'all-am'.
+sub handle_all
{
my ($makefile) = @_;
push (@all, "all-local")
if user_phony_rule "all-local";
- &pretty_print_rule ("all-am:", "\t\t", @all);
- &depend ('.PHONY', 'all-am', 'all');
+ pretty_print_rule ("all-am:", "\t\t", @all);
+ depend ('.PHONY', 'all-am', 'all');
# Output 'all'.
}
}
-# Generate helper targets for user recursion, where needed.
+# Generate helper targets for user-defined recursive targets, where needed.
sub handle_user_recursion ()
{
return unless @extra_recursive_targets;
# associated 'foo-local' rule; we define it as an empty rule by
# default, so that the user can transparently extend it in his
# own Makefile.am.
- pretty_print_rule ("$target-local:");
+ pretty_print_rule ("$target-local:", '', '');
# $target-recursive might as well be undefined, so do not add
# it here; it's taken care of in subdirs.am anyway.
depend (".PHONY", "$target-am", "$target-local");
}
-# &do_check_merge_target ()
-# -------------------------
# Handle check merge target specially.
sub do_check_merge_target ()
{
if var ('BUILT_SOURCES');
}
-# handle_clean ($MAKEFILE)
-# ------------------------
# Handle all 'clean' targets.
-sub handle_clean ($)
+sub handle_clean
{
my ($makefile) = @_;
push @{$rms{$when}}, "\t-$rm\n";
}
- $output_rules .= &file_contents
+ $output_rules .= file_contents
('clean',
new Automake::Location,
MOSTLYCLEAN_RMS => join ('', sort @{$rms{&MOSTLY_CLEAN}}),
}
-# &target_cmp ($A, $B)
-# --------------------
-# Subroutine for &handle_factored_dependencies to let '.PHONY' and
-# other '.TARGETS' be last.
+# Subroutine for handle_factored_dependencies() to let '.PHONY' and
+# other '.TARGETS' be last. This is meant to be used as a comparison
+# subroutine passed to the sort built-int.
sub target_cmp
{
return 0 if $a eq $b;
}
-# &handle_factored_dependencies ()
-# --------------------------------
# Handle everything related to gathered targets.
-sub handle_factored_dependencies
+sub handle_factored_dependencies ()
{
# Reject bad hooks.
foreach my $utarg ('uninstall-data-local', 'uninstall-data-hook',
foreach my $cond (@undefined_conds)
{
my $condstr = $cond->subst_string;
- &pretty_print_rule ("$condstr$_:", "$condstr\t", @uniq_deps);
+ pretty_print_rule ("$condstr$_:", "$condstr\t", @uniq_deps);
$output_rules .= $actions{$_} if defined $actions{$_};
$output_rules .= "\n";
}
}
-# &handle_tests_dejagnu ()
-# ------------------------
-sub handle_tests_dejagnu
+sub handle_tests_dejagnu ()
{
push (@check_tests, 'check-DEJAGNU');
$output_rules .= file_contents ('dejagnu', new Automake::Location);
}
+# handle_per_suffix_test ($TEST_SUFFIX, [%TRANSFORM])
+#----------------------------------------------------
sub handle_per_suffix_test
{
my ($test_suffix, %transform) = @_;
# ------------------------------
# Return true if $EXT can appear in $(TEST_EXTENSIONS), return false
# otherwise.
-sub is_valid_test_extension ($)
+sub is_valid_test_extension
{
my $ext = shift;
return 1
return 0;
}
-# Handle TESTS variable and other checks.
-sub handle_tests
+
+sub handle_tests ()
{
if (option 'dejagnu')
{
- &handle_tests_dejagnu;
+ handle_tests_dejagnu;
}
else
{
{
push (@check_tests, 'check-TESTS');
my $check_deps = "@check";
- $output_rules .= &file_contents ('check', new Automake::Location,
- SERIAL_TESTS => !! option 'serial-tests',
- CHECK_DEPS => $check_deps);
+ $output_rules .= file_contents ('check', new Automake::Location,
+ SERIAL_TESTS => !! option 'serial-tests',
+ CHECK_DEPS => $check_deps);
# Tests that are known programs should have $(EXEEXT) appended.
# For matching purposes, we need to adjust XFAIL_TESTS as well.
}
}
-# Handle Emacs Lisp.
-sub handle_emacs_lisp
+sub handle_emacs_lisp ()
{
- my @elfiles = &am_install_var ('-candist', 'lisp', 'LISP',
- 'lisp', 'noinst');
+ my @elfiles = am_install_var ('-candist', 'lisp', 'LISP',
+ 'lisp', 'noinst');
return if ! @elfiles;
'EMACS', 'lispdir');
}
-# Handle Python
-sub handle_python
+sub handle_python ()
{
- my @pyfiles = &am_install_var ('-defaultdist', 'python', 'PYTHON',
- 'noinst');
+ my @pyfiles = am_install_var ('-defaultdist', 'python', 'PYTHON',
+ 'noinst');
return if ! @pyfiles;
require_variables ($pyfiles[0][0], "Python sources seen", TRUE, 'PYTHON');
require_conf_file ($pyfiles[0][0], FOREIGN, 'py-compile');
- &define_variable ('py_compile', "$am_config_aux_dir/py-compile", INTERNAL);
+ define_variable ('py_compile', "$am_config_aux_dir/py-compile", INTERNAL);
}
-# Handle Java.
-sub handle_java
+sub handle_java ()
{
- my @sourcelist = &am_install_var ('-candist',
- 'java', 'JAVA',
- 'noinst', 'check');
+ my @sourcelist = am_install_var ('-candist',
+ 'java', 'JAVA',
+ 'noinst', 'check');
return if ! @sourcelist;
my @prefixes = am_primary_prefixes ('JAVA', 1,
}
-# Handle some of the minor options.
-sub handle_minor_options
+sub handle_minor_options ()
{
if (option 'readme-alpha')
{
################################################################
# ($OUTPUT, @INPUTS)
-# &split_config_file_spec ($SPEC)
-# -------------------------------
+# split_config_file_spec ($SPEC)
+# ------------------------------
# Decode the Autoconf syntax for config files (files, headers, links
# etc.).
-sub split_config_file_spec ($)
+sub split_config_file_spec
{
my ($spec) = @_;
my ($output, @inputs) = split (/:/, $spec);
# AC_CONFIG_FILES allow specifications such as Makefile:top.in:mid.in:bot.in
# This functions returns the first *.in file for which a *.am exists.
# It returns undef otherwise.
-sub locate_am (@)
+sub locate_am
{
my (@rest) = @_;
my $input;
my %make_list;
-# &scan_autoconf_config_files ($WHERE, $CONFIG-FILES)
-# ---------------------------------------------------
+# scan_autoconf_config_files ($WHERE, $CONFIG-FILES)
+# --------------------------------------------------
# Study $CONFIG-FILES which is the first argument to AC_CONFIG_FILES
# (or AC_OUTPUT).
-sub scan_autoconf_config_files ($$)
+sub scan_autoconf_config_files
{
my ($where, $config_files) = @_;
}
-# &scan_autoconf_traces ($FILENAME)
-# ---------------------------------
-sub scan_autoconf_traces ($)
+sub scan_autoconf_traces
{
my ($filename) = @_;
AM_INIT_AUTOMAKE => 0,
AM_MAINTAINER_MODE => 0,
AM_PROG_AR => 0,
- AM_PROG_CC_C_O => 0,
_AM_SUBST_NOTMAKE => 1,
_AM_COND_IF => 1,
_AM_COND_ELSE => 1,
{
my @opts = split (' ', $args[1]);
@opts = map { { option => $_, where => $where } } @opts;
- exit $exit_code if process_global_option_list (@opts);
+ exit $exit_code unless process_global_option_list (@opts);
}
}
elsif ($macro eq 'AM_MAINTAINER_MODE')
{
$seen_ar = $where;
}
- elsif ($macro eq 'AM_PROG_CC_C_O')
- {
- $seen_cc_c_o = $where;
- }
elsif ($macro eq '_AM_COND_IF')
{
cond_stack_if ('', $args[1], $where);
}
-# &scan_autoconf_files ()
-# -----------------------
# Check whether we use 'configure.ac' or 'configure.in'.
# Scan it (and possibly 'aclocal.m4') for interesting things.
# We must scan aclocal.m4 because there might be AC_SUBSTs and such there.
################################################################
# Do any extra checking for GNU standards.
-sub check_gnu_standards
+sub check_gnu_standards ()
{
if ($relative_dir eq '.')
{
}
# Do any extra checking for GNITS standards.
-sub check_gnits_standards
+sub check_gnits_standards ()
{
if ($relative_dir eq '.')
{
# This is just a convenience function that can be used to determine
# when a subdir object should be used.
-sub lang_sub_obj
+sub lang_sub_obj ()
{
return option 'subdir-objects' ? LANG_SUBDIR : LANG_PROCESS;
}
-# Rewrite a single C source file.
-sub lang_c_rewrite
-{
- my ($directory, $base, $ext, $obj, $have_per_exec_flags, $var) = @_;
-
- my $r = LANG_PROCESS;
- if (option 'subdir-objects')
- {
- $r = LANG_SUBDIR;
- if ($directory && $directory ne '.')
- {
- $base = $directory . '/' . $base;
-
- # libtool is always able to put the object at the proper place,
- # so we do not have to require AM_PROG_CC_C_O when building .lo files.
- msg_var ('portability', $var,
- "compiling '$base.c' in subdir requires "
- . "'AM_PROG_CC_C_O' in '$configure_ac'",
- uniq_scope => US_GLOBAL,
- uniq_part => 'AM_PROG_CC_C_O subdir')
- unless $seen_cc_c_o || $obj eq '.lo';
- }
- }
-
- if (! $seen_cc_c_o
- && $have_per_exec_flags
- && ! option 'subdir-objects'
- && $obj ne '.lo')
- {
- msg_var ('portability',
- $var, "compiling '$base.c' with per-target flags requires "
- . "'AM_PROG_CC_C_O' in '$configure_ac'",
- uniq_scope => US_GLOBAL,
- uniq_part => 'AM_PROG_CC_C_O per-target')
- }
-
- return $r;
-}
-
# Rewrite a single header file.
sub lang_header_rewrite
{
{
my ($directory, $base, $ext) = @_;
- my $r = &lang_sub_obj;
+ my $r = lang_sub_obj;
(my $newext = $ext) =~ tr/y/c/;
return ($r, $newext);
}
{
my ($directory, $base, $ext) = @_;
- my $r = &lang_sub_obj;
+ my $r = lang_sub_obj;
(my $newext = $ext) =~ tr/l/c/;
return ($r, $newext);
}
# language, etc. A finish function is only called if a source file of
# the appropriate type has been seen.
-sub lang_vala_finish_target ($$)
+sub lang_vala_finish_target
{
my ($self, $name) = @_;
# Add output rules to invoke valac and create stamp file as a witness
# to handle multiple outputs. This function is called after all source
# file processing is done.
-sub lang_vala_finish
+sub lang_vala_finish ()
{
my ($self) = @_;
. "$condstr\t\@if test ! -f \$@; then \$(MAKE) \$(AM_MAKEFLAGS) $output; else :; fi\n";
}
# Distribute the generated file, unless its .y source was
- # listed in a nodist_ variable. (&handle_source_transform
+ # listed in a nodist_ variable. (handle_source_transform()
# will set DIST_SOURCE.)
- &push_dist_common ($header)
+ push_dist_common ($header)
if $transform{'DIST_SOURCE'};
# The GNU rules say that yacc/lex output files should be removed
}
# This is a helper for both lex and yacc.
-sub yacc_lex_finish_helper
+sub yacc_lex_finish_helper ()
{
return if defined $language_scratch{'lex-yacc-done'};
$language_scratch{'lex-yacc-done'} = 1;
# FIXME: for now, no line number.
require_conf_file ($configure_ac, FOREIGN, 'ylwrap');
- &define_variable ('YLWRAP', "$am_config_aux_dir/ylwrap", INTERNAL);
+ define_variable ('YLWRAP', "$am_config_aux_dir/ylwrap", INTERNAL);
}
-sub lang_yacc_finish
+sub lang_yacc_finish ()
{
return if defined $language_scratch{'yacc-done'};
$language_scratch{'yacc-done'} = 1;
}
-sub lang_lex_finish
+sub lang_lex_finish ()
{
return if defined $language_scratch{'lex-done'};
$language_scratch{'lex-done'} = 1;
# ------------------------------
# Register a single language.
# Each %ATTRIBUTE is of the form ATTRIBUTE => VALUE.
-sub register_language (%)
+sub register_language
{
my (%option) = @_;
$option{'nodist_specific'} = 0
unless defined $option{'nodist_specific'};
- my $lang = new Language (%option);
+ my $lang = new Automake::Language (%option);
# Fill indexes.
$extension_map{$_} = $lang->name foreach @{$lang->extensions};
# Update the suffix rules map.
foreach my $suffix (@{$lang->extensions})
{
- foreach my $dest (&{$lang->output_extensions} ($suffix))
+ foreach my $dest ($lang->output_extensions->($suffix))
{
register_suffix_rule (INTERNAL, $suffix, $dest);
}
# --------------------------
# This function is used to find a path from a user-specified suffix $EXT
# to $OBJ or to some other suffix we recognize internally, e.g. 'cc'.
-sub derive_suffix ($$)
+sub derive_suffix
{
my ($source_ext, $obj) = @_;
}
-################################################################
-
-# Pretty-print something and append to output_rules.
+# Pretty-print something and append to '$output_rules'.
sub pretty_print_rule
{
- $output_rules .= &makefile_wrap (@_);
+ $output_rules .= makefile_wrap (shift, shift, @_);
}
# $STRING
# make_conditional_string ($NEGATE, $COND)
# ----------------------------------------
-sub make_conditional_string ($$)
+sub make_conditional_string
{
my ($negate, $cond) = @_;
$cond = "${cond}_TRUE"
# $COND
# cond_stack_if ($NEGATE, $COND, $WHERE)
# --------------------------------------
-sub cond_stack_if ($$$)
+sub cond_stack_if
{
my ($negate, $cond, $where) = @_;
# $COND
# cond_stack_else ($NEGATE, $COND, $WHERE)
# ----------------------------------------
-sub cond_stack_else ($$$)
+sub cond_stack_else
{
my ($negate, $cond, $where) = @_;
# $COND
# cond_stack_endif ($NEGATE, $COND, $WHERE)
# -----------------------------------------
-sub cond_stack_endif ($$$)
+sub cond_stack_endif
{
my ($negate, $cond, $where) = @_;
my $old_cond;
## ------------------------ ##
-# &define_pretty_variable ($VAR, $COND, $WHERE, @VALUE)
-# -----------------------------------------------------
+# define_pretty_variable ($VAR, $COND, $WHERE, @VALUE)
+# ----------------------------------------------------
# Like define_variable, but the value is a list, and the variable may
# be defined conditionally. The second argument is the condition
# under which the value should be defined; this should be the empty
# string to define the variable unconditionally. The third argument
# is a list holding the values to use for the variable. The value is
# pretty printed in the output file.
-sub define_pretty_variable ($$$@)
+sub define_pretty_variable
{
my ($var, $cond, $where, @value) = @_;
# --------------------------------------
# Define a new Automake Makefile variable VAR to VALUE, but only if
# not already defined.
-sub define_variable ($$$)
+sub define_variable
{
my ($var, $value, $where) = @_;
define_pretty_variable ($var, TRUE, $where, $value);
# Like define_variable, but define a variable to be the configure
# substitution by the same name.
-sub define_configure_variable ($)
+sub define_configure_variable
{
my ($var) = @_;
# Some variables we do not want to output. For instance it
# would be a bad idea to output `U = @U@` when `@U@` can be
# substituted as `\`.
my $pretty = exists $ignored_configure_vars{$var} ? VAR_SILENT : VAR_ASIS;
- Automake::Variable::define ($var, VAR_CONFIGURE, '', TRUE, subst $var,
+ Automake::Variable::define ($var, VAR_CONFIGURE, '', TRUE, subst ($var),
'', $configure_vars{$var}, $pretty);
}
# --------------------------------
# Define a compiler variable. We also handle defining the 'LT'
# version of the command when using libtool.
-sub define_compiler_variable ($)
+sub define_compiler_variable
{
my ($lang) = @_;
my $libtool_tag = '';
$libtool_tag = '--tag=' . $lang->libtool_tag . ' '
if $lang->libtool_tag && exists $libtool_tags{$lang->libtool_tag};
- &define_variable ($var, $value, INTERNAL);
+ define_variable ($var, $value, INTERNAL);
if (var ('LIBTOOL'))
{
my $verbose = define_verbose_libtool ();
- &define_variable ("LT$var",
- "\$(LIBTOOL) $verbose $libtool_tag\$(AM_LIBTOOLFLAGS) "
- . "\$(LIBTOOLFLAGS) --mode=compile $value",
- INTERNAL);
+ define_variable ("LT$var",
+ "\$(LIBTOOL) $verbose $libtool_tag\$(AM_LIBTOOLFLAGS)"
+ . " \$(LIBTOOLFLAGS) --mode=compile $value",
+ INTERNAL);
}
define_verbose_tagvar ($lang->ccer || 'GEN');
}
-# define_linker_variable ($LANG)
-# ------------------------------
-# Define linker variables.
-sub define_linker_variable ($)
+sub define_linker_variable
{
my ($lang) = @_;
$libtool_tag = '--tag=' . $lang->libtool_tag . ' '
if $lang->libtool_tag && exists $libtool_tags{$lang->libtool_tag};
# CCLD = $(CC).
- &define_variable ($lang->lder, $lang->ld, INTERNAL);
+ define_variable ($lang->lder, $lang->ld, INTERNAL);
# CCLINK = $(CCLD) blah blah...
my $link = '';
if (var ('LIBTOOL'))
$link = "\$(LIBTOOL) $verbose $libtool_tag\$(AM_LIBTOOLFLAGS) "
. "\$(LIBTOOLFLAGS) --mode=link ";
}
- &define_variable ($lang->linker, $link . $lang->link, INTERNAL);
- &define_variable ($lang->compiler, $lang);
- &define_verbose_tagvar ($lang->lder || 'GEN');
+ define_variable ($lang->linker, $link . $lang->link, INTERNAL);
+ define_variable ($lang->compiler, $lang, INTERNAL);
+ define_verbose_tagvar ($lang->lder || 'GEN');
}
-sub define_per_target_linker_variable ($$)
+sub define_per_target_linker_variable
{
my ($linker, $target) = @_;
return ($lang->linker, $lang->lder)
if $link_command eq $orig_command;
- &define_variable ("${target}_LINK", $link_command, INTERNAL);
+ define_variable ("${target}_LINK", $link_command, INTERNAL);
return ("${target}_LINK", $lang->lder);
}
################################################################
-# &check_trailing_slash ($WHERE, $LINE)
-# -------------------------------------
+# check_trailing_slash ($WHERE, $LINE)
+# ------------------------------------
# Return 1 iff $LINE ends with a slash.
# Might modify $LINE.
sub check_trailing_slash ($\$)
}
-# &read_am_file ($AMFILE, $WHERE)
-# -------------------------------
+# read_am_file ($AMFILE, $WHERE, $RELDIR)
+# ---------------------------------------
# Read Makefile.am and set up %contents. Simultaneously copy lines
# from Makefile.am into $output_trailer, or define variables as
# appropriate. NOTE we put rules in the trailer section. We want
# user rules to come after our generated stuff.
-sub read_am_file ($$)
+sub read_am_file
{
- my ($amfile, $where) = @_;
+ my ($amfile, $where, $reldir) = @_;
+ my $canon_reldir = &canonicalize ($reldir);
my $am_file = new Automake::XFile ("< $amfile");
verb "reading $amfile";
my $new_saw_bk = check_trailing_slash ($where, $_);
+ if ($reldir eq '.')
+ {
+ # If present, eat the following '_' or '/', converting
+ # "%reldir%/foo" and "%canon_reldir%_foo" into plain "foo"
+ # when $reldir is '.'.
+ $_ =~ s,%(D|reldir)%/,,g;
+ $_ =~ s,%(C|canon_reldir)%_,,g;
+ }
+ $_ =~ s/%(D|reldir)%/${reldir}/g;
+ $_ =~ s/%(C|canon_reldir)%/${canon_reldir}/g;
+
if (/$IGNORE_PATTERN/o)
{
# Merely delete comments beginning with two hashes.
push_dist_common ("\$\(srcdir\)/$path");
$path = $relative_dir . "/" . $path if $relative_dir ne '.';
}
+ my $new_reldir = File::Spec->abs2rel ($path, $relative_dir);
+ $new_reldir = '.' if $new_reldir !~ s,/[^/]*$,,;
$where->push_context ("'$path' included from here");
- &read_am_file ($path, $where);
+ read_am_file ($path, $where, $new_reldir);
$where->pop_context;
}
else
}
-# define_standard_variables ()
-# ----------------------------
# A helper for read_main_am_file which initializes configure variables
# and variables from header-vars.am.
-sub define_standard_variables
+sub define_standard_variables ()
{
my $saved_output_vars = $output_vars;
my ($comments, undef, $rules) =
foreach my $var (sort keys %configure_vars)
{
- &define_configure_variable ($var);
+ define_configure_variable ($var);
}
$output_vars .= $comments . $rules;
}
-# Read main am file.
-sub read_main_am_file ($$)
+
+# read_main_am_file ($MAKEFILE_AM, $MAKEFILE_IN)
+# ----------------------------------------------
+sub read_main_am_file
{
my ($amfile, $infile) = @_;
# We want to predefine as many variables as possible. This lets
# the user set them with '+=' in Makefile.am.
- &define_standard_variables;
+ define_standard_variables;
# Read user file, which might override some of our values.
- &read_am_file ($amfile, new Automake::Location);
+ read_am_file ($amfile, new Automake::Location, '.');
}
################################################################
-# $FLATTENED
-# &flatten ($STRING)
-# ------------------
-# Flatten the $STRING and return the result.
+# $STRING
+# flatten ($ORIGINAL_STRING)
+# --------------------------
sub flatten
{
$_ = shift;
# transform_token ($TOKEN, \%PAIRS, $KEY)
-# =======================================
+# ---------------------------------------
# Return the value associated to $KEY in %PAIRS, as used on $TOKEN
# (which should be ?KEY? or any of the special %% requests)..
-sub transform_token ($$$)
+sub transform_token ($\%$)
{
my ($token, $transform, $key) = @_;
my $res = $transform->{$key};
# transform ($TOKEN, \%PAIRS)
-# ===========================
+# ---------------------------
# If ($TOKEN, $VAL) is in %PAIRS:
# - replaces %KEY% with $VAL,
# - enables/disables ?KEY? and ?!KEY?,
# - replaces %?KEY% with TRUE or FALSE.
-sub transform ($$)
+sub transform ($\%)
{
my ($token, $transform) = @_;
# when there is neither IFTRUE nor IFFALSE.
if ($token =~ /^%([\w\-]+)%$/)
{
- return transform_token ($token, $transform, $1);
+ return transform_token ($token, %$transform, $1);
}
# %?KEY%.
elsif ($token =~ /^%\?([\w\-]+)%$/)
{
- return transform_token ($token, $transform, $1) ? 'TRUE' : 'FALSE';
+ return transform_token ($token, %$transform, $1) ? 'TRUE' : 'FALSE';
}
# ?KEY? and ?!KEY?.
elsif ($token =~ /^ \? (!?) ([\w\-]+) \? $/x)
{
my $neg = ($1 eq '!') ? 1 : 0;
- my $val = transform_token ($token, $transform, $2);
+ my $val = transform_token ($token, %$transform, $2);
return (!!$val == $neg) ? '##%' : '';
}
else
# Load a $MAKEFILE, apply the %TRANSFORM, and return the result.
# No extra parsing or post-processing is done (i.e., recognition of
# rules declaration or of make variables definitions).
-sub preprocess_file ($%)
+sub preprocess_file
{
my ($file, %transform) = @_;
# Substitute Automake template tokens.
s/(?: % \?? [\w\-]+ %
| \? !? [\w\-]+ \?
- )/transform($&, \%transform)/gex;
+ )/transform($&, %transform)/gex;
# transform() may have added some ##%-comments to strip.
# (we use '##%' instead of '##' so we can distinguish ##%##%##% from
# ####### and do not remove the latter.)
# @PARAGRAPHS
-# &make_paragraphs ($MAKEFILE, [%TRANSFORM])
-# ------------------------------------------
+# make_paragraphs ($MAKEFILE, [%TRANSFORM])
+# -----------------------------------------
# Load a $MAKEFILE, apply the %TRANSFORM, and return it as a list of
# paragraphs.
-sub make_paragraphs ($%)
+sub make_paragraphs
{
my ($file, %transform) = @_;
$transform{FIRST} = !$transformed_files{$file};
# ($COMMENT, $VARIABLES, $RULES)
-# &file_contents_internal ($IS_AM, $FILE, $WHERE, [%TRANSFORM])
-# -------------------------------------------------------------
+# file_contents_internal ($IS_AM, $FILE, $WHERE, [%TRANSFORM])
+# ------------------------------------------------------------
# Return contents of a file from $libdir/am, automatically skipping
# macros or rules which are already known. $IS_AM iff the caller is
# reading an Automake file (as opposed to the user's Makefile.am).
-sub file_contents_internal ($$$%)
+sub file_contents_internal
{
my ($is_am, $file, $where, %transform) = @_;
my ($targets, $dependencies) = ($1, $2);
# Remove the escaped new lines.
# I don't know why, but I have to use a tmp $flat_deps.
- my $flat_deps = &flatten ($dependencies);
+ my $flat_deps = flatten ($dependencies);
my @deps = split (' ', $flat_deps);
foreach (split (' ', $targets))
# Output only if not in FALSE.
if (defined $dependencies{$_} && $cond != FALSE)
{
- &depend ($_, @deps);
+ depend ($_, @deps);
register_action ($_, $actions);
}
else
# $CONTENTS
-# &file_contents ($BASENAME, $WHERE, [%TRANSFORM])
-# ------------------------------------------------
+# file_contents ($BASENAME, $WHERE, [%TRANSFORM])
+# -----------------------------------------------
# Return contents of a file from $libdir/am, automatically skipping
# macros or rules which are already known.
-sub file_contents ($$%)
+sub file_contents
{
my ($basename, $where, %transform) = @_;
my ($comments, $variables, $rules) =
# @PREFIX
-# &am_primary_prefixes ($PRIMARY, $CAN_DIST, @PREFIXES)
-# -----------------------------------------------------
+# am_primary_prefixes ($PRIMARY, $CAN_DIST, @PREFIXES)
+# ----------------------------------------------------
# Find all variable prefixes that are used for install directories. A
# prefix 'zar' qualifies iff:
#
# variable "zardir" is defined, then "zar_PROGRAMS" becomes valid.
# This is to provide a little extra flexibility in those cases which
# need it.
-sub am_primary_prefixes ($$@)
+sub am_primary_prefixes
{
my ($primary, $can_dist, @prefixes) = @_;
}
+# am_install_var (-OPTION..., file, HOW, where...)
+# ------------------------------------------------
+#
# Handle 'where_HOW' variable magic. Does all lookups, generates
# install code, and possibly generates code to define the primary
# variable. The first argument is the name of the .am file to munge,
# FIXME: this should be rewritten to be cleaner. It should be broken
# up into multiple functions.
#
-# Usage is: am_install_var (OPTION..., file, HOW, where...)
sub am_install_var
{
my (@args) = @_;
}
else
{
- # Strip any $(EXEEXT) suffix the user might have added, or this
- # will confuse &handle_source_transform and &check_canonical_spelling.
+ # Strip any $(EXEEXT) suffix the user might have added,
+ # or this will confuse handle_source_transform() and
+ # check_canonical_spelling().
# We'll add $(EXEEXT) back later anyway.
- # Do it here rather than in handle_programs so the uniquifying at the
- # end of this function works.
+ # Do it here rather than in handle_programs so the
+ # uniquifying at the end of this function works.
${$locvals}[1] =~ s/\$\(EXEEXT\)$//
if $primary eq 'PROGRAMS';
# Singular form of $PRIMARY.
(my $one_primary = $primary) =~ s/S$//;
- $output_rules .= &file_contents ($file, $where,
- PRIMARY => $primary,
- ONE_PRIMARY => $one_primary,
- DIR => $X,
- NDIR => $nodir_name,
- BASE => $strip_subdir,
-
- EXEC => $exec_p,
- INSTALL => $install_p,
- DIST => $dist_p,
- DISTVAR => $distvar,
- 'CK-OPTS' => $check_options_p);
+ $output_rules .= file_contents ($file, $where,
+ PRIMARY => $primary,
+ ONE_PRIMARY => $one_primary,
+ DIR => $X,
+ NDIR => $nodir_name,
+ BASE => $strip_subdir,
+ EXEC => $exec_p,
+ INSTALL => $install_p,
+ DIST => $dist_p,
+ DISTVAR => $distvar,
+ 'CK-OPTS' => $check_options_p);
}
# The JAVA variable is used as the name of the Java interpreter.
my %make_dirs = ();
my $make_dirs_set = 0;
+# is_make_dir ($DIRECTORY)
+# ------------------------
sub is_make_dir
{
my ($dir) = @_;
}
-# &push_required_file ($DIR, $FILE, $FULLFILE)
-# --------------------------------------------------
+# push_required_file ($DIR, $FILE, $FULLFILE)
+# -------------------------------------------
# Push the given file onto DIST_COMMON.
sub push_required_file
{
$am_config_libobj_dir =~ s|/*$||;
push_dist_common ("$am_config_libobj_dir/$file");
}
- elsif ($relative_dir eq '.' && ! &is_make_dir ($dir))
+ elsif ($relative_dir eq '.' && ! is_make_dir ($dir))
{
# If we are doing the topmost directory, and the file is in a
# subdir which does not have a Makefile, then we distribute it
# than once.
my %required_file_not_found = ();
-# &required_file_check_or_copy ($WHERE, $DIRECTORY, $FILE)
-# --------------------------------------------------------
+# required_file_check_or_copy ($WHERE, $DIRECTORY, $FILE)
+# -------------------------------------------------------
# Verify that the file must exist in $DIRECTORY, or install it.
-sub required_file_check_or_copy ($$$)
+sub required_file_check_or_copy
{
my ($where, $dir, $file) = @_;
}
-# &require_file_internal ($WHERE, $MYSTRICT, $DIRECTORY, $QUEUE, @FILES)
-# ----------------------------------------------------------------------
+# require_file_internal ($WHERE, $MYSTRICT, $DIRECTORY, $QUEUE, @FILES)
+# ---------------------------------------------------------------------
# Verify that the file must exist in $DIRECTORY, or install it.
# $MYSTRICT is the strictness level at which this file becomes required.
# Worker threads may queue up the action to be serialized by the master,
# if $QUEUE is true
-sub require_file_internal ($$$@)
+sub require_file_internal
{
my ($where, $mystrict, $dir, $queue, @files) = @_;
}
}
-# &require_file ($WHERE, $MYSTRICT, @FILES)
-# -----------------------------------------
-sub require_file ($$@)
+# require_file ($WHERE, $MYSTRICT, @FILES)
+# ----------------------------------------
+sub require_file
{
my ($where, $mystrict, @files) = @_;
require_file_internal ($where, $mystrict, $relative_dir, 0, @files);
}
-# &require_file_with_macro ($COND, $MACRO, $MYSTRICT, @FILES)
-# -----------------------------------------------------------
-sub require_file_with_macro ($$$@)
+# require_file_with_macro ($COND, $MACRO, $MYSTRICT, @FILES)
+# ----------------------------------------------------------
+sub require_file_with_macro
{
my ($cond, $macro, $mystrict, @files) = @_;
$macro = rvar ($macro) unless ref $macro;
require_file ($macro->rdef ($cond)->location, $mystrict, @files);
}
-# &require_libsource_with_macro ($COND, $MACRO, $MYSTRICT, @FILES)
-# ----------------------------------------------------------------
+# require_libsource_with_macro ($COND, $MACRO, $MYSTRICT, @FILES)
+# ---------------------------------------------------------------
# Require an AC_LIBSOURCEd file. If AC_CONFIG_LIBOBJ_DIR was called, it
# must be in that directory. Otherwise expect it in the current directory.
-sub require_libsource_with_macro ($$$@)
+sub require_libsource_with_macro
{
my ($cond, $macro, $mystrict, @files) = @_;
$macro = rvar ($macro) unless ref $macro;
}
}
-# &queue_required_file_check_or_copy ($QUEUE, $KEY, $DIR, $WHERE,
-# $MYSTRICT, @FILES)
-# ---------------------------------------------------------------
-sub queue_required_file_check_or_copy ($$$$@)
+# queue_required_file_check_or_copy ($QUEUE, $KEY, $DIR, $WHERE,
+# $MYSTRICT, @FILES)
+# --------------------------------------------------------------
+sub queue_required_file_check_or_copy
{
my ($queue, $key, $dir, $where, $mystrict, @files) = @_;
my @serial_loc;
$queue->enqueue ($key, $dir, @serial_loc, $mystrict, 0 + @files, @files);
}
-# &require_queued_file_check_or_copy ($QUEUE)
-# -------------------------------------------
-sub require_queued_file_check_or_copy ($)
+# require_queued_file_check_or_copy ($QUEUE)
+# ------------------------------------------
+sub require_queued_file_check_or_copy
{
my ($queue) = @_;
my $where;
}
}
-# &require_conf_file ($WHERE, $MYSTRICT, @FILES)
-# ----------------------------------------------
+# require_conf_file ($WHERE, $MYSTRICT, @FILES)
+# ---------------------------------------------
# Looks in configuration path, as specified by AC_CONFIG_AUX_DIR.
-sub require_conf_file ($$@)
+sub require_conf_file
{
my ($where, $mystrict, @files) = @_;
my $queue = defined $required_conf_file_queue ? 1 : 0;
}
-# &require_conf_file_with_macro ($COND, $MACRO, $MYSTRICT, @FILES)
-# ----------------------------------------------------------------
-sub require_conf_file_with_macro ($$$@)
+# require_conf_file_with_macro ($COND, $MACRO, $MYSTRICT, @FILES)
+# ---------------------------------------------------------------
+sub require_conf_file_with_macro
{
my ($cond, $macro, $mystrict, @files) = @_;
require_conf_file (rvar ($macro)->rdef ($cond)->location,
################################################################
-# &require_build_directory ($DIRECTORY)
-# -------------------------------------
+# require_build_directory ($DIRECTORY)
+# ------------------------------------
# Emit rules to create $DIRECTORY if needed, and return
# the file that any target requiring this directory should be made
# dependent upon.
# We don't want to emit the rule twice, and want to reuse it
# for directories with equivalent names (e.g., 'foo/bar' and './foo//bar').
-sub require_build_directory ($)
+sub require_build_directory
{
my $directory = shift;
return $dirstamp;
}
-# &require_build_directory_maybe ($FILE)
-# --------------------------------------
+# require_build_directory_maybe ($FILE)
+# -------------------------------------
# If $FILE lies in a subdirectory, emit a rule to create this
# directory and return the file that $FILE should be made
# dependent upon. Otherwise, just return the empty string.
-sub require_build_directory_maybe ($)
+sub require_build_directory_maybe
{
my $file = shift;
my $directory = dirname ($file);
################################################################
-# Push a list of files onto dist_common.
+# Push a list of files onto '@dist_common'.
sub push_dist_common
{
prog_error "push_dist_common run after handle_dist"
# ----------------------------------------------
# Generate a Makefile.in given the name of the corresponding Makefile and
# the name of the file output by config.status.
-sub generate_makefile ($$)
+sub generate_makefile
{
my ($makefile_am, $makefile_in) = @_;
# $OUTPUT is encoded. If it contains a ":" then the first element
# is the real output file, and all remaining elements are input
# files. We don't scan or otherwise deal with these input files,
- # other than to mark them as dependencies. See
- # &scan_autoconf_files for details.
+ # other than to mark them as dependencies. See the subroutine
+ # 'scan_autoconf_files' for details.
my ($makefile, @inputs) = split (/:/, $output_files{$makefile_in});
$relative_dir = dirname ($makefile);
read_main_am_file ($makefile_am, $makefile_in);
- if (handle_options)
+ if (not handle_options)
{
# Process buffered warnings.
flush_messages;
handle_silent;
- # These must be run after all the sources are scanned. They
- # use variables defined by &handle_libraries, &handle_ltlibraries,
- # or &handle_programs.
+ # These must be run after all the sources are scanned. They use
+ # variables defined by handle_libraries(), handle_ltlibraries(),
+ # or handle_programs().
handle_compile;
handle_languages;
handle_libtool;
print $gm_file $output;
}
-################################################################
-
-
-
################################################################
+
# Helper function for usage().
-sub print_autodist_files (@)
+sub print_autodist_files
{
+ # NOTE: we need to call our 'uniq' function with the leading '&'
+ # here, because otherwise perl complains that "Unquoted string
+ # 'uniq' may clash with future reserved word".
my @lcomm = sort (&uniq (@_));
my @four;
}
-# Print usage information.
sub usage ()
{
print "Usage: $0 [OPTION]... [Makefile]...
}
-# &version ()
-# -----------
-# Print version information
sub version ()
{
print <<EOF;
set_global_option ('no-dependencies', $cli_where) if $ignore_deps;
for my $warning (@warnings)
{
- &parse_warnings ('-W', $warning);
+ parse_warnings ('-W', $warning);
}
return unless @ARGV;
}
-# handle_makefile ($MAKEFILE_IN)
-# ------------------------------
-# Deal with $MAKEFILE_IN.
-sub handle_makefile ($)
+# handle_makefile ($MAKEFILE)
+# ---------------------------
+sub handle_makefile
{
my ($file) = @_;
($am_file = $file) =~ s/\.in$//;
}
}
-# handle_makefiles_serial ()
-# --------------------------
# Deal with all makefiles, without threads.
sub handle_makefiles_serial ()
{
}
}
-# get_number_of_threads ()
-# ------------------------
# Logic for deciding how many worker threads to use.
-sub get_number_of_threads
+sub get_number_of_threads ()
{
my $nthreads = $ENV{'AUTOMAKE_JOBS'} || 0;
#
# The latter requires that the makefile that deals with the aux dir
# files be handled last, done by the master thread.
-sub handle_makefiles_threaded ($)
+sub handle_makefiles_threaded
{
my ($nthreads) = @_;