unshift @INC, @Automake::perl_libdirs;
}
- 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
-{
- if ($perl_threads)
- {
- require threads;
- import threads;
- require Thread::Queue;
- import Thread::Queue;
- }
-}
use Automake::General;
use Automake::XFile;
use Automake::Channels;
################################################################
- ## --------------------------------- ##
- ## Forward subroutine declarations. ##
- ## --------------------------------- ##
- sub register_language (%);
- sub file_contents_internal ($$$%);
- sub define_files_variable ($\@$$);
-# 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);
--
-################################################################
--
- # &initialize_per_input ()
- # ------------------------
-
+ # initialize_per_input ()
+ # -----------------------
# (Re)-Initialize per-Makefile.am variables.
sub initialize_per_input ()
{
'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,
VERBOSE => $verbose,
# 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
- # 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
- # needs to 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,
check_user_variables @dont_override;
}
- # If the project is entirely C++ or entirely Fortran 77 (i.e., 1
- # suffix rule was learned), don't bother with the C stuff. But if
- # anything else creeps in, then use it.
- $needs_c = 1
- if $need_link || suffix_rules_count > 1;
-
- if ($needs_c)
+ # Non-pure languages, or languages lacking a linker of their own.
+ if ($needs_c || $need_link)
{
- &define_compiler_variable ($languages{'c'})
+ define_compiler_variable ($languages{'c'})
unless defined $done{$languages{'c'}};
define_linker_variable ($languages{'c'});
}
$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);
+ define_variable ($one_file . '_OBJECTS', $where, @result);
}
else
{
# Set up the compile suite.
sub handle_compile ()
{
-- return if ! $must_handle_compiled_objects;
- $output_rules .= file_contents ('compile',
- new Automake::Location,
- 'STDINC' => ! option 'nostdinc');
-
- # Boilerplate.
- my $default_includes = '';
- if (! option 'nostdinc')
- {
- my @incs = ('-I.', subst ('am__isrc'));
-
- my $var = var 'CONFIG_HEADER';
- if ($var)
- {
- foreach my $hdr (split (' ', $var->variable_value))
- {
- push @incs, '-I' . dirname ($hdr);
- }
- }
- # We want '-I. -I$(srcdir)', but the latter -I is redundant
- # and unaesthetic in non-VPATH builds. We use `-I.@am__isrc@`
- # instead. It will be replaced by '-I.' or '-I. -I$(srcdir)'.
- # Items in CONFIG_HEADER are never in $(srcdir) so it is safe
- # to just put @am__isrc@ right after '-I.', without a space.
- ($default_includes = ' ' . uniq (@incs)) =~ s/ @/@/;
- }
-
- my (@mostly_rms, @dist_rms);
- foreach my $item (sort keys %compile_clean_files)
- {
- if ($compile_clean_files{$item} == MOSTLY_CLEAN)
- {
- push (@mostly_rms, "\t-rm -f $item");
- }
- elsif ($compile_clean_files{$item} == DIST_CLEAN)
- {
- push (@dist_rms, "\t-rm -f $item");
- }
- else
- {
- prog_error 'invalid entry in %compile_clean_files';
- }
- }
-
- 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));
- $output_vars .= $vars;
- $output_rules .= "$coms$rules";
++ return if ! $must_handle_compiled_objects;
++ $output_rules .= file_contents ('compile',
++ new Automake::Location,
++ 'STDINC' => ! option 'nostdinc');
}
# handle_libtool ()
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,
- # ensure that the directory exists before we need it.
- my $dirstamp = require_build_directory_maybe ($one_file);
-
- $libtool_clean_directories{dirname ($one_file)} = 1;
+ $clean_dirs{dirname ($one_file) . '/.libs'} = CLEAN;
- $output_rules .= &file_contents ('program',
- $where,
- PROGRAM => $one_file,
- XPROGRAM => $xname,
- XLINK => $xlink,
- VERBOSE => $vlink,
- EXEEXT => '$(EXEEXT)');
+ $output_rules .= file_contents ('program',
- $where,
- PROGRAM => $one_file,
- XPROGRAM => $xname,
- XLINK => $xlink,
- VERBOSE => $vlink,
- DIRSTAMP => $dirstamp,
- EXEEXT => '$(EXEEXT)');
++ $where,
++ PROGRAM => $one_file,
++ XPROGRAM => $xname,
++ XLINK => $xlink,
++ VERBOSE => $vlink,
++ EXEEXT => '$(EXEEXT)');
if ($seen_libobjs || $seen_global_libobjs)
{
reject_var ($xlib . '_LDADD',
"use '${xlib}_LIBADD', not '${xlib}_LDADD'");
- &handle_source_transform ($xlib, $onelib, $obj, $where,
- NONLIBTOOL => 1, LIBTOOL => 0);
- # Make sure we at look at this.
- set_seen ($xlib . '_DEPENDENCIES');
- set_seen ('EXTRA_' . $xlib . '_DEPENDENCIES');
-
+ 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 $dirstamp = require_build_directory_maybe ($onelib);
my $verbose = verbose_flag ('AR');
- my $silent = silent_flag ();
- $output_rules .= &file_contents ('library',
- $where,
- VERBOSE => $verbose,
- LIBRARY => $onelib,
- XLIBRARY => $xlib);
+ $output_rules .= file_contents ('library',
+ $where,
+ VERBOSE => $verbose,
- SILENT => $silent,
+ LIBRARY => $onelib,
- XLIBRARY => $xlib,
- DIRSTAMP => $dirstamp);
++ XLIBRARY => $xlib);
if ($seen_libobjs)
{
}
}
- # If the resulting library lies in a subdirectory,
- # make sure this directory will exist.
- my $dirstamp = require_build_directory_maybe ($onelib);
-
- # Remember to cleanup .libs/ in this directory.
- my $dirname = dirname $onelib;
- $libtool_clean_directories{$dirname} = 1;
+ $clean_dirs{dirname ($onelib) . '/.libs'} = CLEAN;
- $output_rules .= &file_contents ('ltlibrary',
- $where,
- LTLIBRARY => $onelib,
- XLTLIBRARY => $xlib,
- RPATH => $rpath,
- XLINK => $xlink,
- VERBOSE => $vlink);
+ $output_rules .= file_contents ('ltlibrary',
+ $where,
+ LTLIBRARY => $onelib,
+ XLTLIBRARY => $xlib,
+ RPATH => $rpath,
+ XLINK => $xlink,
- VERBOSE => $vlink,
- DIRSTAMP => $dirstamp);
++ VERBOSE => $vlink);
if ($seen_libobjs)
{
if (var ($xlib . '_LIBADD'))
}
}
-# See if any _SOURCES variable were misspelled.
-sub check_typos ()
-{
- # It is ok if the user sets this particular variable.
- set_seen 'AM_LDFLAGS';
-
- foreach my $primary ('SOURCES', 'LIBADD', 'LDADD', 'LDFLAGS', 'DEPENDENCIES')
- {
- foreach my $var (variables $primary)
- {
- my $varname = $var->name;
- # A configure variable is always legitimate.
- next if exists $configure_vars{$varname};
-
- for my $cond ($var->conditions->conds)
- {
- $varname =~ /^(?:EXTRA_)?(?:nobase_)?(?:dist_|nodist_)?(.*)_[[:alnum:]]+$/;
- msg_var ('syntax', $var, "variable '$varname' is defined but no"
- . " program or\nlibrary has '$1' as canonical name"
- . " (possible typo)")
- unless $var->rdef ($cond)->seen;
- }
- }
- }
-}
-
# 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
}
# 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 ()
-{
- my @config;
- foreach my $spec (@config_headers)
- {
- my ($out, @ins) = split_config_file_spec ($spec);
- foreach my $in (@ins)
- {
- # If the config header source is in this directory,
- # require it.
- push @config, basename ($in)
- if $relative_dir eq dirname ($in);
- }
- }
-
- define_variable ('am__tagged_files',
- '$(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)'
- . "@config", INTERNAL);
-
- if (rvar('am__tagged_files')->value_as_list_recursive
- || var ('ETAGS_ARGS') || var ('SUBDIRS'))
- {
- $output_rules .= file_contents ('tags', new Automake::Location);
- set_seen 'TAGS_DEPENDENCIES';
- }
- else
- {
- reject_var ('TAGS_DEPENDENCIES',
- "it doesn't make sense to define 'TAGS_DEPENDENCIES'"
- . " without\nsources or 'ETAGS_ARGS'");
- # Every Makefile must define some sort of TAGS rule.
- # Otherwise, it would be possible for a top-level "make TAGS"
- # to fail because some subdirectory failed. Ditto ctags and
- # cscope.
- $output_rules .=
- "tags TAGS:\n\n" .
- "ctags CTAGS:\n\n" .
- "cscope cscopelist:\n\n";
- }
-}
-
-
# user_phony_rule ($NAME)
# -----------------------
# Return false if rule $NAME does not exist. Otherwise,
}
-# ($REGEN, @DEPENDENCIES)
-# scan_aclocal_m4
-# ---------------
-# If aclocal.m4 creation is automated, return the list of its dependencies.
+# $REGEN
- # &scan_aclocal_m4
++# scan_aclocal_m4()
+# ----------------
+# If aclocal.m4 creation is automated, return "aclocal.m4",
+# otherwise return 0.
sub scan_aclocal_m4 ()
{
my $regen_aclocal = 0;
return @res;
}
+sub handle_config_headers ()
+{
+ my (@config_h_local, @config_h_nonlocal, @config_hin_local);
+ foreach my $spec (@config_headers)
+ {
+ my ($out, @ins) = split_config_file_spec ($spec);
+ if ($relative_dir eq dirname ($out))
+ {
+ push @config_h_local, basename ($out);
+ }
+ else
+ {
+ push @config_h_nonlocal, "\$(top_builddir)/$out";
+ }
+ foreach my $in (@ins)
+ {
+ push @config_hin_local, '$(srcdir)/' . basename ($in)
+ if $relative_dir eq dirname ($in);
+ }
+ }
+ define_variable ('am.config-hdr.local', INTERNAL, @config_h_local);
+ define_variable ('am.config-hdr.non-local', INTERNAL, @config_h_nonlocal);
+ define_variable ('am.config-hdr.local.in', INTERNAL, @config_hin_local);
+ define_variable ('AM_CONFIG_HEADERS', INTERNAL,
+ qw/$(am.config-hdr.local) $(am.config-hdr.non-local)/);
+}
- # &handle_configure ($MAKEFILE, @INPUTS)
- # --------------------------------------
-
-# handle_configure ($MAKEFILE_AM, $MAKEFILE_IN, $MAKEFILE, @INPUTS)
-# -----------------------------------------------------------------
++# handle_configure ($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) = @_;
+ my ($makefile, @inputs) = @_;
prog_error 'empty @inputs'
unless @inputs;
}
# Handle footer elements.
- sub handle_footer
+ sub handle_footer ()
{
- reject_rule ('.SUFFIXES',
- "use variable 'SUFFIXES', not target '.SUFFIXES'");
-
- # Note: AIX 4.1 /bin/make will fail if any suffix rule appears
- # before .SUFFIXES. So we make sure that .SUFFIXES appears before
- # anything else, by sticking it right after the default: target.
- $output_header .= ".SUFFIXES:\n";
- my $suffixes = var 'SUFFIXES';
- my @suffixes = Automake::Rule::suffixes;
- if (@suffixes || $suffixes)
- {
- # Make sure SUFFIXES has unique elements. Sort them to ensure
- # the output remains consistent. However, $(SUFFIXES) is
- # always at the start of the list, unsorted. This is done
- # because make will choose rules depending on the ordering of
- # suffixes, and this lets the user have some control. Push
- # actual suffixes, and not $(SUFFIXES). Some versions of make
- # do not like variable substitutions on the .SUFFIXES line.
- my @user_suffixes = ($suffixes
- ? $suffixes->value_as_list_recursive : ());
+ # FIXME: maybe display a warning if the obsolescent $(SUFFIXES)
+ # FIXME: variable is used? Currently, we don't do that, to preserve
+ # FIXME: better compatibility with mainline Automake.
+ $output_trailer .= file_contents ('footer', new Automake::Location);
+}
- my %suffixes = map { $_ => 1 } @suffixes;
- delete @suffixes{@user_suffixes};
+# Generate helper targets for user recursion, where needed.
+sub handle_user_recursion ()
+{
+ return unless @extra_recursive_targets;
- $output_header .= (".SUFFIXES: "
- . join (' ', @user_suffixes, sort keys %suffixes)
- . "\n");
+ define_variable ('am.recurs.extra-targets', INTERNAL,
+ map { "$_-recursive" } @extra_recursive_targets);
+ my $aux = var ('SUBDIRS') ? 'recursive' : 'am';
+ foreach my $target (@extra_recursive_targets)
+ {
+ # This allows the default target's rules to be overridden in
+ # Makefile.am.
+ user_phony_rule ($target);
+ depend ("$target", "$target-$aux");
+ depend ("$target-am", "$target-local");
+ # Every user-defined recursive target 'foo' *must* have a valid
+ # 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");
}
-
- $output_trailer .= file_contents ('footer', new Automake::Location);
}
-
-# Generate 'make install' rules.
-sub handle_install ()
+sub handle_clean ()
{
- $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' : ''),
- am__installdirs => variable_value ('am__installdirs') || '');
-}
-
-
-# Deal with all and all-am.
-sub handle_all ($)
-{
- my ($makefile) = @_;
-
- # Output 'all-am'.
-
- # Put this at the beginning for the sake of non-GNU makes. This
- # is still wrong if these makes can run parallel jobs. But it is
- # right enough.
- unshift (@all, basename ($makefile));
-
- foreach my $spec (@config_headers)
- {
- my ($out, @ins) = split_config_file_spec ($spec);
- push (@all, basename ($out))
- if dirname ($out) eq $relative_dir;
- }
+ my (%f, %d);
- # Install 'all' hooks.
- push (@all, "all-local")
- if user_phony_rule "all-local";
+ my @fkeys = keys %clean_files;
+ $f{mostly} = [ grep { $clean_files{$_} == MOSTLY_CLEAN } @fkeys ];
+ $f{normal} = [ grep { $clean_files{$_} == CLEAN } @fkeys ];
+ $f{dist} = [ grep { $clean_files{$_} == DIST_CLEAN } @fkeys ];
+ $f{maint} = [ grep { $clean_files{$_} == MAINTAINER_CLEAN } @fkeys ];
- pretty_print_rule ("all-am:", "\t\t", @all);
- depend ('.PHONY', 'all-am', 'all');
+ my @dkeys = keys %clean_dirs;
+ $d{mostly} = [ grep { $clean_dirs{$_} == MOSTLY_CLEAN } @dkeys ];
+ $d{normal} = [ grep { $clean_dirs{$_} == CLEAN } @dkeys ];
+ $d{dist} = [ grep { $clean_dirs{$_} == DIST_CLEAN } @dkeys ];
+ $d{maint} = [ grep { $clean_dirs{$_} == MAINTAINER_CLEAN } @dkeys ];
-
- # Output 'all'.
-
- my @local_headers = ();
- push @local_headers, '$(BUILT_SOURCES)'
- if var ('BUILT_SOURCES');
- foreach my $spec (@config_headers)
- {
- my ($out, @ins) = split_config_file_spec ($spec);
- push @local_headers, basename ($out)
- if dirname ($out) eq $relative_dir;
- }
-
- if (@local_headers)
- {
- # We need to make sure config.h is built before we recurse.
- # We also want to make sure that built sources are built
- # before any ordinary 'all' targets are run. We can't do this
- # by changing the order of dependencies to the "all" because
- # that breaks when using parallel makes. Instead we handle
- # things explicitly.
- $output_all .= ("all: @local_headers"
- . "\n\t"
- . '$(MAKE) $(AM_MAKEFLAGS) '
- . (var ('SUBDIRS') ? 'all-recursive' : 'all-am')
- . "\n\n");
- depend ('.MAKE', 'all');
- }
- else
- {
- $output_all .= "all: " . (var ('SUBDIRS')
- ? 'all-recursive' : 'all-am') . "\n\n";
- }
-}
-
-# Generate helper targets for user recursion, where needed.
-sub handle_user_recursion ()
-{
- return unless @extra_recursive_targets;
-
- define_pretty_variable ('am__extra_recursive_targets', TRUE, INTERNAL,
- map { "$_-recursive" } @extra_recursive_targets);
- my $aux = var ('SUBDIRS') ? 'recursive' : 'am';
- foreach my $target (@extra_recursive_targets)
+ foreach my $kind (qw/mostly normal dist maint/)
{
- # This allows the default target's rules to be overridden in
- # Makefile.am.
- user_phony_rule ($target);
- depend ("$target", "$target-$aux");
- depend ("$target-am", "$target-local");
- # Every user-defined recursive target 'foo' *must* have a valid
- # 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:", '', '');
- # $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");
+ define_variable ("am.clean.$kind.f.auto", INTERNAL, @{$f{$kind}});
+ define_variable ("am.clean.$kind.d.auto", INTERNAL, @{$d{$kind}});
}
-}
-
-
-# do_check_merge_target ()
-# ------------------------
-# Handle check merge target specially.
-sub do_check_merge_target ()
-{
- # Include user-defined local form of target.
- push @check_tests, 'check-local'
- if user_phony_rule 'check-local';
-
- # The check target must depend on the local equivalent of
- # 'all', to ensure all the primary targets are built. Then it
- # must build the local check rules.
- $output_rules .= "check-am: all-am\n";
- if (@check)
- {
- pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ", @check);
- depend ('.MAKE', 'check-am');
- }
-
- if (@check_tests)
- {
- pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
- @check_tests);
- depend ('.MAKE', 'check-am');
- }
-
- depend '.PHONY', 'check', 'check-am';
- # Handle recursion. We have to honor BUILT_SOURCES like for 'all:'.
- $output_rules .= ("check: "
- . (var ('BUILT_SOURCES')
- ? "\$(BUILT_SOURCES)\n\t\$(MAKE) \$(AM_MAKEFLAGS) "
- : '')
- . (var ('SUBDIRS') ? 'check-recursive' : 'check-am')
- . "\n");
- depend ('.MAKE', 'check')
- if var ('BUILT_SOURCES');
-}
-
-# handle_clean ($MAKEFILE)
-# ------------------------
-# Handle all 'clean' targets.
-sub handle_clean ($)
-{
- my ($makefile) = @_;
-
- # Clean the files listed in user variables if they exist.
- $clean_files{'$(MOSTLYCLEANFILES)'} = MOSTLY_CLEAN
- if var ('MOSTLYCLEANFILES');
- $clean_files{'$(CLEANFILES)'} = CLEAN
- if var ('CLEANFILES');
- $clean_files{'$(DISTCLEANFILES)'} = DIST_CLEAN
- if var ('DISTCLEANFILES');
- $clean_files{'$(MAINTAINERCLEANFILES)'} = MAINTAINER_CLEAN
- if var ('MAINTAINERCLEANFILES');
-
- # Built sources are automatically removed by maintainer-clean.
- $clean_files{'$(BUILT_SOURCES)'} = MAINTAINER_CLEAN
- if var ('BUILT_SOURCES');
-
- # Compute a list of "rm"s to run for each target.
- my %rms = (MOSTLY_CLEAN, [],
- CLEAN, [],
- DIST_CLEAN, [],
- MAINTAINER_CLEAN, []);
-
- foreach my $file (keys %clean_files)
- {
- my $when = $clean_files{$file};
- prog_error 'invalid entry in %clean_files'
- unless exists $rms{$when};
- my $rm = "rm -f $file";
- # If file is a variable, make sure when don't call 'rm -f' without args.
- $rm ="test -z \"$file\" || $rm"
- if ($file =~ /^\s*\$(\(.*\)|\{.*\})\s*$/);
-
- push @{$rms{$when}}, "\t-$rm\n";
- }
-
- $output_rules .= file_contents
- ('clean',
- new Automake::Location,
- MOSTLYCLEAN_RMS => join ('', sort @{$rms{&MOSTLY_CLEAN}}),
- CLEAN_RMS => join ('', sort @{$rms{&CLEAN}}),
- DISTCLEAN_RMS => join ('', sort @{$rms{&DIST_CLEAN}}),
- MAINTAINER_CLEAN_RMS => join ('', sort @{$rms{&MAINTAINER_CLEAN}}),
- MAKEFILE => basename $makefile,
- );
+ verbatim ('clean');
}
}
}
- sub handle_tests
-
-# handle_tests_dejagnu ()
-# -----------------------
-sub handle_tests_dejagnu ()
-{
- push (@check_tests, 'check-DEJAGNU');
- $output_rules .= file_contents ('dejagnu', new Automake::Location);
-}
-
-sub handle_per_suffix_test ($%)
-{
- my ($test_suffix, %transform) = @_;
- my ($pfx, $generic, $am_exeext);
- if ($test_suffix eq '')
- {
- $pfx = '';
- $generic = 0;
- $am_exeext = 'FALSE';
- }
- else
- {
- prog_error ("test suffix '$test_suffix' lacks leading dot")
- unless $test_suffix =~ m/^\.(.*)/;
- $pfx = uc ($1) . '_';
- $generic = 1;
- $am_exeext = exists $configure_vars{'EXEEXT'} ? 'am__EXEEXT'
- : 'FALSE';
- }
- # The "test driver" program, deputed to handle tests protocol used by
- # test scripts. By default, it's assumed that no protocol is used, so
- # we fall back to the old behaviour, implemented by the 'test-driver'
- # auxiliary script.
- if (! var "${pfx}LOG_DRIVER")
- {
- require_conf_file ("parallel-tests", FOREIGN, 'test-driver');
- define_variable ("${pfx}LOG_DRIVER",
- "\$(SHELL) $am_config_aux_dir/test-driver",
- INTERNAL);
- }
- my $driver = '$(' . $pfx . 'LOG_DRIVER)';
- my $driver_flags = '$(AM_' . $pfx . 'LOG_DRIVER_FLAGS)'
- . ' $(' . $pfx . 'LOG_DRIVER_FLAGS)';
- my $compile = "${pfx}LOG_COMPILE";
- define_variable ($compile,
- '$(' . $pfx . 'LOG_COMPILER)'
- . ' $(AM_' . $pfx . 'LOG_FLAGS)'
- . ' $(' . $pfx . 'LOG_FLAGS)',
- INTERNAL);
- $output_rules .= file_contents ('check2', new Automake::Location,
- GENERIC => $generic,
- DRIVER => $driver,
- DRIVER_FLAGS => $driver_flags,
- COMPILE => '$(' . $compile . ')',
- EXT => $test_suffix,
- am__EXEEXT => $am_exeext,
- %transform);
-}
-
-# is_valid_test_extension ($EXT)
-# ------------------------------
-# Return true if $EXT can appear in $(TEST_EXTENSIONS), return false
-# otherwise.
-sub is_valid_test_extension ($)
-{
- my $ext = shift;
- return 1
- if ($ext =~ /^\.[a-zA-Z_][a-zA-Z0-9_]*$/);
- return 1
- if (exists $configure_vars{'EXEEXT'} && $ext eq subst ('EXEEXT'));
- return 0;
-}
-
-# Handle TESTS variable and other checks.
+ sub handle_tests ()
{
if (option 'dejagnu')
{
# Note that the calls to these functions are computed, so don't bother
# searching for their precise names in the source.
-# This is just a convenience function that can be used to determine
-# when a subdir object should be used.
-sub lang_sub_obj ()
-{
- return option 'subdir-objects' ? LANG_SUBDIR : LANG_PROCESS;
-}
+# Header files are simply ignored.
+sub lang_header_ignore { 1; }
-# Rewrite a single header file.
-sub lang_header_rewrite
+# Vala '.vapi' are a kind of header files as well, and should
+# not be processed into compilation rules.
- sub lang_vala_ignore
++sub lang_vala_ignore ($$$)
{
- # Header files are simply ignored.
- return LANG_IGNORE;
+ my ($directory, $base, $ext) = @_;
+ return ($ext =~ m/\.vapi$/ ? 1 : 0);
}
# Rewrite a single Vala source file.
--sub lang_vala_rewrite
++sub lang_vala_rewrite ($$$)
{
my ($directory, $base, $ext) = @_;
-
- (my $newext = $ext) =~ s/vala$/c/;
- return (LANG_SUBDIR, $newext);
+ $ext =~ s/vala$/c/;
+ return $ext;
}
# Rewrite a single yacc/yacc++ file.
--sub lang_yacc_rewrite
++sub lang_yacc_rewrite ($$$)
{
my ($directory, $base, $ext) = @_;
-
- my $r = lang_sub_obj;
- (my $newext = $ext) =~ tr/y/c/;
- return ($r, $newext);
+ $ext =~ tr/y/c/;
+ return $ext;
+}
- sub lang_yaccxx_rewrite { lang_yacc_rewrite (@_); };
++sub lang_yaccxx_rewrite ($$$)
++{
++ lang_yacc_rewrite (shift, shift, shift);
+ }
-sub lang_yaccxx_rewrite { lang_yacc_rewrite (@_); };
# Rewrite a single lex/lex++ file.
--sub lang_lex_rewrite
++sub lang_lex_rewrite ($$$)
{
my ($directory, $base, $ext) = @_;
-
- my $r = lang_sub_obj;
- (my $newext = $ext) =~ tr/l/c/;
- return ($r, $newext);
+ $ext =~ tr/l/c/;
+ return $ext;
}
--sub lang_lexxx_rewrite { lang_lex_rewrite (@_); };
-
-# Rewrite a single Java file.
-sub lang_java_rewrite
++sub lang_lexxx_rewrite ($$$)
+ {
- return LANG_SUBDIR;
++ lang_lex_rewrite (shift, shift, shift);
+ }
# The lang_X_finish functions are called after all source file
# processing is done. Each should handle defining rules for the
# 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) = @_;
+ my @names =
+ (
+ keys %known_programs,
+ keys %known_libraries,
+ keys %known_ltlibraries,
+ );
- foreach my $prog (keys %known_programs)
- {
- lang_vala_finish_target ($self, $prog);
- }
-
- while (my ($name) = each %known_libraries)
+ foreach my $name (@names)
{
lang_vala_finish_target ($self, $name);
}
"$condstr${header}: $output\n"
# Recover from removal of $header
. "$condstr\t\@if test ! -f \$@; then rm -f $output; else :; fi\n"
- . "$condstr\t\@if test ! -f \$@; then \$(MAKE) \$(AM_MAKEFLAGS) $output; else :; fi\n";
+ . "$condstr\t\@if test ! -f \$@; then \$(MAKE) $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)
if $transform{'DIST_SOURCE'};
$clean_files{$output} = $transform{'DIST_SOURCE'} ? MAINTAINER_CLEAN : CLEAN;
}
- sub lang_yacc_lex_finish
-# This is a helper for both lex and yacc.
-sub yacc_lex_finish_helper ()
++sub lang_yacc_lex_finish ()
{
return if defined $language_scratch{'lex-yacc-done'};
$language_scratch{'lex-yacc-done'} = 1;
## ------------------------ ##
- # &define_cond_variable ($VAR, $COND, $WHERE, @VALUE)
- # -----------------------------------------------------
-# define_pretty_variable ($VAR, $COND, $WHERE, @VALUE)
++# define_cond_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
my $libtool_tag = '';
$libtool_tag = '--tag=' . $lang->libtool_tag . ' '
if $lang->libtool_tag && exists $libtool_tags{$lang->libtool_tag};
- &define_variable ($var, INTERNAL, $value);
- define_variable ($var, $value, INTERNAL);
++ define_variable ($var, INTERNAL, $value);
if (var ('LIBTOOL'))
{
my $verbose = define_verbose_libtool ();
- &define_variable ("LT$var", INTERNAL,
- "\$(LIBTOOL) $verbose $libtool_tag\$(AM_LIBTOOLFLAGS) "
- . "\$(LIBTOOLFLAGS) --mode=compile $value");
- define_variable ("LT$var",
- "\$(LIBTOOL) $verbose $libtool_tag\$(AM_LIBTOOLFLAGS)"
- . " \$(LIBTOOLFLAGS) --mode=compile $value",
- INTERNAL);
++ define_variable ("LT$var", INTERNAL,
++ "\$(LIBTOOL) $verbose $libtool_tag\$(AM_LIBTOOLFLAGS) "
++ . "\$(LIBTOOLFLAGS) --mode=compile $value");
}
define_verbose_tagvar ($lang->ccer || 'GEN');
}
$libtool_tag = '--tag=' . $lang->libtool_tag . ' '
if $lang->libtool_tag && exists $libtool_tags{$lang->libtool_tag};
# CCLD = $(CC).
- &define_variable ($lang->lder, INTERNAL, $lang->ld);
- define_variable ($lang->lder, $lang->ld, INTERNAL);
++ define_variable ($lang->lder, INTERNAL, $lang->ld);
# CCLINK = $(CCLD) blah blah...
my $link = '';
if (var ('LIBTOOL'))
# ----------------------------
# 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) =
- file_contents_internal (1, "$libdir/am/header-vars.am",
- new Automake::Location);
-
foreach my $var (sort keys %configure_vars)
{
- &define_configure_variable ($var);
+ define_configure_variable ($var);
}
-
- $output_vars .= $comments . $rules;
+ $output_vars .= verbatim ('header-vars');
}
# Read main am file.
return $_;
}
+# verbatim ($NAME)
+# ----------------
+# Load a "$libdir/am/$NAME.mk", stripping any '##'-style comment. No
+# extra parsing or post-processing is done (i.e., recognition of rules
+# declaration or of make variables definitions).
+# If used in scalar or list context, return the read makefile fragment.
+# While if used in void context, append it to the '$output_verbatim'
+# variable.
+sub verbatim ($)
+{
+ my $name = shift;
+ my $dir = "$config_aux_dir/am-ng";
+ my $file = "$dir/$name.mk";
+ my $text = slurp_makefile_fragment ("$libdir/am/$name.mk");
+ mkdir ($dir, 0755) if ! -d $dir;
+ my $fh = new Automake::XFile "> $file";
+ verb "creating $file";
+ print $fh $text;
+ my $out = "include \@top_srcdir\@/$file\n";
+ if (defined wantarray)
+ {
+ # Scalar or list context.
+ return $out;
+ }
+ else
+ {
+ # Void context
+ $output_verbatim .= $out;
+ return;
+ }
+}
# @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 ($%)
}
- # &push_required_file ($DIR, $FILE, $FULLFILE)
- # --------------------------------------------------
- sub push_required_file
+ # push_required_file ($DIR, $FILE, $FULLFILE)
-# -------------------------------------------------
++# -------------------------------------------
+ # Push the given file onto DIST_COMMON.
+ sub push_required_file ($$$)
{
my ($dir, $file, $fullfile) = @_;
}
- # &require_file_internal ($WHERE, $MYSTRICT, $DIRECTORY, @FILES)
- # --------------------------------------------------------------
-# require_file_internal ($WHERE, $MYSTRICT, $DIRECTORY, $QUEUE, @FILES)
-# ---------------------------------------------------------------------
++# require_file_internal ($WHERE, $MYSTRICT, $DIRECTORY, @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 ($$$@)
{
- my ($where, $mystrict, $dir, $queue, @files) = @_;
+ my ($where, $mystrict, $dir, @files) = @_;
return
unless $strictness >= $mystrict;
sub require_file ($$@)
{
my ($where, $mystrict, @files) = @_;
- require_file_internal ($where, $mystrict, $relative_dir, 0, @files);
+ require_file_internal ($where, $mystrict, $relative_dir, @files);
}
- # &require_file_with_macro ($COND, $MACRO, $MYSTRICT, @FILES)
- # -----------------------------------------------------------
+ # require_file_with_macro ($COND, $MACRO, $MYSTRICT, @FILES)
+ # ----------------------------------------------------------
sub require_file_with_macro ($$$@)
{
my ($cond, $macro, $mystrict, @files) = @_;
}
}
- # &require_conf_file ($WHERE, $MYSTRICT, @FILES)
- # ----------------------------------------------
-# 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;
- if (ref $where)
- {
- @serial_loc = (QUEUE_LOCATION, $where->serialize ());
- }
- else
- {
- @serial_loc = (QUEUE_STRING, $where);
- }
- $queue->enqueue ($key, $dir, @serial_loc, $mystrict, 0 + @files, @files);
-}
-
-# require_queued_file_check_or_copy ($QUEUE)
-# ------------------------------------------
-sub require_queued_file_check_or_copy ($)
-{
- my ($queue) = @_;
- my $where;
- my $dir = $queue->dequeue ();
- my $loc_key = $queue->dequeue ();
- if ($loc_key eq QUEUE_LOCATION)
- {
- $where = Automake::Location::deserialize ($queue);
- }
- elsif ($loc_key eq QUEUE_STRING)
- {
- $where = $queue->dequeue ();
- }
- else
- {
- prog_error "unexpected key $loc_key";
- }
- my $mystrict = $queue->dequeue ();
- my $nfiles = $queue->dequeue ();
- my @files;
- push @files, $queue->dequeue ()
- foreach (1 .. $nfiles);
- return
- unless $strictness >= $mystrict;
- foreach my $file (@files)
- {
- required_file_check_or_copy ($where, $config_aux_dir, $file);
- }
-}
-
+ # require_conf_file ($WHERE, $MYSTRICT, @FILES)
+ # ---------------------------------------------
# Looks in configuration path, as specified by AC_CONFIG_AUX_DIR.
sub require_conf_file ($$@)
{
################################################################
-# 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 ($)
-{
- my $directory = shift;
-
- return $directory_map{$directory} if exists $directory_map{$directory};
-
- my $cdir = File::Spec->canonpath ($directory);
-
- if (exists $directory_map{$cdir})
- {
- my $stamp = $directory_map{$cdir};
- $directory_map{$directory} = $stamp;
- return $stamp;
- }
-
- my $dirstamp = "$cdir/\$(am__dirstamp)";
-
- $directory_map{$directory} = $dirstamp;
- $directory_map{$cdir} = $dirstamp;
-
- # Set a variable for the dirstamp basename.
- define_pretty_variable ('am__dirstamp', TRUE, INTERNAL, '.dirstamp');
-
- # Directory must be removed by 'make distclean'.
- $clean_files{$dirstamp} = DIST_CLEAN;
-
- $output_rules .= ("$dirstamp:\n"
- . "\t\@\$(MKDIR_P) $directory\n"
- . "\t\@: > $dirstamp\n");
-
- return $dirstamp;
-}
-
-# 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 ($)
-{
- my $file = shift;
- my $directory = dirname ($file);
-
- if ($directory ne '.')
- {
- return require_build_directory ($directory);
- }
- else
- {
- return '';
- }
-}
-
-################################################################
-
-# Push a list of files onto dist_common.
+ # require_build_directory ($DIRECTORY)
+ # ------------------------------------
- sub push_dist_common
+# Push a list of files onto @dist_common.
+ sub push_dist_common (@)
{
prog_error "push_dist_common run after handle_dist"
if $handle_dist_run;