eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac'
if 0;
package Language;
use File::Basename ();
my $_bindir;
BEGIN
{
$_bindir = File::Basename::dirname($0);
(my $_datadir = '@datadir@') =~ s,^/usr,$_bindir/..,;
my $perllibdir = $ENV{'perllibdir'} || "$_datadir/@PACKAGE@-@APIVERSION@";
unshift @INC, (split '@PATH_SEPARATOR@', $perllibdir);
$ENV{'SHELL'} = '@SHELL@' if exists $ENV{'DJGPP'};
}
use Automake::Struct;
struct ( 'name' => "\$",
'Name' => "\$",
'config_vars' => '@',
'ansi' => "\$",
'pure' => "\$",
'autodep' => "\$",
'compiler' => "\$",
'compile' => "\$",
'compile_flag' => "\$",
'extensions' => '@',
'output_extensions' => "\$",
'flags' => "@",
'libtool_tag' => "\$",
'rule_file' => "\$",
'linker' => "\$",
'link' => "\$",
'lder' => "\$",
'ld' => "\$",
'output_flag' => "\$",
'_finish' => "\$",
'_target_hook' => "\$",
'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;
use Automake::General;
use Automake::XFile;
use Automake::Channels;
use Automake::ChannelDefs;
use Automake::Configure_ac;
use Automake::FileUtils;
use Automake::Location;
use Automake::Condition qw/TRUE FALSE/;
use Automake::DisjConditions;
use Automake::Options;
use Automake::Version;
use Automake::Variable;
use Automake::VarDef;
use Automake::Rule;
use Automake::RuleDef;
use Automake::Wrap 'makefile_wrap';
use File::Basename;
use File::Spec;
use Carp;
my $IGNORE_PATTERN = '^\s*##([^#\n].*)?\n';
my $WHITE_PATTERN = '^\s*' . "\$";
my $COMMENT_PATTERN = '^#';
my $TARGET_PATTERN='[$a-zA-Z_.@%][-.a-zA-Z0-9_(){}/$+@%]*';
my $RULE_PATTERN =
"^($TARGET_PATTERN(?:(?:\\\\\n|\\s)+$TARGET_PATTERN)*) *:([^=].*|)\$";
my $ASSIGNMENT_PATTERN = '^ *([^ \t=:+]*)\s*([:+]?)=\s*(.*)' . "\$";
my $GNITS_VERSION_PATTERN = '\d+\.\d+([a-z]|\.\d+)?(-[A-Za-z0-9]+)?';
my $IF_PATTERN = '^if\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*)\s*(?:#.*)?' . "\$";
my $ELSE_PATTERN =
'^else(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?' . "\$";
my $ENDIF_PATTERN =
'^endif(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?' . "\$";
my $PATH_PATTERN = '(\w|[+/.-])+';
my $INCLUDE_PATTERN = ('^include\s+'
. '((\$\(top_srcdir\)/' . $PATH_PATTERN . ')'
. '|(\$\(srcdir\)/' . $PATH_PATTERN . ')'
. '|([^/\$]' . $PATH_PATTERN . '))\s*(#.*)?' . "\$");
my $DASH_D_PATTERN = "(^|\\s)-d(\\s|\$)";
my $EXEC_DIR_PATTERN =
'^(?:bin|sbin|libexec|sysconf|localstate|lib|pkglib|.*exec.*)' . "\$";
use constant AC_CANONICAL_BUILD => 1;
use constant AC_CANONICAL_HOST => 2;
use constant AC_CANONICAL_TARGET => 3;
use constant MOSTLY_CLEAN => 0;
use constant CLEAN => 1;
use constant DIST_CLEAN => 2;
use constant MAINTAINER_CLEAN => 3;
my @libtool_files = qw(ltmain.sh config.guess config.sub);
my @libtool_sometimes = qw(ltconfig ltcf-c.sh ltcf-cxx.sh ltcf-gcj.sh);
my @common_files =
(qw(ABOUT-GNU ABOUT-NLS AUTHORS BACKLOG COPYING COPYING.DOC COPYING.LIB
COPYING.LESSER ChangeLog INSTALL NEWS README THANKS TODO
ansi2knr.1 ansi2knr.c compile config.guess config.rpath config.sub
depcomp elisp-comp install-sh libversion.in mdate-sh missing
mkinstalldirs py-compile texinfo.tex ylwrap),
@libtool_files, @libtool_sometimes);
my @common_sometimes =
qw(aclocal.m4 acconfig.h config.h.top config.h.bot configure
configure.ac configure.in stamp-vti);
my %standard_prefix =
map { $_ => 1 } (qw(bin data dataroot dvi exec html include info
lib libexec lisp localstate man man1 man2 man3
man4 man5 man6 man7 man8 man9 oldinclude pdf
pkgdatadir pkgincludedir pkglibdir ps sbin
sharedstate sysconf));
my $gen_copyright = "\
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
";
use constant LANG_IGNORE => 0;
use constant LANG_PROCESS => 1;
use constant LANG_SUBDIR => 2;
use constant COMPILE_LIBTOOL => 1;
use constant COMPILE_ORDINARY => 2;
use constant INTERNAL => new Automake::Location;
my $force_generation = 1;
my $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
my $add_missing = 0;
my $copy_missing = 0;
my $force_missing = 0;
my $configure_ac;
my %libsources = ();
my @config_headers = ();
my @config_links = ();
my $output_directory;
my @input_files = ();
my %output_files = ();
my @configure_input_files = ();
my @other_input_files = ();
my %ac_config_files_location = ();
my $config_aux_dir = '';
my $config_aux_dir_set_in_configure_ac = 0;
my $am_config_aux_dir = '';
my $config_libobj_dir = '';
my $seen_gettext = 0;
my $seen_gettext_external = 0;
my $ac_gettext_location;
my $seen_gettext_intl = 0;
my %libtool_tags = ();
my $libtool_new_api = 0;
my $seen_canonical = 0;
my $canonical_location;
my $seen_maint_mode;
my $package_version = '';
my $package_version_location;
my $seen_multilib = 0;
my $seen_cc_c_o = 0;
my %required_aux_file = ();
my $seen_init_automake = 0;
my $seen_automake_version = 0;
my %configure_vars = ();
my %ignored_configure_vars = ();
my @configure_deps = ();
my $configure_deps_greatest_timestamp = 0;
my %configure_cond = ();
my %extension_map = ();
my $configure_dist_common = '';
my %languages = ();
my %link_languages = ();
my %required_targets =
(
'all' => 1,
'dvi' => 1,
'pdf' => 1,
'ps' => 1,
'info' => 1,
'install-info' => 1,
'install' => 1,
'install-data' => 1,
'install-exec' => 1,
'uninstall' => 1,
'dvi-am' => 1,
'pdf-am' => 1,
'ps-am' => 1,
'info-am' => 1,
'install-data-am' => 1,
'install-exec-am' => 1,
'installcheck-am' => 1,
'uninstall-am' => 1,
'install-man' => 1,
);
my $automake_will_process_aux_dir = 0;
my $am_file = 'BUG';
my $am_file_name;
my $am_relative_dir;
my $in_file_name;
my $relative_dir;
my $topsrcdir;
my $output_deps_greatest_timestamp;
my $output_rules;
my $output_vars;
my $output_trailer;
my $output_all;
my $output_header;
my @cond_stack;
my @include_stack;
my @all;
my @check;
my @check_tests;
my %clean_files;
my %compile_clean_files;
my %libtool_clean_directories;
my @sources;
my @dist_sources;
my %object_map;
my %object_compilation_map;
my %directory_map;
my %dep_files;
my @dist_targets;
my %known_programs;
my %de_ansi_files;
my $all_target;
my %extension_seen;
my %language_scratch;
my %lang_specific_files;
my $handle_dist_run;
my %linkers_used;
my $need_link;
my $get_object_extension_was_run;
my %transformed_files;
my %am_file_cache;
sub var_SUFFIXES_trigger ($$)
{
my ($type, $value) = @_;
accept_extensions (split (' ', $value));
}
Automake::Variable::hook ('SUFFIXES', \&var_SUFFIXES_trigger);
sub register_language (%);
sub file_contents_internal ($$$%);
sub define_files_variable ($\@$$);
sub initialize_per_input ()
{
reset_local_duplicates ();
$am_file_name = '';
$am_relative_dir = '';
$in_file_name = '';
$relative_dir = '';
$output_deps_greatest_timestamp = 0;
$output_rules = '';
$output_vars = '';
$output_trailer = '';
$output_all = '';
$output_header = '';
Automake::Options::reset;
Automake::Variable::reset;
Automake::Rule::reset;
@cond_stack = ();
@include_stack = ();
@all = ();
@check = ();
@check_tests = ();
%clean_files = ();
@sources = ();
@dist_sources = ();
%object_map = ();
%object_compilation_map = ();
%directory_map = ();
%dep_files = ();
@dist_targets = ();
%known_programs = ();
%de_ansi_files = ();
$all_target = '';
%extension_seen = ();
%language_scratch = ();
%lang_specific_files = ();
$handle_dist_run = 0;
$need_link = 0;
$get_object_extension_was_run = 0;
%compile_clean_files = ();
%libtool_clean_directories = ('.' => 1);
%transformed_files = ();
}
register_language ('name' => 'c',
'Name' => 'C',
'config_vars' => ['CC'],
'ansi' => 1,
'autodep' => '',
'flags' => ['CFLAGS', 'CPPFLAGS'],
'compiler' => 'COMPILE',
'compile' => '$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)',
'lder' => 'CCLD',
'ld' => '$(CC)',
'linker' => 'LINK',
'link' => '$(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
'compile_flag' => '-c',
'libtool_tag' => 'CC',
'extensions' => ['.c'],
'_finish' => \&lang_c_finish);
register_language ('name' => 'cxx',
'Name' => 'C++',
'config_vars' => ['CXX'],
'linker' => 'CXXLINK',
'link' => '$(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
'autodep' => 'CXX',
'flags' => ['CXXFLAGS', 'CPPFLAGS'],
'compile' => '$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)',
'compiler' => 'CXXCOMPILE',
'compile_flag' => '-c',
'output_flag' => '-o',
'libtool_tag' => 'CXX',
'lder' => 'CXXLD',
'ld' => '$(CXX)',
'pure' => 1,
'extensions' => ['.c++', '.cc', '.cpp', '.cxx', '.C']);
register_language ('name' => 'objc',
'Name' => 'Objective C',
'config_vars' => ['OBJC'],
'linker' => 'OBJCLINK',
'link' => '$(OBJCLD) $(AM_OBJCFLAGS) $(OBJCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
'autodep' => 'OBJC',
'flags' => ['OBJCFLAGS', 'CPPFLAGS'],
'compile' => '$(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS)',
'compiler' => 'OBJCCOMPILE',
'compile_flag' => '-c',
'output_flag' => '-o',
'lder' => 'OBJCLD',
'ld' => '$(OBJC)',
'pure' => 1,
'extensions' => ['.m']);
register_language ('name' => 'upc',
'Name' => 'Unified Parallel C',
'config_vars' => ['UPC'],
'linker' => 'UPCLINK',
'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)',
'compiler' => 'UPCCOMPILE',
'compile_flag' => '-c',
'output_flag' => '-o',
'lder' => 'UPCLD',
'ld' => '$(UPC)',
'pure' => 1,
'extensions' => ['.upc']);
register_language ('name' => 'header',
'Name' => 'Header',
'extensions' => ['.h', '.H', '.hxx', '.h++', '.hh',
'.hpp', '.inc'],
'output_extensions' => sub { return () },
'_finish' => sub { });
register_language ('name' => 'yacc',
'Name' => 'Yacc',
'config_vars' => ['YACC'],
'flags' => ['YFLAGS'],
'compile' => '$(YACC) $(YFLAGS) $(AM_YFLAGS)',
'compiler' => 'YACCCOMPILE',
'extensions' => ['.y'],
'output_extensions' => sub { (my $ext = $_[0]) =~ tr/y/c/;
return ($ext,) },
'rule_file' => 'yacc',
'_finish' => \&lang_yacc_finish,
'_target_hook' => \&lang_yacc_target_hook,
'nodist_specific' => 1);
register_language ('name' => 'yaccxx',
'Name' => 'Yacc (C++)',
'config_vars' => ['YACC'],
'rule_file' => 'yacc',
'flags' => ['YFLAGS'],
'compiler' => 'YACCCOMPILE',
'compile' => '$(YACC) $(YFLAGS) $(AM_YFLAGS)',
'extensions' => ['.y++', '.yy', '.yxx', '.ypp'],
'output_extensions' => sub { (my $ext = $_[0]) =~ tr/y/c/;
return ($ext,) },
'_finish' => \&lang_yacc_finish,
'_target_hook' => \&lang_yacc_target_hook,
'nodist_specific' => 1);
register_language ('name' => 'lex',
'Name' => 'Lex',
'config_vars' => ['LEX'],
'rule_file' => 'lex',
'flags' => ['LFLAGS'],
'compile' => '$(LEX) $(LFLAGS) $(AM_LFLAGS)',
'compiler' => 'LEXCOMPILE',
'extensions' => ['.l'],
'output_extensions' => sub { (my $ext = $_[0]) =~ tr/l/c/;
return ($ext,) },
'_finish' => \&lang_lex_finish,
'_target_hook' => \&lang_lex_target_hook,
'nodist_specific' => 1);
register_language ('name' => 'lexxx',
'Name' => 'Lex (C++)',
'config_vars' => ['LEX'],
'rule_file' => 'lex',
'flags' => ['LFLAGS'],
'compile' => '$(LEX) $(LFLAGS) $(AM_LFLAGS)',
'compiler' => 'LEXCOMPILE',
'extensions' => ['.l++', '.ll', '.lxx', '.lpp'],
'output_extensions' => sub { (my $ext = $_[0]) =~ tr/l/c/;
return ($ext,) },
'_finish' => \&lang_lex_finish,
'_target_hook' => \&lang_lex_target_hook,
'nodist_specific' => 1);
register_language ('name' => 'asm',
'Name' => 'Assembler',
'config_vars' => ['CCAS', 'CCASFLAGS'],
'flags' => ['CCASFLAGS'],
'compile' => '$(CCAS) $(AM_CCASFLAGS) $(CCASFLAGS)',
'compiler' => 'CCASCOMPILE',
'compile_flag' => '-c',
'output_flag' => '-o',
'extensions' => ['.s'],
'_finish' => \&lang_c_finish);
register_language ('name' => 'cppasm',
'Name' => 'Preprocessed Assembler',
'config_vars' => ['CCAS', 'CCASFLAGS'],
'autodep' => 'CCAS',
'flags' => ['CCASFLAGS', 'CPPFLAGS'],
'compile' => '$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS)',
'compiler' => 'CPPASCOMPILE',
'compile_flag' => '-c',
'output_flag' => '-o',
'extensions' => ['.S'],
'_finish' => \&lang_c_finish);
register_language ('name' => 'f77',
'Name' => 'Fortran 77',
'config_vars' => ['F77'],
'linker' => 'F77LINK',
'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
'flags' => ['FFLAGS'],
'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS)',
'compiler' => 'F77COMPILE',
'compile_flag' => '-c',
'output_flag' => '-o',
'libtool_tag' => 'F77',
'lder' => 'F77LD',
'ld' => '$(F77)',
'pure' => 1,
'extensions' => ['.f', '.for']);
register_language ('name' => 'fc',
'Name' => 'Fortran',
'config_vars' => ['FC'],
'linker' => 'FCLINK',
'link' => '$(FCLD) $(AM_FCFLAGS) $(FCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
'flags' => ['FCFLAGS'],
'compile' => '$(FC) $(AM_FCFLAGS) $(FCFLAGS)',
'compiler' => 'FCCOMPILE',
'compile_flag' => '-c',
'output_flag' => '-o',
'lder' => 'FCLD',
'ld' => '$(FC)',
'pure' => 1,
'extensions' => ['.f90', '.f95']);
register_language ('name' => 'ppfc',
'Name' => 'Preprocessed Fortran',
'config_vars' => ['FC'],
'linker' => 'FCLINK',
'link' => '$(FCLD) $(AM_FCFLAGS) $(FCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
'lder' => 'FCLD',
'ld' => '$(FC)',
'flags' => ['FCFLAGS', 'CPPFLAGS'],
'compiler' => 'PPFCCOMPILE',
'compile' => '$(FC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS)',
'compile_flag' => '-c',
'output_flag' => '-o',
'libtool_tag' => 'FC',
'pure' => 1,
'extensions' => ['.F90','.F95']);
register_language ('name' => 'ppf77',
'Name' => 'Preprocessed Fortran 77',
'config_vars' => ['F77'],
'linker' => 'F77LINK',
'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
'lder' => 'F77LD',
'ld' => '$(F77)',
'flags' => ['FFLAGS', 'CPPFLAGS'],
'compiler' => 'PPF77COMPILE',
'compile' => '$(F77) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)',
'compile_flag' => '-c',
'output_flag' => '-o',
'libtool_tag' => 'F77',
'pure' => 1,
'extensions' => ['.F']);
register_language ('name' => 'ratfor',
'Name' => 'Ratfor',
'config_vars' => ['F77'],
'linker' => 'F77LINK',
'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
'lder' => 'F77LD',
'ld' => '$(F77)',
'flags' => ['RFLAGS', 'FFLAGS'],
'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)',
'compiler' => 'RCOMPILE',
'compile_flag' => '-c',
'output_flag' => '-o',
'libtool_tag' => 'F77',
'pure' => 1,
'extensions' => ['.r']);
register_language ('name' => 'java',
'Name' => 'Java',
'config_vars' => ['GCJ'],
'linker' => 'GCJLINK',
'link' => '$(GCJLD) $(AM_GCJFLAGS) $(GCJFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
'autodep' => 'GCJ',
'flags' => ['GCJFLAGS'],
'compile' => '$(GCJ) $(AM_GCJFLAGS) $(GCJFLAGS)',
'compiler' => 'GCJCOMPILE',
'compile_flag' => '-c',
'output_flag' => '-o',
'libtool_tag' => 'GCJ',
'lder' => 'GCJLD',
'ld' => '$(GCJ)',
'pure' => 1,
'extensions' => ['.java', '.class', '.zip', '.jar']);
sub err_am ($;%)
{
msg_am ('error', @_);
}
sub err_ac ($;%)
{
msg_ac ('error', @_);
}
sub msg_am ($$;%)
{
my ($channel, $msg, %opts) = @_;
msg $channel, "${am_file}.am", $msg, %opts;
}
sub msg_ac ($$;%)
{
my ($channel, $msg, %opts) = @_;
msg $channel, $configure_ac, $msg, %opts;
}
sub subst ($)
{
my ($text) = @_;
return '@' . $text . '@';
}
sub backname ($)
{
my ($file) = @_;
my @res;
foreach (split (/\//, $file))
{
next if $_ eq '.' || $_ eq '';
if ($_ eq '..')
{
pop @res;
}
else
{
push (@res, '..');
}
}
return join ('/', @res) || '.';
}
sub handle_options
{
my $var = var ('AUTOMAKE_OPTIONS');
if ($var)
{
if ($var->has_conditional_contents)
{
msg_var ('unsupported', $var,
"`AUTOMAKE_OPTIONS' cannot have conditional contents");
}
foreach my $locvals ($var->value_as_list_recursive (cond_filter => TRUE,
location => 1))
{
my ($loc, $value) = @$locvals;
return 1 if (process_option_list ($loc, $value))
}
}
if ($strictness == GNITS)
{
set_option ('readme-alpha', INTERNAL);
set_option ('std-options', INTERNAL);
set_option ('check-news', INTERNAL);
}
return 0;
}
sub shadow_unconditionally ($$)
{
my ($varname, $where) = @_;
my $var = var $varname;
if ($var->has_conditional_contents)
{
$varname = "am__${varname}_DIST";
my @files = uniq ($var->value_as_list_recursive);
define_pretty_variable ($varname, TRUE, $where, @files);
}
return "\$($varname)"
}
sub get_object_extension ($)
{
my ($extension) = @_;
$extension = '$U' . $extension
if option 'ansi2knr';
$get_object_extension_was_run = 1;
return $extension;
}
sub check_user_variables (@)
{
my @dont_override = @_;
foreach my $flag (@dont_override)
{
my $var = var $flag;
if ($var)
{
for my $cond ($var->conditions->conds)
{
if ($var->rdef ($cond)->owner == VAR_MAKEFILE)
{
msg_cond_var ('gnu', $cond, $flag,
"`$flag' is a user variable, "
. "you should not override it;\n"
. "use `AM_$flag' instead.");
}
}
}
}
}
sub handle_languages
{
if (! option 'no-dependencies')
{
if (&saw_sources_p (0) && keys %dep_files)
{
&define_variable ('depcomp',
"\$(SHELL) $am_config_aux_dir/depcomp",
INTERNAL);
&define_variable ('am__depfiles_maybe', 'depfiles', INTERNAL);
require_conf_file ("$am_file.am", FOREIGN, 'depcomp');
my @deplist = sort keys %dep_files;
$output_rules .= "\n";
foreach my $iter (@deplist)
{
$output_rules .= (subst ('AMDEP_TRUE')
. subst ('am__include')
. ' '
. subst ('am__quote')
. $iter
. subst ('am__quote')
. "\n");
}
my @depdirs = uniq (map { dirname ($_) } @deplist);
$output_rules .= &file_contents ('depend',
new Automake::Location,
DEPDIRS => "@depdirs");
}
}
else
{
&define_variable ('depcomp', '', INTERNAL);
&define_variable ('am__depfiles_maybe', '', INTERNAL);
}
my %done;
my $needs_c = 0;
foreach my $ext (sort keys %extension_seen)
{
next unless $extension_map{$ext};
my $lang = $languages{$extension_map{$ext}};
my $rule_file = $lang->rule_file || 'depend2';
my $pfx = $lang->autodep;
my $fpfx = ($pfx eq '') ? 'CC' : $pfx;
my ($AMDEP, $FASTDEP) =
(option 'no-dependencies' || $lang->autodep eq 'no')
? ('FALSE', 'FALSE') : ('AMDEP', "am__fastdep$fpfx");
my %transform = ('EXT' => $ext,
'PFX' => $pfx,
'FPFX' => $fpfx,
'AMDEP' => $AMDEP,
'FASTDEP' => $FASTDEP,
'-c' => $lang->compile_flag || '',
SUBDIROBJ => 0,
'DERIVED-EXT' => 'BUG',
DIST_SOURCE => 1,
);
if (((! option 'no-dependencies') && $lang->autodep ne 'no')
|| defined $lang->compile)
{
my $output_flag = $lang->output_flag || '';
$output_flag = '-o'
if (! $output_flag
&& $lang->name eq 'c'
&& option 'subdir-objects');
my $der_ext = (&{$lang->output_extensions} ($ext))[0];
my $depbase =
option ('subdir-objects') ? '$$depbase' : '$(DEPDIR)/$*';
$output_rules .=
file_contents ($rule_file,
new Automake::Location,
%transform,
GENERIC => 1,
'DERIVED-EXT' => $der_ext,
DEPBASE => $depbase,
BASE => '$*',
SOURCE => '$<',
OBJ => '$@',
OBJOBJ => '$@',
LTOBJ => '$@',
COMPILE => '$(' . $lang->compiler . ')',
LTCOMPILE => '$(LT' . $lang->compiler . ')',
-o => $output_flag,
SUBDIROBJ => !! option 'subdir-objects');
}
my %seen_files = ();
foreach my $file (@{$lang_specific_files{$lang->name}})
{
my ($derived, $source, $obj, $myext, %file_transform) = @$file;
next if defined $seen_files{$obj};
$seen_files{$obj} = 1;
prog_error ("found " . $lang->name .
" in handle_languages, but compiler not defined")
unless defined $lang->compile;
my $obj_compile = $lang->compile;
for my $flag (@{$lang->flags})
{
my $val = "${derived}_$flag";
$obj_compile =~ s/\(AM_$flag\)/\($val\)/
if set_seen ($val);
}
my $libtool_tag = '';
if ($lang->libtool_tag && exists $libtool_tags{$lang->libtool_tag})
{
$libtool_tag = '--tag=' . $lang->libtool_tag . ' '
}
my $ptltflags = "${derived}_LIBTOOLFLAGS";
$ptltflags = 'AM_LIBTOOLFLAGS' unless set_seen $ptltflags;
my $obj_ltcompile =
"\$(LIBTOOL) $libtool_tag\$($ptltflags) \$(LIBTOOLFLAGS) "
. "--mode=compile $obj_compile";
my $output_flag = $lang->output_flag || '-o';
my $depbase = dirname ($obj);
$depbase = ''
if $depbase eq '.';
$depbase .= '/'
unless $depbase eq '';
$depbase .= '$(DEPDIR)/' . basename ($obj);
my $objdir = dirname ($obj);
my $srcdir = dirname ($source);
if ($lang->ansi && $obj =~ /\$U/)
{
prog_error "`$obj' contains \$U, but `$source' doesn't."
if $source !~ /\$U/;
(my $source_ = $source) =~ s/\$U/_/g;
if ($objdir ne $srcdir)
{
(my $obj_ = $obj) =~ s/\$U/_/g;
(my $depbase_ = $depbase) =~ s/\$U/_/g;
$source_ = basename ($source_);
$output_rules .=
file_contents ($rule_file,
new Automake::Location,
%transform,
GENERIC => 0,
DEPBASE => $depbase_,
BASE => $obj_,
SOURCE => $source_,
OBJ => "$obj_$myext",
OBJOBJ => "$obj_.obj",
LTOBJ => "$obj_.lo",
COMPILE => $obj_compile,
LTCOMPILE => $obj_ltcompile,
-o => $output_flag,
%file_transform);
$obj =~ s/\$U//g;
$depbase =~ s/\$U//g;
$source =~ s/\$U//g;
}
}
$output_rules .=
file_contents ($rule_file,
new Automake::Location,
%transform,
GENERIC => 0,
DEPBASE => $depbase,
BASE => $obj,
SOURCE => $source,
OBJ => "$obj$myext",
OBJOBJ => "$obj.obj",
LTOBJ => "$obj.lo",
COMPILE => $obj_compile,
LTCOMPILE => $obj_ltcompile,
-o => $output_flag,
%file_transform);
}
next if defined $done{$lang};
$done{$lang} = 1;
my %lang = map { uc ($_) => 0 } keys %languages;
$lang{uc ($lang->name)} = 1;
$output_rules .= file_contents ('lang-compile',
new Automake::Location,
%transform, %lang);
$needs_c ||= ! $lang->pure;
define_compiler_variable ($lang)
if ($lang->compile);
define_linker_variable ($lang)
if ($lang->link);
require_variables ("$am_file.am", $lang->Name . " source seen",
TRUE, @{$lang->config_vars});
$lang->finish;
my @dont_override = @{$lang->flags};
push @dont_override, 'LDFLAGS' if $lang->link;
check_user_variables @dont_override;
}
$needs_c = 1
if $need_link || suffix_rules_count > 1;
if ($needs_c)
{
&define_compiler_variable ($languages{'c'})
unless defined $done{$languages{'c'}};
define_linker_variable ($languages{'c'});
}
}
sub append_exeext (&$)
{
my ($pred, $macro) = @_;
transform_variable_recursively
($macro, $macro, 'am__EXEEXT', 0, INTERNAL,
sub {
my ($subvar, $val, $cond, $full_cond) = @_;
$val .= '$(EXEEXT)'
if $val !~ /(?:\$\(EXEEXT\)$|^[@]\w+[@]$)/ && &$pred ($val);
return $val;
});
}
sub check_libobjs_sources
{
my ($one_file, $unxformed) = @_;
foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
'dist_EXTRA_', 'nodist_EXTRA_')
{
my @files;
my $varname = $prefix . $one_file . '_SOURCES';
my $var = var ($varname);
if ($var)
{
@files = $var->value_as_list_recursive;
}
elsif ($prefix eq '')
{
@files = ($unxformed . '.c');
}
else
{
next;
}
foreach my $file (@files)
{
err_var ($prefix . $one_file . '_SOURCES',
"automatically discovered file `$file' should not" .
" be explicitly mentioned")
if defined $libsources{$file};
}
}
}
sub handle_single_transform ($$$$$%)
{
my ($var, $topparent, $derived, $obj, $_file, %transform) = @_;
my @files = ($_file);
my @result = ();
my $nonansi_obj = $obj;
$nonansi_obj =~ s/\$U//g;
while (scalar @files > 0)
{
$_ = shift @files;
if (/^\@.*\@$/)
{
my $parent_msg = '';
$parent_msg = "\nand is referred to from `$topparent'"
if $topparent ne $var->name;
err_var ($var,
"`" . $var->name . "' includes configure substitution `$_'"
. $parent_msg . ";\nconfigure " .
"substitutions are not allowed in _SOURCES variables");
next;
}
next if ! /^(?:(.*)\/)?([^\/]*)($KNOWN_EXTENSIONS_PATTERN)$/;
my $full = $_;
my $directory = $1 || '';
my $base = $2;
my $extension = $3;
my $renamed = 0;
my ($linker, $object);
my $derived_source = 0;
my $aggregate = 'AM';
$extension = &derive_suffix ($extension, $nonansi_obj);
my $lang;
if ($extension_map{$extension} &&
($lang = $languages{$extension_map{$extension}}))
{
&saw_extension ($extension);
my $have_per_exec_flags = 0;
my @peflags = @{$lang->flags};
push @peflags, 'LIBTOOLFLAGS' if $nonansi_obj eq '.lo';
foreach my $flag (@peflags)
{
if (set_seen ("${derived}_$flag"))
{
$have_per_exec_flags = 1;
last;
}
}
my $subr = \&{'lang_' . $lang->name . '_rewrite'};
my ($r, $source_extension)
= &$subr ($directory, $base, $extension,
$nonansi_obj, $have_per_exec_flags, $var);
next if $r == LANG_IGNORE;
$linker = $lang->linker;
my $this_obj_ext;
if (defined $source_extension)
{
$this_obj_ext = $source_extension;
$derived_source = 1;
}
elsif ($lang->ansi)
{
$this_obj_ext = $obj;
}
else
{
$this_obj_ext = $nonansi_obj;
}
$object = $base . $this_obj_ext;
if ($have_per_exec_flags)
{
my $dname = $derived;
my $var = var ($derived . '_SHORTNAME');
if ($var)
{
$dname = $var->variable_value;
}
$object = $dname . '-' . $object;
prog_error ($lang->name . " flags defined without compiler")
if ! defined $lang->compile;
$renamed = 1;
}
if ($r == LANG_SUBDIR && $directory ne '')
{
$object = $directory . '/' . $object;
}
if ($renamed
|| ($directory ne '' && ! option 'subdir-objects')
|| ($lang->nodist_specific && ! $transform{'DIST_SOURCE'}))
{
my $obj_sans_ext = substr ($object, 0,
- length ($this_obj_ext));
my $full_ansi = $full;
if ($lang->ansi && option 'ansi2knr')
{
$full_ansi =~ s/$KNOWN_EXTENSIONS_PATTERN$/\$U$&/;
$obj_sans_ext .= '$U';
}
my @specifics = ($full_ansi, $obj_sans_ext,
($derived_source ? $this_obj_ext : '.o'));
if ($renamed)
{
unshift @specifics, $derived;
$aggregate = $derived;
}
else
{
unshift @specifics, 'AM';
}
push (@{$lang_specific_files{$lang->name}},
[@specifics, %transform]);
}
}
elsif ($extension eq $nonansi_obj)
{
$object = "$base$extension";
$object = "$directory/$object" if $directory ne '';
$linker = '';
}
else
{
next;
}
err_am "object `$object' created by `$full' and `$object_map{$object}'"
if (defined $object_map{$object}
&& $object_map{$object} ne $full);
my $comp_val = (($object =~ /\.lo$/)
? COMPILE_LIBTOOL : COMPILE_ORDINARY);
(my $comp_obj = $object) =~ s/\.lo$/.\$(OBJEXT)/;
if (defined $object_compilation_map{$comp_obj}
&& $object_compilation_map{$comp_obj} != 0
&& ($object_compilation_map{$comp_obj}
!= (COMPILE_LIBTOOL | COMPILE_ORDINARY))
&& $object_compilation_map{$comp_obj} != $comp_val)
{
err_am "object `$comp_obj' created both with libtool and without";
}
$object_compilation_map{$comp_obj} |= $comp_val;
if (defined $lang)
{
$lang->target_hook ($aggregate, $object, $full, %transform);
}
if ($derived_source)
{
prog_error ($lang->name . " has automatic dependency tracking")
if $lang->autodep ne 'no';
unshift (@files, $object);
&push_dist_common ($object)
unless ($topparent =~ /^(?:nobase_)?nodist_/);
next;
}
$linkers_used{$linker} = 1;
push (@result, $object);
if (! defined $object_map{$object})
{
my @dep_list = ();
$object_map{$object} = $full;
if ($object =~ /\//)
{
if ($lang && $lang->name eq 'java' && $object =~ /(\/|^)\.\.\//)
{
err_am "`$full' should not contain a `..' component";
}
$compile_clean_files{$object} = MOSTLY_CLEAN;
if ($object =~ /\.lo$/)
{
(my $xobj = $object) =~ s,lo$,\$(OBJEXT),;
$compile_clean_files{$xobj} = MOSTLY_CLEAN;
$libtool_clean_directories{$directory} = 1;
}
push (@dep_list, require_build_directory ($directory));
push (@dep_list,
require_build_directory ($directory . '/$(DEPDIR)'))
unless option 'no-dependencies';
}
&pretty_print_rule ($object . ':', "\t", @dep_list)
if scalar @dep_list > 0;
}
if ($lang && $lang->autodep ne 'no')
{
my $depfile = $object;
$depfile =~ s/\.([^.]*)$/.P$1/;
$depfile =~ s/\$\(OBJEXT\)$/o/;
$dep_files{dirname ($depfile) . '/$(DEPDIR)/'
. basename ($depfile)} = 1;
}
}
return @result;
}
sub define_objects_from_sources ($$$$$$$%)
{
my ($var, $objvar, $nodefine, $one_file,
$obj, $topparent, $where, %transform) = @_;
my $needlinker = "";
transform_variable_recursively
($var, $objvar, 'am__objects', $nodefine, $where,
sub {
my ($subvar, $val, $cond, $full_cond) = @_;
my @trans = handle_single_transform ($subvar, $topparent,
$one_file, $obj, $val,
%transform);
$needlinker = "true" if @trans;
return @trans;
});
return $needlinker;
}
sub handle_source_transform ($$$$%)
{
my ($one_file, $unxformed, $obj, $where, %transform) = @_;
my $linker = '';
return if reject_var ($one_file . '_OBJECTS',
$one_file . '_OBJECTS should not be defined');
my %used_pfx = ();
my $needlinker;
%linkers_used = ();
foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
'dist_EXTRA_', 'nodist_EXTRA_')
{
my $varname = $prefix . $one_file . "_SOURCES";
my $var = var $varname;
next unless $var;
my $xpfx = ($prefix eq '') ? 'am_' : $prefix;
$used_pfx{$xpfx} = 1
unless $prefix =~ /EXTRA_/;
push @sources, "\$($varname)";
push @dist_sources, shadow_unconditionally ($varname, $where)
unless (option ('no-dist') || $prefix =~ /^nodist_/);
$needlinker |=
define_objects_from_sources ($varname,
$xpfx . $one_file . '_OBJECTS',
$prefix =~ /EXTRA_/,
$one_file, $obj, $varname, $where,
DIST_SOURCE => ($prefix !~ /^nodist_/),
%transform);
}
if ($needlinker)
{
$linker ||= &resolve_linker (%linkers_used);
}
my @keys = sort keys %used_pfx;
if (scalar @keys == 0)
{
my $old_default_source = "$one_file.c";
(my $default_source = $unxformed) =~ s,(\.[^./\\]*)?$,.c,;
if ($old_default_source ne $default_source
&& (rule $old_default_source
|| rule '$(srcdir)/' . $old_default_source
|| rule '${srcdir}/' . $old_default_source
|| -f $old_default_source))
{
my $loc = $where->clone;
$loc->pop_context;
msg ('obsolete', $loc,
"the default source for `$unxformed' has been changed "
. "to `$default_source'.\n(Using `$old_default_source' for "
. "backward compatibility.)");
$default_source = $old_default_source;
}
if (rule '$(srcdir)/' . $default_source
|| rule '${srcdir}/' . $default_source)
{
$default_source = '$(srcdir)/' . $default_source;
}
&define_variable ($one_file . "_SOURCES", $default_source, $where);
push (@sources, $default_source);
push (@dist_sources, $default_source);
%linkers_used = ();
my (@result) =
handle_single_transform ($one_file . '_SOURCES',
$one_file . '_SOURCES',
$one_file, $obj,
$default_source, %transform);
$linker ||= &resolve_linker (%linkers_used);
define_pretty_variable ($one_file . '_OBJECTS', TRUE, $where, @result);
}
else
{
@keys = map { '$(' . $_ . $one_file . '_OBJECTS)' } @keys;
define_pretty_variable ($one_file . '_OBJECTS', TRUE, $where, @keys);
}
if ($linker eq '')
{
$need_link = 1;
}
return $linker;
}
sub handle_lib_objects
{
my ($xname, $varname) = @_;
my $var = var ($varname);
prog_error "handle_lib_objects: `$varname' undefined"
unless $var;
prog_error "handle_lib_objects: unexpected variable name `$varname'"
unless $varname =~ /^(.*)(?:LIB|LD)ADD$/;
my $prefix = $1 || 'AM_';
my $seen_libobjs = 0;
my $flagvar = 0;
transform_variable_recursively
($varname, $xname . '_DEPENDENCIES', 'am__DEPENDENCIES',
! $xname, INTERNAL,
sub {
my ($subvar, $val, $cond, $full_cond) = @_;
if ($val =~ /^-/)
{
if ($val !~ /^-[lL]/ &&
$val !~ /^-dl(?:pre)?open$/ &&
! $flagvar)
{
$flagvar = 1;
err_var ($var, "linker flags such as `$val' belong in "
. "`${prefix}LDFLAGS");
}
return ();
}
elsif ($val !~ /^\@.*\@$/)
{
return $val;
}
elsif ($val =~ /^\@(LT)?LIBOBJS\@$/)
{
handle_LIBOBJS ($subvar, $cond, $1);
$seen_libobjs = 1;
return $val;
}
elsif ($val =~ /^\@(LT)?ALLOCA\@$/)
{
handle_ALLOCA ($subvar, $cond, $1);
return $val;
}
else
{
return ();
}
});
return $seen_libobjs;
}
sub handle_LIBOBJS_or_ALLOCA ($)
{
my ($var) = @_;
my $dir = '';
if ($config_libobj_dir
&& $relative_dir ne $config_libobj_dir)
{
if (option 'subdir-objects')
{
$dir = "$config_libobj_dir/" if $config_libobj_dir ne '.';
$dir = "$topsrcdir/$dir" if $relative_dir ne '.';
define_variable ('LIBOBJDIR', "$dir", INTERNAL);
$clean_files{"\$($var)"} = MOSTLY_CLEAN;
$clean_files{"\$($var)"} = MOSTLY_CLEAN if $var =~ s/^LT//;
}
else
{
error ("`\$($var)' cannot be used outside `$dir' if"
. " `subdir-objects' is not set");
}
}
return $dir;
}
sub handle_LIBOBJS ($$$)
{
my ($var, $cond, $lt) = @_;
my $myobjext = $lt ? 'lo' : 'o';
$lt ||= '';
$var->requires_variables ("\@${lt}LIBOBJS\@ used", $lt . 'LIBOBJS')
if ! keys %libsources;
my $dir = handle_LIBOBJS_or_ALLOCA "${lt}LIBOBJS";
foreach my $iter (keys %libsources)
{
if ($iter =~ /\.[cly]$/)
{
&saw_extension ($&);
&saw_extension ('.c');
}
if ($iter =~ /\.h$/)
{
require_libsource_with_macro ($cond, $var, FOREIGN, $iter);
}
elsif ($iter ne 'alloca.c')
{
my $rewrite = $iter;
$rewrite =~ s/\.c$/.P$myobjext/;
$dep_files{$dir . '$(DEPDIR)/' . $rewrite} = 1;
$rewrite = "^" . quotemeta ($iter) . "\$";
my $bs = var ('BUILT_SOURCES');
if (! $bs || ! grep (/$rewrite/, $bs->value_as_list_recursive))
{
require_libsource_with_macro ($cond, $var, FOREIGN, $iter);
}
}
}
}
sub handle_ALLOCA ($$$)
{
my ($var, $cond, $lt) = @_;
my $myobjext = $lt ? 'lo' : 'o';
$lt ||= '';
my $dir = handle_LIBOBJS_or_ALLOCA "${lt}ALLOCA";
$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');
}
sub canonicalize
{
my ($string) = @_;
$string =~ tr/A-Za-z0-9_\@/_/c;
return $string;
}
sub check_canonical_spelling
{
my ($name, @suffixes) = @_;
my $xname = &canonicalize ($name);
if ($xname ne $name)
{
foreach my $xt (@suffixes)
{
reject_var ("$name$xt", "use `$xname$xt', not `$name$xt'");
}
}
return $xname;
}
sub handle_compile ()
{
return
unless $get_object_extension_was_run;
my $default_includes = '';
if (! option 'nostdinc')
{
my @incs = ('-I.');
my $var = var 'CONFIG_HEADER';
if ($var)
{
foreach my $hdr (split (' ', $var->variable_value))
{
push @incs, '-I' . dirname ($hdr);
}
}
$default_includes = ' ' . uniq (@incs) . subst ('am__isrc');
}
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";
if (option 'ansi2knr')
{
my ($ansi2knr_filename, $ansi2knr_where) = @{option 'ansi2knr'};
my $ansi2knr_dir = '';
require_variables ($ansi2knr_where, "option `ansi2knr' is used",
TRUE, "ANSI2KNR", "U");
if ($ansi2knr_filename eq 'ansi2knr')
{
require_file ($ansi2knr_where, FOREIGN,
'ansi2knr.c', 'ansi2knr.1');
unshift (@all, '$(ANSI2KNR)');
}
else
{
$ansi2knr_dir = dirname ($ansi2knr_filename);
}
$output_rules .= &file_contents ('ansi2knr',
new Automake::Location,
'ANSI2KNR-DIR' => $ansi2knr_dir);
}
}
sub handle_libtool
{
return unless var ('LIBTOOL');
require_conf_file_with_macro (TRUE, 'LIBTOOL', FOREIGN, @libtool_files)
if $relative_dir eq '.' && ! $libtool_new_api;
my @libtool_rms;
foreach my $item (sort keys %libtool_clean_directories)
{
my $dir = ($item eq '.') ? '' : "$item/";
push (@libtool_rms, "\t-rm -rf ${dir}.libs ${dir}_libs");
}
check_user_variables 'LIBTOOLFLAGS';
$output_rules .= &file_contents ('libtool',
new Automake::Location,
LTRMS => join ("\n", @libtool_rms));
}
sub handle_programs
{
my @proglist = &am_install_var ('progs', 'PROGRAMS',
'bin', 'sbin', 'libexec', 'pkglib',
'noinst', 'check');
return if ! @proglist;
my $seen_global_libobjs =
var ('LDADD') && &handle_lib_objects ('', 'LDADD');
foreach my $pair (@proglist)
{
my ($where, $one_file) = @$pair;
my $seen_libobjs = 0;
my $obj = get_object_extension '.$(OBJEXT)';
$one_file =~ s/\$\(EXEEXT\)$//;
$known_programs{$one_file} = $where;
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);
if (var ($xname . "_LDADD"))
{
$seen_libobjs = &handle_lib_objects ($xname, $xname . '_LDADD');
}
else
{
&define_variable ($xname . '_LDADD', '$(LDADD)', $where);
if (var ('LDADD'))
{
$seen_libobjs = &handle_lib_objects ($xname, 'LDADD');
}
}
reject_var ($xname . '_LIBADD',
"use `${xname}_LDADD', not `${xname}_LIBADD'");
set_seen ($xname . '_DEPENDENCIES');
set_seen ($xname . '_LDFLAGS');
my $xlink = &define_per_target_linker_variable ($linker, $xname);
my $dirstamp = require_build_directory_maybe ($one_file);
$output_rules .= &file_contents ('program',
$where,
PROGRAM => $one_file,
XPROGRAM => $xname,
XLINK => $xlink,
DIRSTAMP => $dirstamp,
EXEEXT => '$(EXEEXT)');
if ($seen_libobjs || $seen_global_libobjs)
{
if (var ($xname . '_LDADD'))
{
&check_libobjs_sources ($xname, $xname . '_LDADD');
}
elsif (var ('LDADD'))
{
&check_libobjs_sources ($xname, 'LDADD');
}
}
}
}
sub handle_libraries
{
my @liblist = &am_install_var ('libs', 'LIBRARIES',
'lib', 'pkglib', 'noinst', 'check');
return if ! @liblist;
my @prefix = am_primary_prefixes ('LIBRARIES', 0, 'lib', 'pkglib',
'noinst', 'check');
if (@prefix)
{
my $var = rvar ($prefix[0] . '_LIBRARIES');
$var->requires_variables ('library used', 'RANLIB');
}
&define_variable ('AR', 'ar', INTERNAL);
&define_variable ('ARFLAGS', 'cru', INTERNAL);
foreach my $pair (@liblist)
{
my ($where, $onelib) = @$pair;
my $seen_libobjs = 0;
my $bn = basename ($onelib);
if ($bn !~ /^lib.*\.a$/)
{
$bn =~ s/^(?:lib)?(.*?)(?:\.[^.]*)?$/lib$1.a/;
my $suggestion = dirname ($onelib) . "/$bn";
$suggestion =~ s|^\./||g;
msg ('error-gnu/warn', $where,
"`$onelib' is not a standard library name\n"
. "did you mean `$suggestion'?")
}
$where->push_context ("while processing library `$onelib'");
$where->set (INTERNAL->get);
my $obj = get_object_extension '.$(OBJEXT)';
my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES',
'_OBJECTS', '_DEPENDENCIES',
'_AR');
if (! var ($xlib . '_AR'))
{
&define_variable ($xlib . '_AR', '$(AR) $(ARFLAGS)', $where);
}
if (var ($xlib . '_LIBADD'))
{
if (&handle_lib_objects ($xlib, $xlib . '_LIBADD'))
{
$seen_libobjs = 1;
}
}
else
{
&define_variable ($xlib . "_LIBADD", '', $where);
}
reject_var ($xlib . '_LDADD',
"use `${xlib}_LIBADD', not `${xlib}_LDADD'");
set_seen ($xlib . '_DEPENDENCIES');
&handle_source_transform ($xlib, $onelib, $obj, $where,
NONLIBTOOL => 1, LIBTOOL => 0);
my $dirstamp = require_build_directory_maybe ($onelib);
$output_rules .= &file_contents ('library',
$where,
LIBRARY => $onelib,
XLIBRARY => $xlib,
DIRSTAMP => $dirstamp);
if ($seen_libobjs)
{
if (var ($xlib . '_LIBADD'))
{
&check_libobjs_sources ($xlib, $xlib . '_LIBADD');
}
}
}
}
sub handle_ltlibraries
{
my @liblist = &am_install_var ('ltlib', 'LTLIBRARIES',
'noinst', 'lib', 'pkglib', 'check');
return if ! @liblist;
my @prefix = am_primary_prefixes ('LTLIBRARIES', 0, 'lib', 'pkglib',
'noinst', 'check');
if (@prefix)
{
my $var = rvar ($prefix[0] . '_LTLIBRARIES');
$var->requires_variables ('Libtool library used', 'LIBTOOL');
}
my %instdirs = ();
my %instconds = ();
my %liblocations = ();
foreach my $key (@prefix)
{
(my $dir = $key) =~ s/^nobase_//;
my $var = rvar ($key . '_LTLIBRARIES');
$var->traverse_recursively
(sub
{
my ($var, $val, $cond, $full_cond) = @_;
my $hcond = $full_cond->human;
my $where = $var->rdef ($cond)->location;
if (exists $instconds{$val})
{
my ($msg, $acond) =
$instconds{$val}->ambiguous_p ($val, $full_cond);
if ($msg)
{
error ($where, $msg, partial => 1);
my $dirtxt = "installed in `$dir'";
$dirtxt = "built for `$dir'"
if $dir eq 'EXTRA' || $dir eq 'noinst' || $dir eq 'check';
my $dircond =
$full_cond->true ? "" : " in condition $hcond";
error ($where, "`$val' should be $dirtxt$dircond ...",
partial => 1);
my $hacond = $acond->human;
my $adir = $instdirs{$val}{$acond};
my $adirtxt = "installed in `$adir'";
$adirtxt = "built for `$adir'"
if ($adir eq 'EXTRA' || $adir eq 'noinst'
|| $adir eq 'check');
my $adircond = $acond->true ? "" : " in condition $hacond";
my $onlyone = ($dir ne $adir) ?
("\nLibtool libraries can be built for only one "
. "destination.") : "";
error ($liblocations{$val}{$acond},
"... and should also be $adirtxt$adircond.$onlyone");
return;
}
}
else
{
$instconds{$val} = new Automake::DisjConditions;
}
$instdirs{$val}{$full_cond} = $dir;
$liblocations{$val}{$full_cond} = $where;
$instconds{$val} = $instconds{$val}->merge ($full_cond);
},
sub
{
return ();
},
skip_ac_subst => 1);
}
foreach my $pair (@liblist)
{
my ($where, $onelib) = @$pair;
my $seen_libobjs = 0;
my $obj = get_object_extension '.lo';
my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS',
'_SOURCES', '_OBJECTS',
'_DEPENDENCIES');
my $libname_rx = '^lib.*\.la';
my $ldvar = var ("${xlib}_LDFLAGS") || var ('AM_LDFLAGS');
my $ldvar2 = var ('LDFLAGS');
if (($ldvar && grep (/-module/, $ldvar->value_as_list_recursive))
|| ($ldvar2 && grep (/-module/, $ldvar2->value_as_list_recursive)))
{
$libname_rx = '\.la';
}
my $bn = basename ($onelib);
if ($bn !~ /$libname_rx$/)
{
my $type = 'library';
if ($libname_rx eq '\.la')
{
$bn =~ s/^(lib|)(.*?)(?:\.[^.]*)?$/$1$2.la/;
$type = 'module';
}
else
{
$bn =~ s/^(?:lib)?(.*?)(?:\.[^.]*)?$/lib$1.la/;
}
my $suggestion = dirname ($onelib) . "/$bn";
$suggestion =~ s|^\./||g;
msg ('error-gnu/warn', $where,
"`$onelib' is not a standard libtool $type name\n"
. "did you mean `$suggestion'?")
}
$where->push_context ("while processing Libtool library `$onelib'");
$where->set (INTERNAL->get);
set_seen ($xlib . '_LDFLAGS');
set_seen ($xlib . '_DEPENDENCIES');
if (var ($xlib . '_LIBADD'))
{
if (&handle_lib_objects ($xlib, $xlib . '_LIBADD'))
{
$seen_libobjs = 1;
}
}
else
{
&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 $xlink = &define_per_target_linker_variable ($linker, $xlib);
my $rpathvar = "am_${xlib}_rpath";
my $rpath = "\$($rpathvar)";
foreach my $rcond ($instconds{$onelib}->conds)
{
my $val;
if ($instdirs{$onelib}{$rcond} eq 'EXTRA'
|| $instdirs{$onelib}{$rcond} eq 'noinst'
|| $instdirs{$onelib}{$rcond} eq 'check')
{
$val = '';
}
else
{
$val = ('-rpath $(' . $instdirs{$onelib}{$rcond} . 'dir)');
}
if ($rcond->true)
{
$rpath = $val;
}
else
{
define_pretty_variable ($rpathvar, $rcond, INTERNAL, $val);
}
}
my $dirstamp = require_build_directory_maybe ($onelib);
my $dirname = dirname $onelib;
$libtool_clean_directories{$dirname} = 1;
$output_rules .= &file_contents ('ltlibrary',
$where,
LTLIBRARY => $onelib,
XLTLIBRARY => $xlib,
RPATH => $rpath,
XLINK => $xlink,
DIRSTAMP => $dirstamp);
if ($seen_libobjs)
{
if (var ($xlib . '_LIBADD'))
{
&check_libobjs_sources ($xlib, $xlib . '_LIBADD');
}
}
}
}
sub check_typos ()
{
set_seen 'AM_LDFLAGS';
foreach my $primary ('SOURCES', 'LIBADD', 'LDADD', 'LDFLAGS', 'DEPENDENCIES')
{
foreach my $var (variables $primary)
{
my $varname = $var->name;
next if exists $configure_vars{$varname};
for my $cond ($var->conditions->conds)
{
$varname =~ /^(?:nobase_)?(?:dist_|nodist_)?(.*)_[[:alnum:]]+$/;
msg_var ('syntax', $var, "variable `$varname' is defined but no"
. " program or\nlibrary has `$1' as canonic name"
. " (possible typo)")
unless $var->rdef ($cond)->seen;
}
}
}
}
sub handle_scripts
{
&am_install_var ('-candist', 'scripts', 'SCRIPTS',
'bin', 'sbin', 'libexec', 'pkgdata',
'noinst', 'check');
}
sub scan_texinfo_file ($)
{
my ($filename) = @_;
my %clean_suffixes =
map { $_ => 1 } (qw(aux log toc tmp
cp cps
fn fns
ky kys
vr vrs
tp tps
pg pgs));
my $texi = new Automake::XFile "< $filename";
verb "reading $filename";
my ($outfile, $vfile);
while ($_ = $texi->getline)
{
if (/^\@setfilename +(\S+)/)
{
next if $outfile;
$outfile = $1;
if ($outfile =~ /\.([^.]+)$/ && $1 ne 'info')
{
error ("$filename:$.",
"output `$outfile' has unrecognized extension");
return;
}
}
elsif (/^\@include\s+(vers[^.]*\.texi)\s*$/)
{
$vfile = $1;
}
elsif (/^\@def(code)?index (\w+)/)
{
$clean_suffixes{$2} = 1;
$clean_suffixes{"$2s"} = 1;
}
elsif (/^\@syn(code)?index (\w+) (\w+)/)
{
delete $clean_suffixes{"$2s"};
$clean_suffixes{"$3s"} = 1;
}
}
if (! $outfile)
{
err_am "`$filename' missing \@setfilename";
return;
}
my $infobase = basename ($filename);
$infobase =~ s/\.te?xi(nfo)?$//;
return ($outfile, $vfile,
map { "$infobase.$_" } (sort keys %clean_suffixes));
}
sub output_texinfo_build_rules ($$$@)
{
my ($source, $dest, $insrc, @deps) = @_;
my ($spfx, $ssfx) = ($source =~ /^(.*?)(\.[^.]*)?$/);
my ($dpfx, $dsfx) = ($dest =~ /^(.*?)(\.[^.]*)?$/);
$ssfx ||= "";
$dsfx ||= "";
my $generic;
my $makeinfoflags;
my $sdir = dirname $source;
if ($sdir eq '.' && dirname ($dest) eq '.')
{
$generic = 1;
$makeinfoflags = '-I $(srcdir)';
}
else
{
$generic = 0;
$makeinfoflags = "-I $sdir -I \$(srcdir)/$sdir";
}
$generic = 0 unless $insrc;
my $generic_info = ($generic && $dsfx) ? 1 : 0;
my $dirstamp = require_build_directory_maybe ($dest);
my $dipfx = ($insrc ? '$(srcdir)/' : '') . $dpfx;
$output_rules .= file_contents ('texibuild',
new Automake::Location,
DEPS => "@deps",
DEST_PREFIX => $dpfx,
DEST_INFO_PREFIX => $dipfx,
DEST_SUFFIX => $dsfx,
DIRSTAMP => $dirstamp,
GENERIC => $generic,
GENERIC_INFO => $generic_info,
INSRC => $insrc,
MAKEINFOFLAGS => $makeinfoflags,
SOURCE => ($generic
? '$<' : $source),
SOURCE_INFO => ($generic_info
? '$<' : $source),
SOURCE_REAL => $source,
SOURCE_SUFFIX => $ssfx,
);
return ($dirstamp, "$dpfx.dvi", "$dpfx.pdf", "$dpfx.ps", "$dpfx.html");
}
sub handle_texinfo_helper ($)
{
my ($info_texinfos) = @_;
my (@infobase, @info_deps_list, @texi_deps);
my %versions;
my $done = 0;
my @texi_cleans;
my $d = var 'DISTCLEANFILES';
my $c = var 'CLEANFILES';
my @f = ();
push @f, $d->value_as_list_recursive (inner_expand => 1) if $d;
push @f, $c->value_as_list_recursive (inner_expand => 1) if $c;
@f = map { s|[^A-Za-z_0-9*\[\]\-]|\\$&|g; s|\*|[^/]*|g; $_; } @f;
my $user_cleaned_files = '^(?:' . join ('|', @f) . ')$';
foreach my $texi
($info_texinfos->value_as_list_recursive (inner_expand => 1))
{
my $infobase = $texi;
$infobase =~ s/\.(txi|texinfo|texi)$//;
if ($infobase eq $texi)
{
err_am "texinfo file `$texi' has unrecognized extension";
next;
}
push @infobase, $infobase;
my ($out_file, $vtexi, @clean_files) =
scan_texinfo_file ("$relative_dir/$texi")
or next;
push (@texi_cleans, @clean_files);
my $outdir = dirname ($texi) . '/';
$outdir = "" if $outdir eq './';
$out_file = $outdir . $out_file;
my $insrc = ($out_file =~ $user_cleaned_files) ? 0 : 1;
my $soutdir = '$(srcdir)/' . $outdir;
$outdir = $soutdir if $insrc;
@texi_deps = ();
push (@texi_deps, "$soutdir$vtexi") if $vtexi;
my $canonical = canonicalize ($infobase);
if (var ($canonical . "_TEXINFOS"))
{
push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
push_dist_common ('$(' . $canonical . '_TEXINFOS)');
}
my ($dirstamp, @cfiles) =
output_texinfo_build_rules ($texi, $out_file, $insrc, @texi_deps);
push (@texi_cleans, @cfiles);
push (@info_deps_list, $out_file);
if ($vtexi)
{
err_am ("`$vtexi', included in `$texi', "
. "also included in `$versions{$vtexi}'")
if defined $versions{$vtexi};
$versions{$vtexi} = $texi;
my $vti = ($done ? $done : 'vti');
++$done;
if ($config_aux_dir_set_in_configure_ac)
{
require_conf_file_with_macro (TRUE, 'info_TEXINFOS', FOREIGN,
'mdate-sh');
}
else
{
require_file_with_macro (TRUE, 'info_TEXINFOS',
FOREIGN, 'mdate-sh');
}
my $conf_dir;
if ($config_aux_dir_set_in_configure_ac)
{
$conf_dir = "$am_config_aux_dir/";
}
else
{
$conf_dir = '$(srcdir)/';
}
$output_rules .= file_contents ('texi-vers',
new Automake::Location,
TEXI => $texi,
VTI => $vti,
STAMPVTI => "${soutdir}stamp-$vti",
VTEXI => "$soutdir$vtexi",
MDDIR => $conf_dir,
DIRSTAMP => $dirstamp);
}
}
my $need_texi_file = 0;
my $texinfodir;
if (var ('TEXINFO_TEX'))
{
$texinfodir = ('$(srcdir)/'
. dirname (variable_value ('TEXINFO_TEX')));
}
elsif (option 'cygnus')
{
$texinfodir = '$(top_srcdir)/../texinfo';
define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex", INTERNAL);
}
elsif ($config_aux_dir_set_in_configure_ac)
{
$texinfodir = $am_config_aux_dir;
define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex", INTERNAL);
$need_texi_file = 2; }
else
{
$texinfodir = '$(srcdir)';
$need_texi_file = 1;
}
define_variable ('am__TEXINFO_TEX_DIR', $texinfodir, INTERNAL);
push (@dist_targets, 'dist-info');
if (! option 'no-installinfo')
{
unshift (@all, '$(INFO_DEPS)');
}
define_files_variable ("DVIS", @infobase, 'dvi', INTERNAL);
define_files_variable ("PDFS", @infobase, 'pdf', INTERNAL);
define_files_variable ("PSS", @infobase, 'ps', INTERNAL);
define_files_variable ("HTMLS", @infobase, 'html', INTERNAL);
define_variable ("TEXINFOS", variable_value ('info_TEXINFOS'), INTERNAL);
if ($need_texi_file && ! option 'no-texinfo.tex')
{
if ($need_texi_file > 1)
{
require_conf_file_with_macro (TRUE, 'info_TEXINFOS', FOREIGN,
'texinfo.tex');
}
else
{
require_file_with_macro (TRUE, 'info_TEXINFOS', FOREIGN,
'texinfo.tex');
}
}
return makefile_wrap ("", "\t ", @texi_cleans);
}
sub handle_texinfo ()
{
reject_var 'TEXINFOS', "`TEXINFOS' is an anachronism; use `info_TEXINFOS'";
reject_var 'html_TEXINFOS', "HTML generation not yet supported";
my $info_texinfos = var ('info_TEXINFOS');
my $texiclean = "";
if ($info_texinfos)
{
$texiclean = handle_texinfo_helper ($info_texinfos);
}
$output_rules .= file_contents ('texinfos',
new Automake::Location,
TEXICLEAN => $texiclean,
'LOCAL-TEXIS' => !!$info_texinfos);
}
sub handle_man_pages
{
reject_var 'MANS', "`MANS' is an anachronism; use `man_MANS'";
my (%sections, %vlist);
foreach my $pfx ('', 'dist_', 'nodist_')
{
foreach my $section ('0'..'9', 'n', 'l')
{
my $varname = $pfx . 'man' . $section . '_MANS';
if (var ($varname))
{
$sections{$section} = 1;
$varname = '$(' . $varname . ')';
$vlist{$varname} = 1;
&push_dist_common ($varname)
if $pfx eq 'dist_';
}
}
my $varname = $pfx . 'man_MANS';
my $var = var ($varname);
if ($var)
{
foreach ($var->value_as_list_recursive)
{
if (/\.([0-9a-z])([a-z]*)$/)
{
$sections{$1} = 1;
}
}
$varname = '$(' . $varname . ')';
$vlist{$varname} = 1;
&push_dist_common ($varname)
if $pfx eq 'dist_';
}
}
return unless %sections;
foreach my $section (sort keys %sections)
{
$output_rules .= &file_contents ('mans',
new Automake::Location,
SECTION => $section);
}
my @mans = sort keys %vlist;
$output_vars .= file_contents ('mans-vars',
new Automake::Location,
MANS => "@mans");
push (@all, '$(MANS)')
unless option 'no-installman';
}
sub handle_data
{
&am_install_var ('-noextra', '-candist', 'data', 'DATA',
'data', 'dataroot', 'dvi', 'html', 'pdf', 'ps',
'sysconf', 'sharedstate', 'localstate',
'pkgdata', 'lisp', 'noinst', 'check');
}
sub handle_tags
{
my @tag_deps = ();
my @ctag_deps = ();
if (var ('SUBDIRS'))
{
$output_rules .= ("tags-recursive:\n"
. "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
. "\t test \"\$\$subdir\" = . || (cd \$\$subdir"
. " && \$(MAKE) \$(AM_MAKEFLAGS) tags); \\\n"
. "\tdone\n");
push (@tag_deps, 'tags-recursive');
&depend ('.PHONY', 'tags-recursive');
$output_rules .= ("ctags-recursive:\n"
. "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
. "\t test \"\$\$subdir\" = . || (cd \$\$subdir"
. " && \$(MAKE) \$(AM_MAKEFLAGS) ctags); \\\n"
. "\tdone\n");
push (@ctag_deps, 'ctags-recursive');
&depend ('.PHONY', 'ctags-recursive');
}
if (&saw_sources_p (1)
|| var ('ETAGS_ARGS')
|| @tag_deps)
{
my @config;
foreach my $spec (@config_headers)
{
my ($out, @ins) = split_config_file_spec ($spec);
foreach my $in (@ins)
{
push @config, basename ($in)
if $relative_dir eq dirname ($in);
}
}
$output_rules .= &file_contents ('tags',
new Automake::Location,
CONFIG => "@config",
TAGSDIRS => "@tag_deps",
CTAGSDIRS => "@ctag_deps");
set_seen 'TAGS_DEPENDENCIES';
}
elsif (reject_var ('TAGS_DEPENDENCIES',
"doesn't make sense to define `TAGS_DEPENDENCIES'"
. "without\nsources or `ETAGS_ARGS'"))
{
}
else
{
$output_rules .= "tags: TAGS\nTAGS:\n\n";
$output_rules .= "ctags: CTAGS\nCTAGS:\n\n";
}
}
sub handle_multilib
{
if ($seen_multilib && $relative_dir eq '.')
{
$output_rules .= &file_contents ('multilib', new Automake::Location);
push (@all, 'all-multi');
}
}
sub user_phony_rule ($)
{
my ($name) = @_;
my $rule = rule $name;
if ($rule)
{
depend ('.PHONY', $name);
for my $c ($rule->not_always_defined_in_cond (TRUE)->conds)
{
Automake::Rule::define ($name, 'internal', RULE_AUTOMAKE,
$c, INTERNAL);
$output_rules .= $c->subst_string . "$name:\n";
}
}
return $rule;
}
sub for_dist_common
{
return 0
if $a eq $b;
return -1
if $a eq 'README';
return 1
if $b eq 'README';
return $a cmp $b;
}
sub handle_dist ()
{
my %transform;
my $subdirs = var ('SUBDIRS');
if ($subdirs)
{
if (var ('DIST_SUBDIRS'))
{
}
elsif ($subdirs->has_conditional_contents)
{
define_pretty_variable
('DIST_SUBDIRS', TRUE, INTERNAL,
uniq ($subdirs->value_as_list_recursive));
}
else
{
define_pretty_variable ('DIST_SUBDIRS', TRUE, INTERNAL,
'$(SUBDIRS)');
}
}
return if option 'no-dist';
if ($relative_dir eq '.')
{
my $archive_defined = option 'no-dist-gzip' ? 0 : 1;
$archive_defined ||=
grep { option "dist-$_" } ('shar', 'zip', 'tarZ', 'bzip2');
error (option 'no-dist-gzip',
"no-dist-gzip specified but no dist-* specified, "
. "at least one archive format must be enabled")
unless $archive_defined;
}
my $check_aux = 0;
if ($relative_dir eq '.'
&& $config_aux_dir_set_in_configure_ac)
{
if (! &is_make_dir ($config_aux_dir))
{
$check_aux = 1;
}
}
foreach my $cfile (@common_files)
{
if (dir_has_case_matching_file ($relative_dir, $cfile)
|| rule $cfile)
{
&push_dist_common ($cfile);
}
if ($check_aux && dir_has_case_matching_file ($config_aux_dir, $cfile))
{
&push_dist_common ("$config_aux_dir/$cfile")
}
}
if ($relative_dir eq '.')
{
foreach my $file (split (' ' , $configure_dist_common))
{
push_dist_common ($file)
unless is_make_dir (dirname ($file));
}
}
my @dist_common = split (' ', rvar ('DIST_COMMON')->variable_value);
@dist_common = uniq (sort for_dist_common (@dist_common));
variable_delete 'DIST_COMMON';
define_pretty_variable ('DIST_COMMON', TRUE, INTERNAL, @dist_common);
$handle_dist_run = 1;
my $extra_dist = var ('EXTRA_DIST');
$transform{'DISTCHECK-HOOK'} = !! rule 'distcheck-hook';
$transform{'GETTEXT'} = $seen_gettext && !$seen_gettext_external;
push (@dist_targets, 'dist-hook')
if user_phony_rule 'dist-hook';
$transform{'DIST-TARGETS'} = join (' ', @dist_targets);
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);
}
sub check_directory ($$)
{
my ($dir, $where) = @_;
error $where, "required directory $relative_dir/$dir does not exist"
unless -d "$relative_dir/$dir";
msg ('portability', $where,
"naming a subdirectory `obj' causes troubles with BSD make")
if $dir eq 'obj';
msg ('portability', $where,
"name `$dir' is reserved on W32 and DOS platforms")
if grep (/^\Q$dir\E$/i, qw/aux lpt1 lpt2 lpt3 com1 com2 com3 com4 con prn/);
}
sub check_directories_in_var ($)
{
my ($var) = @_;
$var->traverse_recursively
(sub
{
my ($var, $val, $cond, $full_cond) = @_;
check_directory ($val, $var->rdef ($cond)->location);
return ();
},
undef,
skip_ac_subst => 1);
}
sub handle_subdirs ()
{
my $subdirs = var ('SUBDIRS');
return
unless $subdirs;
check_directories_in_var $subdirs;
my $dsubdirs = var ('DIST_SUBDIRS');
check_directories_in_var $dsubdirs
if $dsubdirs;
$output_rules .= &file_contents ('subdirs', new Automake::Location);
rvar ('RECURSIVE_TARGETS')->rdef (TRUE)->{'pretty'} = VAR_SORTED; }
sub scan_aclocal_m4 ()
{
my $regen_aclocal = 0;
set_seen 'CONFIG_STATUS_DEPENDENCIES';
set_seen 'CONFIGURE_DEPENDENCIES';
if (-f 'aclocal.m4')
{
&define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4', INTERNAL);
my $aclocal = new Automake::XFile "< aclocal.m4";
my $line = $aclocal->getline;
$regen_aclocal = $line =~ 'generated automatically by aclocal';
}
my @ac_deps = ();
if (set_seen ('ACLOCAL_M4_SOURCES'))
{
push (@ac_deps, '$(ACLOCAL_M4_SOURCES)');
msg_var ('obsolete', 'ACLOCAL_M4_SOURCES',
"`ACLOCAL_M4_SOURCES' is obsolete.\n"
. "It should be safe to simply remove it.");
}
return ($regen_aclocal, @ac_deps);
}
sub substitute_ac_subst_variables_worker($)
{
my ($token) = @_;
return "\@$token\@" if var $token;
return "\${$token\}";
}
sub substitute_ac_subst_variables ($)
{
my ($text) = @_;
$text =~ s/\${([^ \t=:+{}]+)}/&substitute_ac_subst_variables_worker ($1)/ge;
return $text;
}
sub prepend_srcdir (@)
{
my (@inputs) = @_;
my @newinputs;
foreach my $single (@inputs)
{
if (dirname ($single) eq $relative_dir)
{
push (@newinputs, '$(srcdir)/' . basename ($single));
}
else
{
push (@newinputs, '$(top_srcdir)/' . $single);
}
}
return @newinputs;
}
sub rewrite_inputs_into_dependencies ($@)
{
my ($file, @inputs) = @_;
my @res = ();
for my $i (@inputs)
{
next if (substitute_ac_subst_variables $i) =~ /\$/;
if (exists $ac_config_files_location{$i})
{
my $di = dirname $i;
if ($di eq $relative_dir)
{
$i = basename $i;
}
elsif ($relative_dir ne '.')
{
$i = '$(top_builddir)/' . $i;
}
}
else
{
msg ('error', $ac_config_files_location{$file},
"required file `$i' not found")
unless $i =~ /\$/ || exists $output_files{$i} || -f $i;
($i) = prepend_srcdir ($i);
push_dist_common ($i);
}
push @res, $i;
}
return @res;
}
sub handle_configure ($$$@)
{
my ($makefile_am, $makefile_in, $makefile, @inputs) = @_;
prog_error 'empty @inputs'
unless @inputs;
my ($rel_makefile_am, $rel_makefile_in) = prepend_srcdir ($makefile_am,
$makefile_in);
my $rel_makefile = basename $makefile;
my $colon_infile = ':' . join (':', @inputs);
$colon_infile = '' if $colon_infile eq ":$makefile.in";
my @rewritten = rewrite_inputs_into_dependencies ($makefile, @inputs);
my ($regen_aclocal_m4, @aclocal_m4_deps) = scan_aclocal_m4;
define_pretty_variable ('am__aclocal_m4_deps', TRUE, INTERNAL,
@configure_deps, @aclocal_m4_deps,
'$(top_srcdir)/' . $configure_ac);
my @configuredeps = ('$(am__aclocal_m4_deps)', '$(CONFIGURE_DEPENDENCIES)');
push @configuredeps, '$(ACLOCAL_M4)' if -f 'aclocal.m4';
define_pretty_variable ('am__configure_deps', TRUE, INTERNAL,
@configuredeps);
$output_rules .= file_contents
('configure',
new Automake::Location,
MAKEFILE => $rel_makefile,
'MAKEFILE-DEPS' => "@rewritten",
'CONFIG-MAKEFILE' => ($relative_dir eq '.') ? '$@' : '$(subdir)/$@',
'MAKEFILE-IN' => $rel_makefile_in,
'MAKEFILE-IN-DEPS' => "@include_stack",
'MAKEFILE-AM' => $rel_makefile_am,
STRICTNESS => global_option 'cygnus'
? 'cygnus' : $strictness_name,
'USE-DEPS' => global_option 'no-dependencies'
? ' --ignore-deps' : '',
'MAKEFILE-AM-SOURCES' => "$makefile$colon_infile",
'REGEN-ACLOCAL-M4' => $regen_aclocal_m4);
if ($relative_dir eq '.')
{
&push_dist_common ('acconfig.h')
if -f 'acconfig.h';
}
my $hdr_index = 0;
my @distclean_config;
foreach my $spec (@config_headers)
{
$hdr_index += 1;
my ($config_h_path, @ins) = split_config_file_spec ($spec);
my $config_h_dir = dirname ($config_h_path);
if ($relative_dir eq $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)
{
$cn_sans_dir = basename ($config_h_path);
$stamp_dir = '';
}
else
{
$cn_sans_dir = $config_h_path;
if ($config_h_dir eq '.')
{
$stamp_dir = '';
}
else
{
$stamp_dir = $config_h_dir . '/';
}
}
@ins = rewrite_inputs_into_dependencies ($config_h_path, @ins);
next if (substitute_ac_subst_variables $config_h_path) =~ /\$/;
my @files;
if (-f $config_h_path . '.top')
{
push (@files, "$cn_sans_dir.top");
}
if (-f $config_h_path . '.bot')
{
push (@files, "$cn_sans_dir.bot");
}
push_dist_common (@files);
if (-f 'acconfig.h')
{
push (@files, '$(top_srcdir)/acconfig.h');
}
my $stamp = "${stamp_dir}stamp-h${hdr_index}";
$output_rules .=
file_contents ('remake-hdr',
new Automake::Location,
FILES => "@files",
CONFIG_H => $cn_sans_dir,
CONFIG_HIN => $ins[0],
CONFIG_H_DEPS => "@ins",
CONFIG_H_PATH => $config_h_path,
STAMP => "$stamp");
push @distclean_config, $cn_sans_dir, $stamp;
}
}
$output_rules .= file_contents ('clean-hdr',
new Automake::Location,
FILES => "@distclean_config")
if @distclean_config;
my $mkidpath = "$config_aux_dir/mkinstalldirs";
if (-f $mkidpath)
{
require_conf_file ($mkidpath, FOREIGN, 'mkinstalldirs');
define_variable ('mkinstalldirs',
"\$(SHELL) $am_config_aux_dir/mkinstalldirs", INTERNAL);
}
else
{
define_variable ('mkinstalldirs', '$(install_sh) -d', INTERNAL);
}
reject_var ('CONFIG_HEADER',
"`CONFIG_HEADER' is an anachronism; now determined "
. "automatically\nfrom `$configure_ac'");
my @config_h;
foreach my $spec (@config_headers)
{
my ($out, @ins) = split_config_file_spec ($spec);
if ($relative_dir eq dirname ($out))
{
push @config_h, basename ($out);
}
else
{
push @config_h, "\$(top_builddir)/$out";
}
}
define_variable ("CONFIG_HEADER", "@config_h", INTERNAL)
if @config_h;
my @actual_other_files = ();
foreach my $lfile (@other_input_files)
{
my $file;
my @inputs;
if ($lfile =~ /^([^:]*):(.*)$/)
{
$file = $1;
@inputs = split (':', $2);
}
else
{
$file = $lfile;
@inputs = $file . '.in';
}
prog_error ("$lfile in \@other_input_files\n"
. "\@other_input_files = (@other_input_files)")
if -f $file . '.am';
my $local = basename ($file);
my $fd = dirname ($file);
if ($fd ne $relative_dir)
{
if ($relative_dir eq '.' && ! &is_make_dir ($fd))
{
$local = $file;
}
else
{
next;
}
}
my @rewritten_inputs = rewrite_inputs_into_dependencies ($file, @inputs);
next if (substitute_ac_subst_variables $local) =~ /\$/;
$output_rules .= ($local . ': '
. '$(top_builddir)/config.status '
. "@rewritten_inputs\n"
. "\t"
. 'cd $(top_builddir) && '
. '$(SHELL) ./config.status '
. ($relative_dir eq '.' ? '' : '$(subdir)/')
. '$@'
. "\n");
push (@actual_other_files, $local);
}
foreach my $spec (@config_links)
{
my ($link, $file) = split /:/, $spec;
next unless $file;
my $where = $ac_config_files_location{$link};
if ((substitute_ac_subst_variables $link) !~ /\$/)
{
my $local = basename ($link);
my $fd = dirname ($link);
if ($fd ne $relative_dir)
{
if ($relative_dir eq '.' && ! &is_make_dir ($fd))
{
$local = $link;
}
else
{
$local = undef;
}
}
push @actual_other_files, $local if $local;
}
if ((substitute_ac_subst_variables $file) !~ /\$/)
{
my $fd = dirname ($file);
if (($fd eq $relative_dir)
|| ($relative_dir eq '.' && ! &is_make_dir ($fd)))
{
rewrite_inputs_into_dependencies ($link, $file);
}
}
}
define_pretty_variable ('CONFIG_CLEAN_FILES', TRUE, INTERNAL,
@actual_other_files);
}
sub handle_headers
{
my @r = &am_install_var ('-defaultdist', 'header', 'HEADERS', 'include',
'oldinclude', 'pkginclude',
'noinst', 'check');
foreach (@r)
{
next unless $_->[1] =~ /\..*$/;
&saw_extension ($&);
}
}
sub handle_gettext
{
return if ! $seen_gettext || $relative_dir ne '.';
my $subdirs = var 'SUBDIRS';
if (! $subdirs)
{
err_ac "AM_GNU_GETTEXT used but SUBDIRS not defined";
return;
}
if (-d 'po')
{
my @subdirs = $subdirs->value_as_list_recursive;
msg_var ('syntax', $subdirs,
"AM_GNU_GETTEXT used but `po' not in SUBDIRS")
if ! grep ($_ eq 'po', @subdirs);
msg_var ('syntax', $subdirs,
"AM_GNU_GETTEXT used but `intl' not in SUBDIRS")
if (! ($seen_gettext_external && ! $seen_gettext_intl)
&& ! grep ($_ eq 'intl', @subdirs));
msg_var ('syntax', $subdirs,
"`intl' should not be in SUBDIRS when "
. "AM_GNU_GETTEXT([external]) is used")
if ($seen_gettext_external && ! $seen_gettext_intl
&& grep ($_ eq 'intl', @subdirs));
}
require_file ($ac_gettext_location, GNU, 'ABOUT-NLS');
}
sub handle_footer
{
reject_rule ('.SUFFIXES',
"use variable `SUFFIXES', not target `.SUFFIXES'");
$output_header .= ".SUFFIXES:\n";
my $suffixes = var 'SUFFIXES';
my @suffixes = Automake::Rule::suffixes;
if (@suffixes || $suffixes)
{
my @user_suffixes = ($suffixes
? $suffixes->value_as_list_recursive : ());
my %suffixes = map { $_ => 1 } @suffixes;
delete @suffixes{@user_suffixes};
$output_header .= (".SUFFIXES: "
. join (' ', @user_suffixes, sort keys %suffixes)
. "\n");
}
$output_trailer .= file_contents ('footer', new Automake::Location);
}
sub handle_install ()
{
$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') || '');
}
sub handle_all ($)
{
my ($makefile) = @_;
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;
}
push (@all, "all-local")
if user_phony_rule "all-local";
&pretty_print_rule ("all-am:", "\t\t", @all);
&depend ('.PHONY', 'all-am', '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)
{
$output_all .= ("all: @local_headers"
. "\n\t"
. '$(MAKE) $(AM_MAKEFLAGS) '
. (var ('SUBDIRS') ? 'all-recursive' : 'all-am')
. "\n\n");
}
else
{
$output_all .= "all: " . (var ('SUBDIRS')
? 'all-recursive' : 'all-am') . "\n\n";
}
}
sub do_check_merge_target ()
{
push @check_tests, 'check-local'
if user_phony_rule 'check-local';
if (option 'cygnus')
{
pretty_print_rule ('check-am:', "\t\t", @check);
}
else
{
$output_rules .= "check-am: all-am\n";
pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
@check)
if @check;
}
pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
@check_tests)
if @check_tests;
depend '.PHONY', 'check', 'check-am';
$output_rules .= ("check: "
. (var ('BUILT_SOURCES')
? "\$(BUILT_SOURCES)\n\t\$(MAKE) \$(AM_MAKEFLAGS) "
: '')
. (var ('SUBDIRS') ? 'check-recursive' : 'check-am')
. "\n");
}
sub handle_clean ($)
{
my ($makefile) = @_;
$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');
$clean_files{'$(BUILT_SOURCES)'} = MAINTAINER_CLEAN
if var ('BUILT_SOURCES');
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";
$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,
);
}
sub target_cmp
{
return 0 if $a eq $b;
my $a1 = substr ($a, 0, 1);
my $b1 = substr ($b, 0, 1);
if ($a1 ne $b1)
{
return -1 if $b1 eq '.';
return 1 if $a1 eq '.';
}
return $a cmp $b;
}
sub handle_factored_dependencies
{
foreach my $utarg ('uninstall-data-local', 'uninstall-data-hook',
'uninstall-exec-local', 'uninstall-exec-hook',
'uninstall-dvi-local',
'uninstall-html-local',
'uninstall-info-local',
'uninstall-pdf-local',
'uninstall-ps-local')
{
my $x = $utarg;
$x =~ s/-.*-/-/;
reject_rule ($utarg, "use `$x', not `$utarg'");
}
reject_rule ('install-local',
"use `install-data-local' or `install-exec-local', "
. "not `install-local'");
reject_rule ('install-hook',
"use `install-data-hook' or `install-exec-hook', "
. "not `install-hook'");
foreach (keys %dependencies)
{
s/-am$// or next;
depend ("$_-am", "$_-local")
if user_phony_rule "$_-local";
}
foreach ('install-exec', 'install-data', 'uninstall')
{
if (user_phony_rule "$_-hook")
{
$actions{"$_-am"} .=
("\t\@\$(NORMAL_INSTALL)\n"
. "\t" . '$(MAKE) $(AM_MAKEFLAGS) ' . "$_-hook\n");
depend ('.MAKE', "$_-am");
}
}
depend ('.PHONY', keys %required_targets);
foreach (sort target_cmp keys %dependencies)
{
next
unless (@{$dependencies{$_}}
|| $actions{$_}
|| $required_targets{$_});
my @undefined_conds = (TRUE,);
if ($_ ne '.PHONY' && $_ ne '.MAKE')
{
@undefined_conds =
Automake::Rule::define ($_, 'internal',
RULE_AUTOMAKE, TRUE, INTERNAL);
}
my @uniq_deps = uniq (sort @{$dependencies{$_}});
foreach my $cond (@undefined_conds)
{
my $condstr = $cond->subst_string;
&pretty_print_rule ("$condstr$_:", "$condstr\t", @uniq_deps);
$output_rules .= $actions{$_} if defined $actions{$_};
$output_rules .= "\n";
}
}
}
sub handle_tests_dejagnu
{
push (@check_tests, 'check-DEJAGNU');
$output_rules .= file_contents ('dejagnu', new Automake::Location);
}
sub handle_tests
{
if (option 'dejagnu')
{
&handle_tests_dejagnu;
}
else
{
foreach my $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
{
reject_var ($c, "`$c' defined but `dejagnu' not in "
. "`AUTOMAKE_OPTIONS'");
}
}
if (var ('TESTS'))
{
push (@check_tests, 'check-TESTS');
$output_rules .= &file_contents ('check', new Automake::Location);
append_exeext { exists $known_programs{$_[0]} } 'TESTS';
}
}
sub handle_emacs_lisp
{
my @elfiles = &am_install_var ('-candist', 'lisp', 'LISP',
'lisp', 'noinst');
return if ! @elfiles;
define_pretty_variable ('am__ELFILES', TRUE, INTERNAL,
map { $_->[1] } @elfiles);
define_pretty_variable ('am__ELCFILES', TRUE, INTERNAL,
'$(am__ELFILES:.el=.elc)');
define_pretty_variable ('ELCFILES', TRUE, INTERNAL, '$(LISP:.el=.elc)');
push @all, '$(ELCFILES)';
require_variables ($elfiles[0][0], "Emacs Lisp sources seen", TRUE,
'EMACS', 'lispdir');
require_conf_file ($elfiles[0][0], FOREIGN, 'elisp-comp');
&define_variable ('elisp_comp', "$am_config_aux_dir/elisp-comp", INTERNAL);
}
sub handle_python
{
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);
}
sub handle_java
{
my @sourcelist = &am_install_var ('-candist',
'java', 'JAVA',
'java', 'noinst', 'check');
return if ! @sourcelist;
my @prefix = am_primary_prefixes ('JAVA', 1,
'java', 'noinst', 'check');
my $dir;
foreach my $curs (@prefix)
{
next
if $curs eq 'EXTRA';
err_var "${curs}_JAVA", "multiple _JAVA primaries in use"
if defined $dir;
$dir = $curs;
}
push (@all, 'class' . $dir . '.stamp');
}
sub handle_minor_options
{
if (option 'readme-alpha')
{
if ($relative_dir eq '.')
{
if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
{
msg ('error-gnits', $package_version_location,
"version `$package_version' doesn't follow " .
"Gnits standards");
}
if (defined $1 && -f 'README-alpha')
{
push_dist_common ('README-alpha');
}
}
}
}
sub split_config_file_spec ($)
{
my ($spec) = @_;
my ($output, @inputs) = split (/:/, $spec);
push @inputs, "$output.in"
unless @inputs;
return ($output, @inputs);
}
sub locate_am (@)
{
my (@rest) = @_;
my $input;
foreach my $file (@rest)
{
if (($file =~ /^(.*)\.in$/) && -f "$1.am")
{
$input = $file;
last;
}
}
return $input;
}
my %make_list;
sub scan_autoconf_config_files ($$)
{
my ($where, $config_files) = @_;
foreach (split ' ', $config_files)
{
next if $_ eq "\\" || $_ eq '';
my ($local, @rest) = split (/:/);
@rest = ("$local.in",) unless @rest;
my $input = locate_am @rest;
if ($input)
{
$make_list{$input} = join (':', ($local, @rest));
}
else
{
push (@other_input_files, $_);
}
$ac_config_files_location{$local} = $where;
}
}
sub scan_autoconf_traces ($)
{
my ($filename) = @_;
my %traced = (
AC_CANONICAL_BUILD => 0,
AC_CANONICAL_HOST => 0,
AC_CANONICAL_TARGET => 0,
AC_CONFIG_AUX_DIR => 1,
AC_CONFIG_FILES => 1,
AC_CONFIG_HEADERS => 1,
AC_CONFIG_LIBOBJ_DIR => 1,
AC_CONFIG_LINKS => 1,
AC_INIT => 0,
AC_LIBSOURCE => 1,
AC_REQUIRE_AUX_FILE => 1,
AC_SUBST_TRACE => 1,
AM_AUTOMAKE_VERSION => 1,
AM_CONDITIONAL => 2,
AM_ENABLE_MULTILIB => 0,
AM_GNU_GETTEXT => 0,
AM_GNU_GETTEXT_INTL_SUBDIR => 0,
AM_INIT_AUTOMAKE => 0,
AM_MAINTAINER_MODE => 0,
AM_PROG_CC_C_O => 0,
_AM_SUBST_NOTMAKE => 1,
LT_SUPPORTED_TAG => 1,
_LT_AC_TAGCONFIG => 0,
m4_include => 1,
m4_sinclude => 1,
sinclude => 1,
);
my $traces = ($ENV{AUTOCONF} || "$_bindir/autoconf") . " ";
$traces .= join (' ',
map { "--trace=$_" . ':\$f:\$l::\$n::\${::}%' }
(keys %traced));
my $tracefh = new Automake::XFile ("$traces $filename |");
verb "reading $traces";
while ($_ = $tracefh->getline)
{
chomp;
my ($here, @args) = split (/::/);
my $where = new Automake::Location $here;
my $macro = $args[0];
prog_error ("unrequested trace `$macro'")
unless exists $traced{$macro};
if ($ {
msg ('syntax', $where, "not enough arguments for $macro");
next;
}
if ($macro eq 'AC_CANONICAL_BUILD')
{
if ($seen_canonical <= AC_CANONICAL_BUILD)
{
$seen_canonical = AC_CANONICAL_BUILD;
$canonical_location = $where;
}
}
elsif ($macro eq 'AC_CANONICAL_HOST')
{
if ($seen_canonical <= AC_CANONICAL_HOST)
{
$seen_canonical = AC_CANONICAL_HOST;
$canonical_location = $where;
}
}
elsif ($macro eq 'AC_CANONICAL_TARGET')
{
$seen_canonical = AC_CANONICAL_TARGET;
$canonical_location = $where;
}
elsif ($macro eq 'AC_CONFIG_AUX_DIR')
{
if ($seen_init_automake)
{
error ($where, "AC_CONFIG_AUX_DIR must be called before "
. "AM_INIT_AUTOMAKE...", partial => 1);
error ($seen_init_automake, "... AM_INIT_AUTOMAKE called here");
}
$config_aux_dir = $args[1];
$config_aux_dir_set_in_configure_ac = 1;
$relative_dir = '.';
check_directory ($config_aux_dir, $where);
}
elsif ($macro eq 'AC_CONFIG_FILES')
{
scan_autoconf_config_files ($where, $args[1]);
}
elsif ($macro eq 'AC_CONFIG_HEADERS')
{
foreach my $spec (split (' ', $args[1]))
{
my ($dest, @src) = split (':', $spec);
$ac_config_files_location{$dest} = $where;
push @config_headers, $spec;
}
}
elsif ($macro eq 'AC_CONFIG_LIBOBJ_DIR')
{
$config_libobj_dir = $args[1];
$relative_dir = '.';
check_directory ($config_libobj_dir, $where);
}
elsif ($macro eq 'AC_CONFIG_LINKS')
{
foreach my $spec (split (' ', $args[1]))
{
my ($dest, $src) = split (':', $spec);
$ac_config_files_location{$dest} = $where;
push @config_links, $spec;
}
}
elsif ($macro eq 'AC_INIT')
{
if (defined $args[2])
{
$package_version = $args[2];
$package_version_location = $where;
}
}
elsif ($macro eq 'AC_LIBSOURCE')
{
$libsources{$args[1]} = $here;
}
elsif ($macro eq 'AC_REQUIRE_AUX_FILE')
{
$required_aux_file{$args[1]} = $where
unless exists $required_aux_file{$args[1]};
}
elsif ($macro eq 'AC_SUBST_TRACE')
{
$configure_vars{$args[1]} = $where
if $args[1] =~ /^\w+$/;
}
elsif ($macro eq 'AM_AUTOMAKE_VERSION')
{
error ($where,
"version mismatch. This is Automake $VERSION,\n" .
"but the definition used by this AM_INIT_AUTOMAKE\n" .
"comes from Automake $args[1]. You should recreate\n" .
"aclocal.m4 with aclocal and run automake again.\n",
exit_code => 63)
if $VERSION ne $args[1];
$seen_automake_version = 1;
}
elsif ($macro eq 'AM_CONDITIONAL')
{
$configure_cond{$args[1]} = $where;
}
elsif ($macro eq 'AM_ENABLE_MULTILIB')
{
$seen_multilib = $where;
}
elsif ($macro eq 'AM_GNU_GETTEXT')
{
$seen_gettext = $where;
$ac_gettext_location = $where;
$seen_gettext_external = grep ($_ eq 'external', @args);
}
elsif ($macro eq 'AM_GNU_GETTEXT_INTL_SUBDIR')
{
$seen_gettext_intl = $where;
}
elsif ($macro eq 'AM_INIT_AUTOMAKE')
{
$seen_init_automake = $where;
if (defined $args[2])
{
$package_version = $args[2];
$package_version_location = $where;
}
elsif (defined $args[1])
{
exit $exit_code
if (process_global_option_list ($where,
split (' ', $args[1])));
}
}
elsif ($macro eq 'AM_MAINTAINER_MODE')
{
$seen_maint_mode = $where;
}
elsif ($macro eq 'AM_PROG_CC_C_O')
{
$seen_cc_c_o = $where;
}
elsif ($macro eq '_AM_SUBST_NOTMAKE')
{
$ignored_configure_vars{$args[1]} = $where;
}
elsif ($macro eq 'm4_include'
|| $macro eq 'm4_sinclude'
|| $macro eq 'sinclude')
{
next if $macro ne 'm4_include' && ! -f $args[1];
push @configure_deps, '$(top_srcdir)/' . $args[1]
unless $here =~ m,^(?:\w:)?[\\/],;
if (-e $args[1])
{
my $mtime = mtime $args[1];
$configure_deps_greatest_timestamp = $mtime
if $mtime > $configure_deps_greatest_timestamp;
}
}
elsif ($macro eq 'LT_SUPPORTED_TAG')
{
$libtool_tags{$args[1]} = 1;
$libtool_new_api = 1;
}
elsif ($macro eq '_LT_AC_TAGCONFIG')
{
if (0 == keys %libtool_tags)
{
%libtool_tags = (CC => 1, CXX => 1, GCJ => 1, F77 => 1);
}
}
}
$tracefh->close;
}
sub scan_autoconf_files ()
{
%libsources = ();
$configure_deps_greatest_timestamp = mtime $configure_ac;
if (-e 'aclocal.m4')
{
my $mtime = mtime 'aclocal.m4';
$configure_deps_greatest_timestamp = $mtime
if $mtime > $configure_deps_greatest_timestamp;
}
scan_autoconf_traces ($configure_ac);
@configure_input_files = sort keys %make_list;
if (! @input_files)
{
@input_files = @configure_input_files;
%output_files = %make_list;
}
if (! $seen_init_automake)
{
err_ac ("no proper invocation of AM_INIT_AUTOMAKE was found.\nYou "
. "should verify that $configure_ac invokes AM_INIT_AUTOMAKE,"
. "\nthat aclocal.m4 is present in the top-level directory,\n"
. "and that aclocal.m4 was recently regenerated "
. "(using aclocal).");
}
else
{
if (! $seen_automake_version)
{
if (-f 'aclocal.m4')
{
error ($seen_init_automake,
"your implementation of AM_INIT_AUTOMAKE comes from " .
"an\nold Automake version. You should recreate " .
"aclocal.m4\nwith aclocal and run automake again.\n",
exit_code => 63);
}
else
{
error ($seen_init_automake,
"no proper implementation of AM_INIT_AUTOMAKE was " .
"found,\nprobably because aclocal.m4 is missing...\n" .
"You should run aclocal to create this file, then\n" .
"run automake again.\n");
}
}
}
locate_aux_dir ();
my $auxdirdist = is_make_dir ($config_aux_dir) ? $config_aux_dir : '.';
my @new_input_files = ();
while (@input_files)
{
my $in = pop @input_files;
my @ins = split (/:/, $output_files{$in});
if (dirname ($ins[0]) eq $auxdirdist)
{
push @new_input_files, $in;
$automake_will_process_aux_dir = 1;
}
else
{
unshift @new_input_files, $in;
}
}
@input_files = @new_input_files;
$automake_will_process_aux_dir = 1 if ! is_make_dir ($auxdirdist);
$relative_dir = '.';
foreach my $file (keys %required_aux_file)
{
require_conf_file ($required_aux_file{$file}->get, FOREIGN, $file)
}
err_am "`install.sh' is an anachronism; use `install-sh' instead"
if -f $config_aux_dir . '/install.sh';
$configure_dist_common = variable_value ('DIST_COMMON') || '';
}
sub check_cygnus
{
my $cygnus = option 'cygnus';
return unless $cygnus;
set_strictness ('foreign');
set_option ('no-installinfo', $cygnus);
set_option ('no-dependencies', $cygnus);
set_option ('no-dist', $cygnus);
err_ac "`AM_MAINTAINER_MODE' required when --cygnus specified"
if !$seen_maint_mode;
}
sub check_gnu_standards
{
if ($relative_dir eq '.')
{
require_file ("$am_file.am", GNU,
qw/INSTALL NEWS README AUTHORS ChangeLog/);
my $license;
foreach (qw /COPYING COPYING.LIB COPYING.LESSER/)
{
if (-f $_)
{
$license = $_;
last;
}
}
require_file ("$am_file.am", GNU, 'COPYING')
unless $license;
}
for my $opt ('no-installman', 'no-installinfo')
{
msg ('error-gnu', option $opt,
"option `$opt' disallowed by GNU standards")
if option $opt;
}
}
sub check_gnits_standards
{
if ($relative_dir eq '.')
{
require_file ("$am_file.am", GNITS, 'THANKS');
}
}
sub lang_sub_obj
{
return option 'subdir-objects' ? LANG_SUBDIR : LANG_PROCESS;
}
sub lang_c_rewrite
{
my ($directory, $base, $ext, $nonansi_obj, $have_per_exec_flags, $var) = @_;
if (option 'ansi2knr' && $base =~ /_$/)
{
err_am "C source file `$base.c' would be deleted by ansi2knr rules";
}
my $r = LANG_PROCESS;
if (option 'subdir-objects')
{
$r = LANG_SUBDIR;
if ($directory && $directory ne '.')
{
$base = $directory . '/' . $base;
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 || $nonansi_obj eq '.lo';
}
$de_ansi_files{$base} = '';
}
else
{
$de_ansi_files{$base} = (($directory eq '.' || $directory eq '')
? ''
: "$directory/");
}
if (! $seen_cc_c_o
&& $have_per_exec_flags
&& ! option 'subdir-objects'
&& $nonansi_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;
}
sub lang_cxx_rewrite
{
return &lang_sub_obj;
}
sub lang_header_rewrite
{
return LANG_IGNORE;
}
sub lang_yacc_rewrite
{
my ($directory, $base, $ext) = @_;
my $r = &lang_sub_obj;
(my $newext = $ext) =~ tr/y/c/;
return ($r, $newext);
}
sub lang_yaccxx_rewrite
{
my ($directory, $base, $ext) = @_;
my $r = &lang_sub_obj;
(my $newext = $ext) =~ tr/y/c/;
return ($r, $newext);
}
sub lang_lex_rewrite
{
my ($directory, $base, $ext) = @_;
my $r = &lang_sub_obj;
(my $newext = $ext) =~ tr/l/c/;
return ($r, $newext);
}
sub lang_lexxx_rewrite
{
my ($directory, $base, $ext) = @_;
my $r = &lang_sub_obj;
(my $newext = $ext) =~ tr/l/c/;
return ($r, $newext);
}
sub lang_asm_rewrite
{
return &lang_sub_obj;
}
sub lang_cppasm_rewrite
{
return &lang_sub_obj;
}
sub lang_f77_rewrite
{
return LANG_PROCESS;
}
sub lang_fc_rewrite
{
return LANG_PROCESS;
}
sub lang_ppfc_rewrite
{
return LANG_PROCESS;
}
sub lang_ppf77_rewrite
{
return LANG_PROCESS;
}
sub lang_ratfor_rewrite
{
return LANG_PROCESS;
}
sub lang_objc_rewrite
{
return &lang_sub_obj;
}
sub lang_upc_rewrite
{
return &lang_sub_obj;
}
sub lang_java_rewrite
{
return LANG_SUBDIR;
}
sub lang_c_finish
{
foreach my $file (keys %libsources)
{
if ($file =~ /^(.*)\.[cly]$/ && -f "$relative_dir/$file")
{
$de_ansi_files{$1} = ''
}
}
if (option 'ansi2knr' && keys %de_ansi_files)
{
my @objects;
foreach my $base (sort keys %de_ansi_files)
{
my $ansfile = $de_ansi_files{$base} . $base . '.c';
$output_rules .= ($base . "_.c: $ansfile \$(ANSI2KNR)\n\t"
. '$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) '
. '`if test -f $(srcdir)/' . $ansfile
. '; then echo $(srcdir)/' . $ansfile
. '; else echo ' . $ansfile . '; fi` '
. "| sed 's/^# \\([0-9]\\)/#line \\1/' "
. '| $(ANSI2KNR) > $@'
. " || rm -f \$\@\n");
push (@objects, $base . '_.$(OBJEXT)');
push (@objects, $base . '_.lo')
if var ('LIBTOOL');
$clean_files{$base . '_.c'} = MOSTLY_CLEAN
if dirname ($base) ne '.';
}
&pretty_print_rule ('', '', @objects, ':', '$(ANSI2KNR)');
}
}
sub lang_yacc_target_hook
{
my ($self, $aggregate, $output, $input, %transform) = @_;
my $flag = $aggregate . "_YFLAGS";
my $flagvar = var $flag;
my $YFLAGSvar = var 'YFLAGS';
if (($flagvar && $flagvar->variable_value =~ /$DASH_D_PATTERN/o)
|| ($YFLAGSvar && $YFLAGSvar->variable_value =~ /$DASH_D_PATTERN/o))
{
(my $output_base = $output) =~ s/$KNOWN_EXTENSIONS_PATTERN$//;
my $header = $output_base . '.h';
foreach my $cond (Automake::Rule::define (${header}, 'internal',
RULE_AUTOMAKE, TRUE,
INTERNAL))
{
my $condstr = $cond->subst_string;
$output_rules .=
"$condstr${header}: $output\n"
. "$condstr\t\@if test ! -f \$@; then \\\n"
. "$condstr\t rm -f $output; \\\n"
. "$condstr\t \$(MAKE) \$(AM_MAKEFLAGS) $output; \\\n"
. "$condstr\telse :; fi\n";
}
&push_dist_common ($header)
if $transform{'DIST_SOURCE'};
$clean_files{$header} = MAINTAINER_CLEAN;
}
$clean_files{$output} = MAINTAINER_CLEAN;
}
sub lang_lex_target_hook
{
my ($self, $aggregate, $output, $input) = @_;
$clean_files{$output} = MAINTAINER_CLEAN;
}
sub yacc_lex_finish_helper
{
return if defined $language_scratch{'lex-yacc-done'};
$language_scratch{'lex-yacc-done'} = 1;
require_conf_file ($configure_ac, FOREIGN, 'ylwrap');
&define_variable ('YLWRAP', "$am_config_aux_dir/ylwrap", INTERNAL);
}
sub lang_yacc_finish
{
return if defined $language_scratch{'yacc-done'};
$language_scratch{'yacc-done'} = 1;
reject_var 'YACCFLAGS', "`YACCFLAGS' obsolete; use `YFLAGS' instead";
yacc_lex_finish_helper;
}
sub lang_lex_finish
{
return if defined $language_scratch{'lex-done'};
$language_scratch{'lex-done'} = 1;
yacc_lex_finish_helper;
}
sub resolve_linker
{
my (%linkers) = @_;
foreach my $l (qw(GCJLINK CXXLINK F77LINK FCLINK OBJCLINK UPCLINK))
{
return $l if defined $linkers{$l};
}
return 'LINK';
}
sub saw_extension
{
my ($ext) = @_;
if (! defined $extension_seen{$ext})
{
$extension_seen{$ext} = 1;
}
else
{
++$extension_seen{$ext};
}
}
sub count_files_for_language
{
my ($name) = @_;
my @names;
if ($name eq 'yacc' || $name eq 'yaccxx')
{
@names = ('yacc', 'yaccxx');
}
elsif ($name eq 'lex' || $name eq 'lexxx')
{
@names = ('lex', 'lexxx');
}
else
{
@names = ($name);
}
my $r = 0;
foreach $name (@names)
{
my $lang = $languages{$name};
foreach my $ext (@{$lang->extensions})
{
$r += $extension_seen{$ext}
if defined $extension_seen{$ext};
}
}
return $r
}
sub saw_sources_p
{
my ($headers) = @_;
my $count = 0;
foreach my $val (values %extension_seen)
{
$count += $val;
}
if (!$headers)
{
$count -= count_files_for_language ('header');
}
return $count > 0;
}
sub register_language (%)
{
my (%option) = @_;
$option{'ansi'} = 0
unless defined $option{'ansi'};
$option{'autodep'} = 'no'
unless defined $option{'autodep'};
$option{'linker'} = ''
unless defined $option{'linker'};
$option{'flags'} = []
unless defined $option{'flags'};
$option{'output_extensions'} = sub { return ( '.$(OBJEXT)', '.lo' ) }
unless defined $option{'output_extensions'};
$option{'nodist_specific'} = 0
unless defined $option{'nodist_specific'};
my $lang = new Language (%option);
$extension_map{$_} = $lang->name foreach @{$lang->extensions};
$languages{$lang->name} = $lang;
my $link = $lang->linker;
if ($link)
{
if (exists $link_languages{$link})
{
prog_error ("`$link' has different definitions in "
. $lang->name . " and " . $link_languages{$link}->name)
if $lang->link ne $link_languages{$link}->link;
}
else
{
$link_languages{$link} = $lang;
}
}
accept_extensions (@{$lang->extensions});
foreach my $suffix (@{$lang->extensions})
{
foreach my $dest (&{$lang->output_extensions} ($suffix))
{
register_suffix_rule (INTERNAL, $suffix, $dest);
}
}
}
sub derive_suffix ($$)
{
my ($source_ext, $obj) = @_;
while (! $extension_map{$source_ext}
&& $source_ext ne $obj
&& exists $suffix_rules->{$source_ext}
&& exists $suffix_rules->{$source_ext}{$obj})
{
$source_ext = $suffix_rules->{$source_ext}{$obj}[0];
}
return $source_ext;
}
sub pretty_print_rule
{
$output_rules .= &makefile_wrap (@_);
}
sub make_conditional_string ($$)
{
my ($negate, $cond) = @_;
$cond = "${cond}_TRUE"
unless $cond =~ /^TRUE|FALSE$/;
$cond = Automake::Condition::conditional_negate ($cond)
if $negate;
return $cond;
}
my %_am_macro_for_cond =
(
AMDEP => "one of the compiler tests\n"
. " AC_PROG_CC, AC_PROG_CXX, AC_PROG_CXX, AC_PROG_OBJC,\n"
. " AM_PROG_AS, AM_PROG_GCJ, AM_PROG_UPC",
am__fastdepCC => 'AC_PROG_CC',
am__fastdepCCAS => 'AM_PROG_AS',
am__fastdepCXX => 'AC_PROG_CXX',
am__fastdepGCJ => 'AM_PROG_GCJ',
am__fastdepOBJC => 'AC_PROG_OBJC',
am__fastdepUPC => 'AM_PROG_UPC'
);
sub cond_stack_if ($$$)
{
my ($negate, $cond, $where) = @_;
if (! $configure_cond{$cond} && $cond !~ /^TRUE|FALSE$/)
{
my $text = "$cond does not appear in AM_CONDITIONAL";
my $scope = US_LOCAL;
if (exists $_am_macro_for_cond{$cond})
{
my $mac = $_am_macro_for_cond{$cond};
$text .= "\n The usual way to define `$cond' is to add ";
$text .= ($mac =~ / /) ? $mac : "`$mac'";
$text .= "\n to `$configure_ac' and run `aclocal' and `autoconf' again.";
$scope = US_GLOBAL;
}
error $where, $text, uniq_scope => $scope;
}
push (@cond_stack, make_conditional_string ($negate, $cond));
return new Automake::Condition (@cond_stack);
}
sub cond_stack_else ($$$)
{
my ($negate, $cond, $where) = @_;
if (! @cond_stack)
{
error $where, "else without if";
return FALSE;
}
$cond_stack[$ Automake::Condition::conditional_negate ($cond_stack[$
if (defined $cond)
{
$cond = make_conditional_string ($negate, $cond);
error ($where, "else reminder ($negate$cond) incompatible with "
. "current conditional: $cond_stack[$#cond_stack]")
if $cond_stack[$ }
return new Automake::Condition (@cond_stack);
}
sub cond_stack_endif ($$$)
{
my ($negate, $cond, $where) = @_;
my $old_cond;
if (! @cond_stack)
{
error $where, "endif without if";
return TRUE;
}
if (defined $cond)
{
$cond = make_conditional_string ($negate, $cond);
error ($where, "endif reminder ($negate$cond) incompatible with "
. "current conditional: $cond_stack[$#cond_stack]")
if $cond_stack[$ }
pop @cond_stack;
return new Automake::Condition (@cond_stack);
}
sub define_pretty_variable ($$$@)
{
my ($var, $cond, $where, @value) = @_;
if (! vardef ($var, $cond))
{
Automake::Variable::define ($var, VAR_AUTOMAKE, '', $cond, "@value",
'', $where, VAR_PRETTY);
rvar ($var)->rdef ($cond)->set_seen;
}
}
sub define_variable ($$$)
{
my ($var, $value, $where) = @_;
define_pretty_variable ($var, TRUE, $where, $value);
}
sub define_files_variable ($\@$$)
{
my ($var, $basename, $extension, $where) = @_;
define_variable ($var,
join (' ', map { "$_.$extension" } @$basename),
$where);
}
sub define_configure_variable ($)
{
my ($var) = @_;
my $pretty = VAR_ASIS;
my $owner = VAR_CONFIGURE;
$pretty = VAR_SILENT if exists $ignored_configure_vars{$var};
$owner = VAR_AUTOMAKE if $var eq 'ANSI2KNR';
Automake::Variable::define ($var, $owner, '', TRUE, subst $var,
'', $configure_vars{$var}, $pretty);
}
sub define_compiler_variable ($)
{
my ($lang) = @_;
my ($var, $value) = ($lang->compiler, $lang->compile);
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 ("LT$var",
"\$(LIBTOOL) $libtool_tag\$(AM_LIBTOOLFLAGS) "
. "\$(LIBTOOLFLAGS) --mode=compile $value",
INTERNAL)
if var ('LIBTOOL');
}
sub define_linker_variable ($)
{
my ($lang) = @_;
my $libtool_tag = '';
$libtool_tag = '--tag=' . $lang->libtool_tag . ' '
if $lang->libtool_tag && exists $libtool_tags{$lang->libtool_tag};
&define_variable ($lang->lder, $lang->ld, INTERNAL);
&define_variable ($lang->linker,
((var ('LIBTOOL') ?
"\$(LIBTOOL) $libtool_tag\$(AM_LIBTOOLFLAGS) "
. "\$(LIBTOOLFLAGS) --mode=link " : '')
. $lang->link),
INTERNAL);
}
sub define_per_target_linker_variable ($$)
{
my ($linker, $target) = @_;
return "${target}_LINK"
if set_seen "${target}_LINK";
my $xlink = $linker ? $linker : 'LINK';
my $lang = $link_languages{$xlink};
prog_error "Unknown language for linker variable `$xlink'"
unless $lang;
my $link_command = $lang->link;
if (var 'LIBTOOL')
{
my $libtool_tag = '';
$libtool_tag = '--tag=' . $lang->libtool_tag . ' '
if $lang->libtool_tag && exists $libtool_tags{$lang->libtool_tag};
$link_command =
"\$(LIBTOOL) $libtool_tag\$(AM_LIBTOOLFLAGS) \$(LIBTOOLFLAGS) "
. "--mode=link " . $link_command;
}
my $orig_command = $link_command;
my @flags = (@{$lang->flags}, 'LDFLAGS');
push @flags, 'LIBTOOLFLAGS' if var 'LIBTOOL';
for my $flag (@flags)
{
my $val = "${target}_$flag";
$link_command =~ s/\(AM_$flag\)/\($val\)/
if set_seen ($val);
}
return $lang->linker
if $link_command eq $orig_command;
&define_variable ("${target}_LINK", $link_command, INTERNAL);
return "${target}_LINK";
}
sub check_trailing_slash ($\$)
{
my ($where, $line) = @_;
return 0 if $$line =~ /$IGNORE_PATTERN/o;
msg "syntax", $where, "whitespace following trailing backslash"
if $$line =~ s/\\\s+\n$/\\\n/;
return $$line =~ /\\$/;
}
sub read_am_file ($$)
{
my ($amfile, $where) = @_;
my $am_file = new Automake::XFile ("< $amfile");
verb "reading $amfile";
my $mtime = mtime $amfile;
$output_deps_greatest_timestamp = $mtime
if $mtime > $output_deps_greatest_timestamp;
my $spacing = '';
my $comment = '';
my $blank = 0;
my $saw_bk = 0;
my $var_look = VAR_ASIS;
use constant IN_VAR_DEF => 0;
use constant IN_RULE_DEF => 1;
use constant IN_COMMENT => 2;
my $prev_state = IN_RULE_DEF;
while ($_ = $am_file->getline)
{
$where->set ("$amfile:$.");
if (/$IGNORE_PATTERN/o)
{
}
elsif (/$WHITE_PATTERN/o)
{
error $where, "blank line following trailing backslash"
if $saw_bk;
$spacing = "\n";
$blank = 1;
if ($comment ne '')
{
$output_vars .= $comment;
$comment = '';
}
}
elsif (/$COMMENT_PATTERN/o)
{
$spacing = "\n" unless $blank;
$blank = 1;
$comment .= $spacing . $_;
$spacing = '';
$prev_state = IN_COMMENT;
}
else
{
last;
}
$saw_bk = check_trailing_slash ($where, $_);
}
my @saved_cond_stack = @cond_stack;
my $cond = new Automake::Condition (@cond_stack);
my $last_var_name = '';
my $last_var_type = '';
my $last_var_value = '';
my $last_where;
while ($_)
{
$where->set ("$amfile:$.");
chomp;
$_ .= "\n";
$_ =~ s/\@MAINT\@//g
unless $seen_maint_mode;
my $new_saw_bk = check_trailing_slash ($where, $_);
if (/$IGNORE_PATTERN/o)
{
$new_saw_bk = $saw_bk;
}
elsif (/$WHITE_PATTERN/o)
{
$spacing = "\n";
error $where, "blank line following trailing backslash"
if $saw_bk;
}
elsif (/$COMMENT_PATTERN/o)
{
error $where, "comment following trailing backslash"
if $saw_bk && $comment eq '';
$comment .= $spacing . $_;
$spacing = '';
$prev_state = IN_COMMENT;
}
elsif ($saw_bk)
{
if ($prev_state == IN_RULE_DEF)
{
my $cond = new Automake::Condition @cond_stack;
$output_trailer .= $cond->subst_string;
$output_trailer .= $_;
}
elsif ($prev_state == IN_COMMENT)
{
s/^ $comment .= $spacing . $_;
}
else {
$last_var_value .= ' '
unless $last_var_value =~ /\s$/;
$last_var_value .= $_;
if (!/\\$/)
{
Automake::Variable::define ($last_var_name, VAR_MAKEFILE,
$last_var_type, $cond,
$last_var_value, $comment,
$last_where, VAR_ASIS)
if $cond != FALSE;
$comment = $spacing = '';
}
}
}
elsif (/$IF_PATTERN/o)
{
$cond = cond_stack_if ($1, $2, $where);
}
elsif (/$ELSE_PATTERN/o)
{
$cond = cond_stack_else ($1, $2, $where);
}
elsif (/$ENDIF_PATTERN/o)
{
$cond = cond_stack_endif ($1, $2, $where);
}
elsif (/$RULE_PATTERN/o)
{
$prev_state = IN_RULE_DEF;
Automake::Rule::define ($1, $amfile, RULE_USER, $cond, $where);
check_variable_expansions ($_, $where);
$output_trailer .= $comment . $spacing;
my $cond = new Automake::Condition @cond_stack;
$output_trailer .= $cond->subst_string;
$output_trailer .= $_;
$comment = $spacing = '';
}
elsif (/$ASSIGNMENT_PATTERN/o)
{
$prev_state = IN_VAR_DEF;
$last_var_name = $1;
$last_var_type = $2;
$last_var_value = $3;
$last_where = $where->clone;
if ($3 ne '' && substr ($3, -1) eq "\\")
{
$last_var_value = $3 . "\n";
}
$var_look = VAR_PRETTY if length ($last_var_value) >= 1000;
if (!/\\$/)
{
Automake::Variable::define ($last_var_name, VAR_MAKEFILE,
$last_var_type, $cond,
$last_var_value, $comment,
$last_where, $var_look)
if $cond != FALSE;
$comment = $spacing = '';
$var_look = VAR_ASIS;
}
}
elsif (/$INCLUDE_PATTERN/o)
{
my $path = $1;
if ($path =~ s/^\$\(top_srcdir\)\///)
{
push (@include_stack, "\$\(top_srcdir\)/$path");
push_dist_common ("\$\(top_srcdir\)/$path");
}
else
{
$path =~ s/\$\(srcdir\)\///;
push (@include_stack, "\$\(srcdir\)/$path");
push_dist_common ("\$\(srcdir\)/$path");
$path = $relative_dir . "/" . $path if $relative_dir ne '.';
}
$where->push_context ("`$path' included from here");
&read_am_file ($path, $where);
$where->pop_context;
}
else
{
$prev_state = IN_RULE_DEF;
check_variable_expansions ($_, $where);
$output_trailer .= $comment . $spacing;
my $cond = new Automake::Condition @cond_stack;
$output_trailer .= $cond->subst_string;
$output_trailer .= $_;
$comment = $spacing = '';
error $where, "`#' comment at start of rule is unportable"
if $_ =~ /^\t\s*\ }
$saw_bk = $new_saw_bk;
$_ = $am_file->getline;
}
$output_trailer .= $comment;
error ($where, "trailing backslash on last line")
if $saw_bk;
error ($where, (@cond_stack ? "unterminated conditionals: @cond_stack"
: "too many conditionals closed in include file"))
if "@saved_cond_stack" ne "@cond_stack";
}
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);
}
$output_vars .= $comments . $rules;
}
sub read_main_am_file
{
my ($amfile) = @_;
prog_error (macros_dump () . "variable defined before read_main_am_file")
if (scalar (variables) > 0);
$output_vars = ("# $in_file_name generated by automake "
. $VERSION . " from $am_file_name.\n");
$output_vars .= '# ' . subst ('configure_input') . "\n";
$output_vars .= $gen_copyright;
&define_standard_variables;
&read_am_file ($amfile, new Automake::Location);
}
sub flatten
{
$_ = shift;
s/\\\n//somg;
s/\s+/ /g;
s/^ //;
s/ $//;
return $_;
}
sub transform($$)
{
my ($token, $transform) = @_;
if (substr ($token, 0, 1) eq '%')
{
my $cond = (substr ($token, 1, 1) eq '?') ? 1 : 0;
$token = substr ($token, 1 + $cond, -1);
my $val = $transform->{$token};
prog_error "Unknown %token% `$token'" unless defined $val;
if ($cond)
{
return $val ? 'TRUE' : 'FALSE';
}
else
{
return $val;
}
}
my $neg = (substr ($token, 1, 1) eq '!') ? 1 : 0;
$token = substr ($token, 1 + $neg, -1);
my $val = $transform->{$token};
prog_error "Unknown ?token? `$token' (neg = $neg)" unless defined $val;
return (!!$val == $neg) ? '##%' : '';
}
sub make_paragraphs ($%)
{
my ($file, %transform) = @_;
%transform = ('CYGNUS' => !! option 'cygnus',
'MAINTAINER-MODE'
=> $seen_maint_mode ? subst ('MAINTAINER_MODE_TRUE') : '',
'BZIP2' => !! option 'dist-bzip2',
'COMPRESS' => !! option 'dist-tarZ',
'GZIP' => ! option 'no-dist-gzip',
'SHAR' => !! option 'dist-shar',
'ZIP' => !! option 'dist-zip',
'INSTALL-INFO' => ! option 'no-installinfo',
'INSTALL-MAN' => ! option 'no-installman',
'CK-NEWS' => !! option 'check-news',
'SUBDIRS' => !! var ('SUBDIRS'),
'TOPDIR_P' => $relative_dir eq '.',
'BUILD' => ($seen_canonical >= AC_CANONICAL_BUILD),
'HOST' => ($seen_canonical >= AC_CANONICAL_HOST),
'TARGET' => ($seen_canonical >= AC_CANONICAL_TARGET),
'LIBTOOL' => !! var ('LIBTOOL'),
'NONLIBTOOL' => 1,
'FIRST' => ! $transformed_files{$file},
%transform);
$transformed_files{$file} = 1;
$_ = $am_file_cache{$file};
if (! defined $_)
{
verb "reading $file";
my $fc_file = new Automake::XFile "< $file";
my $saved_dollar_slash = $/;
undef $/;
$_ = $fc_file->getline;
$/ = $saved_dollar_slash;
$fc_file->close;
s/(?:$IGNORE_PATTERN|(?<=\n\n)\n+)//gom;
$am_file_cache{$file} = $_;
}
s/(?:%\??[\w\-]+%|\?!?[\w\-]+\?)/transform($&, \%transform)/ge;
s/^[ \t]*(?:
my @lines = split (/(?<!\\)\n/, $_);
my @res;
while (defined ($_ = shift @lines))
{
my $paragraph = $_;
if (/$RULE_PATTERN/smo)
{
while (defined ($_ = shift @lines) && $_ =~ /^\t/)
{
$paragraph .= "\n$_";
}
unshift (@lines, $_);
}
elsif (/$COMMENT_PATTERN/smo)
{
while (defined ($_ = shift @lines)
&& $_ =~ /$COMMENT_PATTERN/smo)
{
$paragraph .= "\n$_";
}
unshift (@lines, $_);
}
push @res, $paragraph;
}
return @res;
}
sub file_contents_internal ($$$%)
{
my ($is_am, $file, $where, %transform) = @_;
$where->set ($file);
my $result_vars = '';
my $result_rules = '';
my $comment = '';
my $spacing = '';
my $is_rule = 0; my $discard_rule = 0;
my @saved_cond_stack = @cond_stack;
my $cond = new Automake::Condition (@cond_stack);
foreach (make_paragraphs ($file, %transform))
{
$where->set ($file);
error $where, "blank line following trailing backslash:\n$_"
if /\\$/;
error $where, "comment following trailing backslash:\n$_"
if /\\
if (/^$/)
{
$is_rule = 0;
$spacing = "\n";
}
elsif (/$COMMENT_PATTERN/mso)
{
$is_rule = 0;
$comment = "$_\n";
}
elsif (/$INCLUDE_PATTERN/o)
{
if ($cond != FALSE)
{
my $file = ($is_am ? "$libdir/am/" : '') . $1;
$where->push_context ("`$file' included from here");
my ($com, $vars, $rules)
= file_contents_internal ($is_am, $file, $where, %transform);
$where->pop_context;
$comment .= $com;
$result_vars .= $vars;
$result_rules .= $rules;
}
}
elsif (/$IF_PATTERN/o)
{
$cond = cond_stack_if ($1, $2, $file);
}
elsif (/$ELSE_PATTERN/o)
{
$cond = cond_stack_else ($1, $2, $file);
}
elsif (/$ENDIF_PATTERN/o)
{
$cond = cond_stack_endif ($1, $2, $file);
}
elsif (/$RULE_PATTERN/mso)
{
$is_rule = 1;
$discard_rule = 0;
my $paragraph = $_;
/^(.*?)(?:(?<!\\)\n(\t.*))?$/s;
my ($relationship, $actions) = ($1, $2 || '');
$relationship =~ /^([^:]+\S+) *: *(.*)$/som;
my ($targets, $dependencies) = ($1, $2);
my $flat_deps = &flatten ($dependencies);
my @deps = split (' ', $flat_deps);
foreach (split (' ' , $targets))
{
if (defined $dependencies{$_} && $cond != FALSE)
{
&depend ($_, @deps);
if ($actions{$_})
{
$actions{$_} .= "\n$actions" if $actions;
}
else
{
$actions{$_} = $actions;
}
}
else
{
my @undefined_conds =
Automake::Rule::define ($targets, $file,
$is_am ? RULE_AUTOMAKE : RULE_USER,
$cond, $where);
for my $undefined_cond (@undefined_conds)
{
my $condparagraph = $paragraph;
$condparagraph =~ s/^/$undefined_cond->subst_string/gme;
$result_rules .= "$spacing$comment$condparagraph\n";
}
if (scalar @undefined_conds == 0)
{
$discard_rule = 1;
}
$comment = $spacing = '';
last;
}
}
}
elsif (/$ASSIGNMENT_PATTERN/mso)
{
my ($var, $type, $val) = ($1, $2, $3);
error $where, "variable `$var' with trailing backslash"
if /\\$/;
$is_rule = 0;
Automake::Variable::define ($var,
$is_am ? VAR_AUTOMAKE : VAR_MAKEFILE,
$type, $cond, $val, $comment, $where,
VAR_ASIS)
if $cond != FALSE;
$comment = $spacing = '';
}
else
{
if (! $cond->false && ! ($is_rule && $discard_rule))
{
s/^/$cond->subst_string/gme;
$result_rules .= "$spacing$comment$_\n";
}
$comment = $spacing = '';
}
}
error ($where, @cond_stack ?
"unterminated conditionals: @cond_stack" :
"too many conditionals closed in include file")
if "@saved_cond_stack" ne "@cond_stack";
return ($comment, $result_vars, $result_rules);
}
sub file_contents ($$%)
{
my ($basename, $where, %transform) = @_;
my ($comments, $variables, $rules) =
file_contents_internal (1, "$libdir/am/$basename.am", $where,
%transform);
return "$comments$variables$rules";
}
sub am_primary_prefixes ($$@)
{
my ($primary, $can_dist, @prefixes) = @_;
local $_;
my %valid = map { $_ => 0 } @prefixes;
$valid{'EXTRA'} = 0;
foreach my $var (variables $primary)
{
my $def = $var->def (TRUE);
next if $def && $def->owner != VAR_MAKEFILE;
my $varname = $var->name;
if ($varname =~ /^(nobase_)?(dist_|nodist_)?(.*)_[[:alnum:]]+$/)
{
my ($base, $dist, $X) = ($1 || '', $2 || '', $3 || '');
if ($dist ne '' && ! $can_dist)
{
err_var ($var,
"invalid variable `$varname': `dist' is forbidden");
}
elsif (! defined $valid{$X} && exists $standard_prefix{$X})
{
err_var ($var,
"`${X}dir' is not a legitimate directory " .
"for `$primary'");
}
elsif (! defined $valid{$X} &&
$var->requires_variables ("`$varname' is used", "${X}dir"))
{
}
else
{
$valid{"$base$dist$X"} = 1;
}
}
else
{
prog_error "unexpected variable name: $varname";
}
}
return sort grep { var ($_ . '_' . $primary) } keys %valid;
}
sub am_install_var
{
my (@args) = @_;
my $do_require = 1;
my $can_dist = 0;
my $default_dist = 0;
while (@args)
{
if ($args[0] eq '-noextra')
{
$do_require = 0;
}
elsif ($args[0] eq '-candist')
{
$can_dist = 1;
}
elsif ($args[0] eq '-defaultdist')
{
$default_dist = 1;
$can_dist = 1;
}
elsif ($args[0] !~ /^-/)
{
last;
}
shift (@args);
}
my ($file, $primary, @prefix) = @args;
reject_var $primary, "`$primary' is an anachronism"
unless $primary eq 'JAVA' || $primary eq 'PYTHON';
@prefix = am_primary_prefixes ($primary, $can_dist, @prefix);
my $require_extra;
my @used = ();
my @result = ();
foreach my $X (@prefix)
{
my $nodir_name = $X;
my $one_name = $X . '_' . $primary;
my $one_var = var $one_name;
my $strip_subdir = 1;
if ($nodir_name =~ /^nobase_/)
{
$strip_subdir = 0;
$nodir_name =~ s/^nobase_//;
}
my $dist_p = 0;
if ($can_dist)
{
$dist_p = (($default_dist && $nodir_name !~ /^nodist_/)
|| (! $default_dist && $nodir_name =~ /^dist_/));
$nodir_name =~ s/^(dist|nodist)_//;
}
my $tmpcond = $one_var->conditions->one_cond;
my $where = $one_var->rdef ($tmpcond)->location->clone;
foreach my $locvals ($one_var->value_as_list_recursive (location => 1))
{
my ($loc, $value) = @$locvals;
if ($value =~ /^\@.*\@$/)
{
if ($nodir_name eq 'EXTRA')
{
error ($where,
"`$one_name' contains configure substitution, "
. "but shouldn't");
}
elsif (! defined $configure_vars{$one_name})
{
$require_extra = $one_name
if $do_require;
}
}
else
{
push (@result, $locvals);
}
}
append_exeext { 1 } $one_name
if $primary eq 'PROGRAMS';
next
if $nodir_name eq 'EXTRA';
if ($nodir_name eq 'check')
{
push (@check, '$(' . $one_name . ')');
}
else
{
push (@used, '$(' . $one_name . ')');
}
my $install_p = $nodir_name ne 'noinst' && $nodir_name ne 'check';
my $exec_p = ($nodir_name =~ /$EXEC_DIR_PATTERN/o);
my $check_options_p = $install_p && !! option 'std-options';
$where->push_context ("while processing `$one_name'");
my $distvar = "\$($one_name)";
$distvar = shadow_unconditionally ($one_name, $where)
if ($dist_p && $one_var->has_conditional_contents);
(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);
}
if (@used && $primary ne 'JAVA' && $primary ne 'PYTHON')
{
define_pretty_variable ($primary, TRUE, INTERNAL, @used);
$output_vars .= "\n";
}
err_var ($require_extra,
"`$require_extra' contains configure substitution,\n"
. "but `EXTRA_$primary' not defined")
if ($require_extra && ! var ('EXTRA_' . $primary));
push (@all, '$(' . $primary . ')')
if @used && $primary ne 'JAVA' && $primary ne 'PYTHON';
my %result = ();
for my $pair (@result)
{
my ($loc, $val) = @$pair;
$result{$val} = $loc;
}
my @l = sort keys %result;
return map { [$result{$_}->clone, $_] } @l;
}
my %make_dirs = ();
my $make_dirs_set = 0;
sub is_make_dir
{
my ($dir) = @_;
if (! $make_dirs_set)
{
foreach my $iter (@configure_input_files)
{
$make_dirs{dirname ($iter)} = 1;
}
foreach my $iter (@other_input_files)
{
if ($iter =~ /Makefile\.in$/)
{
$make_dirs{dirname ($iter)} = 1;
}
}
$make_dirs_set = 1;
}
return defined $make_dirs{$dir};
}
sub locate_aux_dir ()
{
if (! $config_aux_dir_set_in_configure_ac)
{
for my $dir (qw (. .. ../..))
{
if (-f "$dir/install-sh")
{
$config_aux_dir = $dir;
last;
}
}
$config_aux_dir = '.' unless $config_aux_dir;
}
$am_config_aux_dir =
'$(top_srcdir)' . ($config_aux_dir eq '.' ? "" : "/$config_aux_dir");
$am_config_aux_dir =~ s,/*$,,;
}
sub maybe_push_required_file
{
my ($dir, $file, $fullfile) = @_;
if ($dir eq $relative_dir)
{
push_dist_common ($file);
return 1;
}
elsif ($relative_dir eq '.' && ! &is_make_dir ($dir))
{
$fullfile = '$(srcdir)/' . $fullfile
if $dir =~ m,^\.\.(?:$|/),;
push_dist_common ($fullfile);
return 1;
}
return 0;
}
my %required_file_not_found = ();
sub require_file_internal ($$$@)
{
my ($where, $mystrict, $dir, @files) = @_;
foreach my $file (@files)
{
my $fullfile = "$dir/$file";
my $found_it = 0;
my $dangling_sym = 0;
if (-l $fullfile && ! -f $fullfile)
{
$dangling_sym = 1;
}
elsif (dir_has_case_matching_file ($dir, $file))
{
$found_it = 1;
maybe_push_required_file ($dir, $file, $fullfile);
}
if ($found_it && (! $add_missing || ! $force_missing))
{
next;
}
else
{
if (! $found_it)
{
next if defined $required_file_not_found{$fullfile};
$required_file_not_found{$fullfile} = 1;
}
if ($strictness >= $mystrict)
{
if ($dangling_sym && $add_missing)
{
unlink ($fullfile);
}
my $trailer = '';
my $suppress = 0;
my $message = "required file `$fullfile' not found";
if ($add_missing)
{
if (-f "$libdir/$file")
{
$suppress = 1;
$message = "installing `$fullfile'";
unlink ($fullfile) if -f $fullfile;
if ($symlink_exists && ! $copy_missing)
{
if (! symlink ("$libdir/$file", $fullfile))
{
$suppress = 0;
$trailer = "; error while making link: $!";
}
}
elsif (system ('cp', "$libdir/$file", $fullfile))
{
$suppress = 0;
$trailer = "\n error while copying";
}
reset_dir_cache ($dir);
}
if (! maybe_push_required_file (dirname ($fullfile),
$file, $fullfile))
{
if (! $found_it && ! $automake_will_process_aux_dir)
{
error ($where, 'Please make a full run of automake'
. " so $fullfile gets distributed.");
}
}
}
else
{
$trailer = "\n `automake --add-missing' can install `$file'"
if -f "$libdir/$file";
}
next
if $found_it && $force_missing;
next
if !$suppress && rule $file;
msg ($suppress ? 'note' : 'error', $where, "$message$trailer");
}
}
}
}
sub require_file ($$@)
{
my ($where, $mystrict, @files) = @_;
require_file_internal ($where, $mystrict, $relative_dir, @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);
}
sub require_libsource_with_macro ($$$@)
{
my ($cond, $macro, $mystrict, @files) = @_;
$macro = rvar ($macro) unless ref $macro;
if ($config_libobj_dir)
{
require_file_internal ($macro->rdef ($cond)->location, $mystrict,
$config_libobj_dir, @files);
}
else
{
require_file ($macro->rdef ($cond)->location, $mystrict, @files);
}
}
sub require_conf_file ($$@)
{
my ($where, $mystrict, @files) = @_;
require_file_internal ($where, $mystrict, $config_aux_dir, @files);
}
sub require_conf_file_with_macro ($$$@)
{
my ($cond, $macro, $mystrict, @files) = @_;
require_conf_file (rvar ($macro)->rdef ($cond)->location,
$mystrict, @files);
}
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;
define_pretty_variable ('am__dirstamp', TRUE, INTERNAL,
'$(am__leading_dot)dirstamp');
$clean_files{$dirstamp} = DIST_CLEAN;
$output_rules .= ("$dirstamp:\n"
. "\t\@\$(MKDIR_P) $directory\n"
. "\t\@: > $dirstamp\n");
return $dirstamp;
}
sub require_build_directory_maybe ($)
{
my $file = shift;
my $directory = dirname ($file);
if ($directory ne '.')
{
return require_build_directory ($directory);
}
else
{
return '';
}
}
sub push_dist_common
{
prog_error "push_dist_common run after handle_dist"
if $handle_dist_run;
Automake::Variable::define ('DIST_COMMON', VAR_AUTOMAKE, '+', TRUE, "@_",
'', INTERNAL, VAR_PRETTY);
}
sub generate_makefile ($$)
{
my ($makefile_am, $makefile_in) = @_;
initialize_per_input;
buffer_messages ('warning');
$am_file_name = basename ($makefile_am);
$in_file_name = basename ($makefile_in);
my ($makefile, @inputs) = split (/:/, $output_files{$makefile_in});
$relative_dir = dirname ($makefile);
$am_relative_dir = dirname ($makefile_am);
$topsrcdir = backname ($relative_dir);
read_main_am_file ($makefile_am);
if (handle_options)
{
flush_messages;
return;
}
flush_messages;
foreach my $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
{
my $v = var $var;
if ($v)
{
my $def = $v->def (TRUE);
prog_error "$var not defined in condition TRUE"
unless $def;
reject_var $var, "`$var' should not be defined"
if $def->owner != VAR_AUTOMAKE;
}
}
msg_var ('obsolete', 'INCLUDES',
"`INCLUDES' is the old name for `AM_CPPFLAGS' (or `*_CPPFLAGS')")
if var ('INCLUDES');
define_variable ('subdir', $relative_dir, INTERNAL);
define_pretty_variable ('SUBDIRS', TRUE, INTERNAL, '')
if var 'DIST_SUBDIRS' && ! var 'SUBDIRS';
check_cygnus;
check_gnu_standards;
check_gnits_standards;
handle_configure ($makefile_am, $makefile_in, $makefile, @inputs);
handle_gettext;
handle_libraries;
handle_ltlibraries;
handle_programs;
handle_scripts;
handle_compile;
handle_languages;
handle_libtool;
define_pretty_variable ('SOURCES', TRUE, INTERNAL, @sources);
if (! option 'no-dist')
{
define_pretty_variable ('DIST_SOURCES', TRUE, INTERNAL, @dist_sources);
}
handle_multilib;
handle_texinfo;
handle_emacs_lisp;
handle_python;
handle_java;
handle_man_pages;
handle_data;
handle_headers;
handle_subdirs;
handle_tags;
handle_minor_options;
handle_tests;
handle_dist;
handle_footer;
do_check_merge_target;
handle_all ($makefile);
if (var ('lib_LTLIBRARIES') && var ('bin_PROGRAMS'))
{
$output_rules .= "install-binPROGRAMS: install-libLTLIBRARIES\n\n";
}
handle_install;
handle_clean ($makefile);
handle_factored_dependencies;
$output_vars .= output_variables;
check_typos;
my ($out_file) = $output_directory . '/' . $makefile_in;
if ($exit_code != 0)
{
verb "not writing $out_file because of earlier errors";
return;
}
if (! -d ($output_directory . '/' . $am_relative_dir))
{
mkdir ($output_directory . '/' . $am_relative_dir, 0755);
}
my $output =
"$output_vars$output_all$output_header$output_rules$output_trailer";
my $timestamp = mtime $out_file;
if (! $force_generation
&& $configure_deps_greatest_timestamp < $timestamp
&& $output_deps_greatest_timestamp < $timestamp
&& $output eq contents ($out_file))
{
verb "$out_file unchanged";
return;
}
if (-e $out_file)
{
unlink ($out_file)
or fatal "cannot remove $out_file: $!\n";
}
my $gm_file = new Automake::XFile "> $out_file";
verb "creating $out_file";
print $gm_file $output;
}
sub usage ()
{
print "Usage: $0 [OPTION] ... [Makefile]...
Generate Makefile.in for configure from Makefile.am.
Operation modes:
--help print this help, then exit
--version print version number, then exit
-v, --verbose verbosely list files processed
--no-force only update Makefile.in's that are out of date
-W, --warnings=CATEGORY report the warnings falling in CATEGORY
Dependency tracking:
-i, --ignore-deps disable dependency tracking code
--include-deps enable dependency tracking code
Flavors:
--cygnus assume program is part of Cygnus-style tree
--foreign set strictness to foreign
--gnits set strictness to gnits
--gnu set strictness to gnu
Library files:
-a, --add-missing add missing standard files to package
--libdir=DIR directory storing library files
-c, --copy with -a, copy missing files (default is symlink)
-f, --force-missing force update of standard files
";
Automake::ChannelDefs::usage;
my ($last, @lcomm);
$last = '';
foreach my $iter (sort ((@common_files, @common_sometimes)))
{
push (@lcomm, $iter) unless $iter eq $last;
$last = $iter;
}
my @four;
print "\nFiles which are automatically distributed, if found:\n";
format USAGE_FORMAT =
@<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
$four[0], $four[1], $four[2], $four[3]
.
$~ = "USAGE_FORMAT";
my $cols = 4;
my $rows = int(@lcomm / $cols);
my $rest = @lcomm % $cols;
if ($rest)
{
$rows++;
}
else
{
$rest = $cols;
}
for (my $y = 0; $y < $rows; $y++)
{
@four = ("", "", "", "");
for (my $x = 0; $x < $cols; $x++)
{
last if $y + 1 == $rows && $x == $rest;
my $idx = (($x > $rest)
? ($rows * $rest + ($rows - 1) * ($x - $rest))
: ($rows * $x));
$idx += $y;
$four[$x] = $lcomm[$idx];
}
write;
}
print "\nReport bugs to <bug-automake\@gnu.org>.\n";
exit 0;
}
sub version ()
{
print <<EOF;
automake (GNU $PACKAGE) $VERSION
Written by Tom Tromey <tromey\@redhat.com>
and Alexandre Duret-Lutz <adl\@gnu.org>.
Copyright 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
EOF
exit 0;
}
sub parse_arguments ()
{
set_strictness ('gnu');
my $cli_where = new Automake::Location;
my %cli_options =
(
'libdir=s' => \$libdir,
'gnu' => sub { set_strictness ('gnu'); },
'gnits' => sub { set_strictness ('gnits'); },
'cygnus' => sub { set_global_option ('cygnus', $cli_where); },
'foreign' => sub { set_strictness ('foreign'); },
'include-deps' => sub { unset_global_option ('no-dependencies'); },
'i|ignore-deps' => sub { set_global_option ('no-dependencies',
$cli_where); },
'no-force' => sub { $force_generation = 0; },
'f|force-missing' => \$force_missing,
'o|output-dir=s' => \$output_directory,
'a|add-missing' => \$add_missing,
'c|copy' => \$copy_missing,
'v|verbose' => sub { setup_channel 'verb', silent => 0; },
'W|warnings=s' => \&parse_warnings,
'Werror' => sub { parse_warnings 'W', 'error'; },
'Wno-error' => sub { parse_warnings 'W', 'no-error'; },
);
use Getopt::Long;
Getopt::Long::config ("bundling", "pass_through");
my %cli_options_1st_pass =
(
'version' => \&version,
'help' => \&usage,
map { $_ => sub {} } (keys %cli_options)
);
my @ARGV_backup = @ARGV;
Getopt::Long::GetOptions %cli_options_1st_pass
or exit 1;
@ARGV = @ARGV_backup;
Getopt::Long::GetOptions %cli_options, 'version' => sub {}, 'help' => sub {}
or exit 1;
if (defined $output_directory)
{
msg 'obsolete', "`--output-dir' is deprecated\n";
}
else
{
$output_directory = '.';
}
return unless @ARGV;
if ($ARGV[0] =~ /^-./)
{
my %argopts;
for my $k (keys %cli_options)
{
if ($k =~ /(.*)=s$/)
{
map { $argopts{(length ($_) == 1)
? "-$_" : "--$_" } = 1; } (split (/\|/, $1));
}
}
if ($ARGV[0] eq '--')
{
shift @ARGV;
}
elsif (exists $argopts{$ARGV[0]})
{
fatal ("option `$ARGV[0]' requires an argument\n"
. "Try `$0 --help' for more information.");
}
else
{
fatal ("unrecognized option `$ARGV[0]'.\n"
. "Try `$0 --help' for more information.");
}
}
my $errspec = 0;
foreach my $arg (@ARGV)
{
fatal ("empty argument\nTry `$0 --help' for more information.")
if ($arg eq '');
my ($local, @rest) = split (/:/, $arg);
@rest = ("$local.in",) unless @rest;
my $input = locate_am @rest;
if ($input)
{
push @input_files, $input;
$output_files{$input} = join (':', ($local, @rest));
}
else
{
error "no Automake input file found for `$arg'";
$errspec = 1;
}
}
fatal "no input file found among supplied arguments"
if $errspec && ! @input_files;
}
parse_WARNINGS;
parse_arguments;
$configure_ac = require_configure_ac;
scan_autoconf_files;
if (! @input_files)
{
my $msg = '';
$msg = "\nDid you forget AC_CONFIG_FILES([Makefile]) in $configure_ac?"
if -f 'Makefile.am';
fatal ("no `Makefile.am' found for any configure output$msg");
}
foreach my $file (@input_files)
{
($am_file = $file) =~ s/\.in$//;
if (! -f ($am_file . '.am'))
{
error "`$am_file.am' does not exist";
}
else
{
dup_channel_setup;
generate_makefile ($am_file . '.am', $file);
drop_channel_setup;
}
}
exit $exit_code;