From d46057277f3b805e5f198e31fc81a892bf5c9141 Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Thu, 10 Mar 2016 09:04:09 +0100 Subject: [PATCH] Pass down inclusion directories to source file generators The source file generators sometimes use $(CC) to post-process generated source, and getting the inclusion directories may be necessary at times, so we pass them down. RT#4406 Reviewed-by: Rich Salz --- Configurations/common.tmpl | 11 +++++++++-- Configurations/unix-Makefile.tmpl | 5 +++-- Configurations/windows-makefile.tmpl | 5 +++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Configurations/common.tmpl b/Configurations/common.tmpl index c2362d0d93..d89817efd2 100644 --- a/Configurations/common.tmpl +++ b/Configurations/common.tmpl @@ -32,17 +32,24 @@ @newlist; } + # dogenerate is responsible for producing all the recipes that build + # generated source files. It recurses in case a dependency is also a + # generated source file. sub dogenerate { my $src = shift; return "" if $cache{$src}; + my $obj = shift; + my $bin = shift; my %opts = @_; if ($unified_info{generate}->{$src}) { $OUT .= generatesrc(src => $src, generator => $unified_info{generate}->{$src}, deps => $unified_info{depends}->{$src}, + incs => [ @{$unified_info{includes}->{$bin}}, + @{$unified_info{includes}->{$obj}} ], %opts); foreach (@{$unified_info{depends}->{$src}}) { - dogenerate($_, %opts); + dogenerate($_, $obj, $bin, %opts); } } $cache{$src} = 1; @@ -65,7 +72,7 @@ %opts); foreach ((@{$unified_info{sources}->{$obj}}, @{$unified_info{depends}->{$obj}})) { - dogenerate($_, %opts); + dogenerate($_, $obj, $bin, %opts); } } $cache{$obj} = 1; diff --git a/Configurations/unix-Makefile.tmpl b/Configurations/unix-Makefile.tmpl index 02e8cb4654..114a4be2be 100644 --- a/Configurations/unix-Makefile.tmpl +++ b/Configurations/unix-Makefile.tmpl @@ -825,6 +825,7 @@ configdata.pm: {- $config{build_file_template} -} $(SRCDIR)/Configurations/commo sub generatesrc { my %args = @_; my $generator = join(" ", @{$args{generator}}); + my $incs = join("", map { " -I".$_ } @{$args{incs}}); if ($args{src} !~ /\.[sS]$/) { return <<"EOF"; @@ -851,7 +852,7 @@ EOF $target: $args{generator}->[0] ( trap "rm -f \$@.S" INT; \\ $generator \$@.S; \\ - \$(CC) \$(CFLAGS) -E -P \$@.S > \$@ && rm -f \$@.S ) + \$(CC) \$(CFLAGS) $incs -E -P \$@.S > \$@ && rm -f \$@.S ) EOF } # Otherwise.... @@ -862,7 +863,7 @@ EOF } return <<"EOF"; $args{src}: $args{generator}->[0] - \$(CC) \$(CFLAGS) -E -P \$< > \$@ + \$(CC) \$(CFLAGS) $incs -E -P \$< > \$@ EOF } } diff --git a/Configurations/windows-makefile.tmpl b/Configurations/windows-makefile.tmpl index 7b78f9f4d9..967146fa29 100644 --- a/Configurations/windows-makefile.tmpl +++ b/Configurations/windows-makefile.tmpl @@ -171,6 +171,7 @@ configdata.pm: {- $config{build_file_template} -} $(SRCDIR)\Configure my %args = @_; (my $target = $args{src}) =~ s/\.[sS]$/.asm/; my $generator = join(" ", @{$args{generator}}); + my $incs = join("", map { " /I ".$_ } @{$args{incs}}); if ($target !~ /\.asm$/) { return <<"EOF"; @@ -195,7 +196,7 @@ $target: $args{generator}->[0] set ASM=\$(AS) set CC=\$(CC) $generator \$@.S - \$(CC) \$(CFLAGS) /EP /C \$@.S > \$@ + \$(CC) \$(CFLAGS) $incs /EP /C \$@.S > \$@ del /Q \$@.S EOF } @@ -209,7 +210,7 @@ EOF } return <<"EOF"; $target: $args{generator}->[0] - \$(CC) \$(CFLAGS) /EP /C \$< > \$@ + \$(CC) \$(CFLAGS) $incs /EP /C \$< > \$@ EOF } } -- 2.39.5