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-06 11:25:54 +0100 |
commit | 1b4c84b80d6099fd6747b129630bbf00c388e0f9 (patch) | |
tree | 2dea95a5a4b38f36c1490db44f76f5ebcf29be8f /bin | |
parent | e3908dd893aadc5e7775ede9a8a24d8667b371b9 (diff) | |
download | automake-1b4c84b80d6099fd6747b129630bbf00c388e0f9.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')
-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 681b3d2a5..dd828da62 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) |