diff options
author | Stefano Lattarini <stefano.lattarini@gmail.com> | 2015-01-02 14:47:36 +0100 |
---|---|---|
committer | Stefano Lattarini <stefano.lattarini@gmail.com> | 2015-01-04 18:30:44 +0100 |
commit | 860d21b8854eb61dd79f37f1be564af7efa916c6 (patch) | |
tree | d5d8803140e6bef3c7fe4678b5592a2a11bbdda9 /bin/automake.in | |
parent | e60e8498f589edbf9d7ab016df7c2e1dc775076d (diff) | |
download | automake-860d21b8854eb61dd79f37f1be564af7efa916c6.tar.gz |
compile: don't place built object files in $(srcdir), ever ...
... even when a source file is specified as '$(srdir)/foo.c' or
'$(top_srcdir)/bar.c'. And ditto for dependency-tracking makefile
fragments (those under '.deps' directories).
Such issues used to occur when the 'subdir-objects' option was given.
This change should fix the second and last part of automake bug#13928.
See also bug#16375 and bug#15293.
* NEWS: Update.
* bin/automake.in (handle_single_transform): Make sure object files
and dependency-tracking makefile fragments coming from source like
'$(srcdir)/foo.c' and '$(top_srcdir)/bar.c' are placed respectively
under $(builddir) and $(top_builddir).
* t/subobj-vpath-pr13928.sh: Enhance to expose even more aspects
of the bug we've just fixed.
* t/subobj-pr13928-more-langs.sh: New test, similar to the one above,
but with non-C languages as well.
* t/list-of-tests.mk (XFAIL_TESTS): Remove 'subobj-vpath-pr13928.sh',
it's now supposed to pass.
(handwritten_TESTS): Add 'subobj-pr13928-more-langs.sh'.
Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
Diffstat (limited to 'bin/automake.in')
-rw-r--r-- | bin/automake.in | 50 |
1 files changed, 34 insertions, 16 deletions
diff --git a/bin/automake.in b/bin/automake.in index f19be92bc..d8ecca514 100644 --- a/bin/automake.in +++ b/bin/automake.in @@ -1617,9 +1617,9 @@ sub handle_single_transform my $renamed = 0; my ($linker, $object); - # This records whether we've seen a derived source file (e.g. - # yacc output). - my $derived_source = 0; + # This records whether we've seen a derived source file (e.g., yacc + # or lex output). + my $derived_source; # This holds the 'aggregate context' of the file we are # currently examining. If the file is compiled with @@ -1667,17 +1667,36 @@ sub handle_single_transform # Now extract linker and other info. $linker = $lang->linker; - my $this_obj_ext; - if (defined $source_extension) - { - $this_obj_ext = $source_extension; - $derived_source = 1; - } - else - { - $this_obj_ext = $obj; - } - $object = $base . $this_obj_ext; + my $this_obj_ext; + if (defined $source_extension) + { + $this_obj_ext = $source_extension; + $derived_source = 1; + } + else + { + $this_obj_ext = $obj; + $derived_source = 0; + # Don't ever place built object files in $(srcdir), + # even when sources are specified explicitly as (say) + # '$(srcdir)/foo.c' or '$(top_srcdir)/foo.c'. + # See automake bug#13928. + my @d = split '/', $directory; + if (@d > 0 && option 'subdir-objects') + { + my $d = $d[0]; + if ($d eq '$(srcdir)' or $d eq '${srcdir}') + { + shift @d; + } + elsif ($d eq '$(top_srcdir)' or $d eq '${top_srcdir}') + { + $d[0] = '$(top_builddir)'; + } + $directory = join '/', @d; + } + } + $object = $base . $this_obj_ext; if ($have_per_exec_flags) { @@ -1710,8 +1729,7 @@ sub handle_single_transform $renamed = 1; } - # If rewrite said it was ok, put the object into a - # subdir. + # If rewrite said it was ok, put the object into a subdir. if ($directory ne '') { if ($r == LANG_SUBDIR) |