summaryrefslogtreecommitdiff
path: root/bin/automake.in
diff options
context:
space:
mode:
authorMathieu Lirzin <mthl@gnu.org>2017-08-31 19:23:42 +0200
committerMathieu Lirzin <mthl@gnu.org>2017-08-31 19:23:42 +0200
commitf389ecb89acb7f51b6a9e8f41ebad3e45ac905a2 (patch)
tree9380abfd73fe36221b5378562629ef2da539e862 /bin/automake.in
parentcc7231cc3668a387ae36905efca11f9d236c8df6 (diff)
parente94c0186d98d70df2f18c17622ee75f80f95e17b (diff)
downloadautomake-f389ecb89acb7f51b6a9e8f41ebad3e45ac905a2.tar.gz
Merge branch 'minor'
Diffstat (limited to 'bin/automake.in')
-rw-r--r--bin/automake.in168
1 files changed, 143 insertions, 25 deletions
diff --git a/bin/automake.in b/bin/automake.in
index 9c4cb8694..62eb13fe5 100644
--- a/bin/automake.in
+++ b/bin/automake.in
@@ -31,9 +31,8 @@ use strict;
BEGIN
{
- @Automake::perl_libdirs = ('@datadir@/@PACKAGE@-@APIVERSION@')
- unless @Automake::perl_libdirs;
- unshift @INC, @Automake::perl_libdirs;
+ unshift (@INC, '@datadir@/@PACKAGE@-@APIVERSION@')
+ unless $ENV{AUTOMAKE_UNINSTALLED};
}
use Automake::Config;
@@ -64,14 +63,68 @@ use Automake::Wrap 'makefile_wrap';
use Automake::Language;
use File::Basename;
use File::Spec;
+use List::Util 'none';
use Carp;
## ----------------------- ##
## Subroutine prototypes. ##
## ----------------------- ##
-#! Prototypes here will automatically be generated by the build system.
-
+sub append_exeext (&$);
+sub check_gnits_standards ();
+sub check_gnu_standards ();
+sub check_trailing_slash ($\$);
+sub check_typos ();
+sub define_files_variable ($\@$$);
+sub define_standard_variables ();
+sub define_verbose_libtool ();
+sub define_verbose_texinfo ();
+sub do_check_merge_target ();
+sub get_number_of_threads ();
+sub handle_compile ();
+sub handle_data ();
+sub handle_dist ();
+sub handle_emacs_lisp ();
+sub handle_factored_dependencies ();
+sub handle_footer ();
+sub handle_gettext ();
+sub handle_headers ();
+sub handle_install ();
+sub handle_java ();
+sub handle_languages ();
+sub handle_libraries ();
+sub handle_libtool ();
+sub handle_ltlibraries ();
+sub handle_makefiles_serial ();
+sub handle_man_pages ();
+sub handle_minor_options ();
+sub handle_options ();
+sub handle_programs ();
+sub handle_python ();
+sub handle_scripts ();
+sub handle_silent ();
+sub handle_subdirs ();
+sub handle_tags ();
+sub handle_targets ();
+sub handle_tests ();
+sub handle_tests_dejagnu ();
+sub handle_texinfo ();
+sub handle_user_recursion ();
+sub initialize_per_input ();
+sub lang_lex_finish ();
+sub lang_sub_obj ();
+sub lang_vala_finish ();
+sub lang_yacc_finish ();
+sub locate_aux_dir ();
+sub parse_arguments ();
+sub scan_aclocal_m4 ();
+sub scan_autoconf_files ();
+sub silent_flag ();
+sub transform ($\%);
+sub transform_token ($\%$);
+sub usage ();
+sub version ();
+sub yacc_lex_finish_helper ();
## ----------- ##
## Constants. ##
@@ -455,6 +508,15 @@ my %dep_files;
# This is a list of all targets to run during "make dist".
my @dist_targets;
+# List of all programs, libraries and ltlibraries as returned
+# by am_install_var
+my @proglist;
+my @liblist;
+my @ltliblist;
+# Blacklist of targets (as canonical base name) for which object file names
+# may not be automatically shortened
+my @dup_shortnames;
+
# Keep track of all programs declared in this Makefile, without
# $(EXEEXT). @substitutions@ are not listed.
my %known_programs;
@@ -575,6 +637,11 @@ sub initialize_per_input ()
@dist_common = ();
$handle_dist_run = 0;
+ @proglist = ();
+ @liblist = ();
+ @ltliblist = ();
+ @dup_shortnames = ();
+
%known_programs = ();
%known_libraries = ();
@@ -1637,14 +1704,47 @@ sub handle_single_transform
# object. In this case we rewrite the object's
# name to ensure it is unique.
- # We choose the name 'DERIVED_OBJECT' to ensure
- # (1) uniqueness, and (2) continuity between
- # invocations. However, this will result in a
- # name that is too long for losing systems, in
- # some situations. So we provide _SHORTNAME to
- # override.
-
- my $dname = $derived;
+ # We choose the name 'DERIVED_OBJECT' to ensure (1) uniqueness,
+ # and (2) continuity between invocations. However, this will
+ # result in a name that is too long for losing systems, in some
+ # situations. So we attempt to shorten automatically, and
+ # provide _SHORTNAME to override as a last resort. If
+ # subdir-object is in effect, it's usually unnecessary to use
+ # the complete 'DERIVED_OBJECT' (that is often the result from
+ # %canon_reldir%/%C% usage) since objects are placed next to
+ # their source file. Generally, this means it is already
+ # unique within that directory (see below for an exception).
+ # Thus, we try to avoid unnecessarily long file names by
+ # stripping the directory components of 'DERIVED_OBJECT'.
+ # This allows avoiding explicit _SHORTNAME usage in many
+ # cases. EXCEPTION: If two (or more) targets in different
+ # directories but with the same base name (after
+ # canonicalization), using target-specific FLAGS, link the
+ # same object, then this logic clashes. Thus, we don't strip
+ # if this is detected.
+ my $dname = $derived;
+ if ($directory ne ''
+ && none { $dname =~ /$_$/ } @dup_shortnames)
+ {
+ # At this point, we don't clear information about what
+ # parts of $derived are truly file name components. We can
+ # determine that by comparing against the canonicalization
+ # of $directory.
+ my $dir = $directory . "/";
+ my $cdir = canonicalize ($dir);
+ my $dir_len = length ($dir);
+ # Make sure we only strip full file name components. This
+ # is done by repeatedly trying to find cdir at the
+ # beginning. Each iteration removes one file name
+ # component from the end of cdir.
+ while ($dir_len > 0 && index ($derived, $cdir) != 0)
+ {
+ # Eventually $dir_len becomes 0.
+ $dir_len = rindex ($dir, "/", $dir_len - 2) + 1;
+ $cdir = substr ($cdir, 0, $dir_len);
+ }
+ $dname = substr ($derived, $dir_len);
+ }
my $var = var ($derived . '_SHORTNAME');
if ($var)
{
@@ -2154,9 +2254,8 @@ sub handle_LIBOBJS_or_ALLOCA
if $relative_dir ne '.';
define_variable ('LIBOBJDIR', "$dir", INTERNAL);
$clean_files{"\$($var)"} = MOSTLY_CLEAN;
- # If LTLIBOBJS is used, we must also clear LIBOBJS (which might
- # be created by libtool as a side-effect of creating LTLIBOBJS).
- $clean_files{"\$($var)"} = MOSTLY_CLEAN if $var =~ s/^LT//;
+ # libtool might create LIBOBJS as a side-effect of using LTLIBOBJS.
+ $clean_files{"\$(LIBOBJS)"} = MOSTLY_CLEAN if $var eq "LTLIBOBJS";
}
return $dir;
@@ -2323,12 +2422,33 @@ sub handle_libtool ()
LTRMS => join ("\n", @libtool_rms));
}
+# Check for duplicate targets
+sub handle_targets ()
+{
+ my %seen = ();
+ my @dups = ();
+ @proglist = am_install_var ('progs', 'PROGRAMS',
+ 'bin', 'sbin', 'libexec', 'pkglibexec',
+ 'noinst', 'check');
+ @liblist = am_install_var ('libs', 'LIBRARIES',
+ 'lib', 'pkglib', 'noinst', 'check');
+ @ltliblist = am_install_var ('ltlib', 'LTLIBRARIES',
+ 'noinst', 'lib', 'pkglib', 'check');
+
+ # Record duplications that may arise after canonicalization of the
+ # base names, in order to prevent object file clashes in the presence
+ # of target-specific *FLAGS
+ my @targetlist = (@proglist, @liblist, @ltliblist);
+ foreach my $pair (@targetlist)
+ {
+ my $base = canonicalize (basename (@$pair[1]));
+ push (@dup_shortnames, $base) if ($seen{$base});
+ $seen{$base} = $base;
+ }
+}
sub handle_programs ()
{
- my @proglist = am_install_var ('progs', 'PROGRAMS',
- 'bin', 'sbin', 'libexec', 'pkglibexec',
- 'noinst', 'check');
return if ! @proglist;
$must_handle_compiled_objects = 1;
@@ -2415,8 +2535,6 @@ sub handle_programs ()
sub handle_libraries ()
{
- my @liblist = am_install_var ('libs', 'LIBRARIES',
- 'lib', 'pkglib', 'noinst', 'check');
return if ! @liblist;
$must_handle_compiled_objects = 1;
@@ -2525,9 +2643,7 @@ sub handle_libraries ()
sub handle_ltlibraries ()
{
- my @liblist = am_install_var ('ltlib', 'LTLIBRARIES',
- 'noinst', 'lib', 'pkglib', 'check');
- return if ! @liblist;
+ return if ! @ltliblist;
$must_handle_compiled_objects = 1;
my @prefix = am_primary_prefixes ('LTLIBRARIES', 0, 'lib', 'pkglib',
@@ -2620,7 +2736,7 @@ sub handle_ltlibraries ()
skip_ac_subst => 1);
}
- foreach my $pair (@liblist)
+ foreach my $pair (@ltliblist)
{
my ($where, $onelib) = @$pair;
@@ -7610,6 +7726,8 @@ sub generate_makefile
handle_configure ($makefile_am, $makefile_in, $makefile, @inputs);
handle_gettext;
+
+ handle_targets;
handle_libraries;
handle_ltlibraries;
handle_programs;