summaryrefslogtreecommitdiff
path: root/bin/automake.in
diff options
context:
space:
mode:
Diffstat (limited to 'bin/automake.in')
-rw-r--r--bin/automake.in47
1 files changed, 33 insertions, 14 deletions
diff --git a/bin/automake.in b/bin/automake.in
index 7b3d1c9c4..b55b5080d 100644
--- a/bin/automake.in
+++ b/bin/automake.in
@@ -1453,9 +1453,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
@@ -1506,17 +1506,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)
{