summaryrefslogtreecommitdiff
path: root/source4/build
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-10-10 23:58:29 +0200
committerStefan Metzmacher <metze@samba.org>2007-12-21 05:42:55 +0100
commita33d97341f2e2afa2e7e6994eb7f14e848408fb7 (patch)
tree2cbe0876065c9313a980595c5bb5856d8658cbde /source4/build
parent5c4a4b45667a714cb1154f20eccb56d00c1163a7 (diff)
downloadsamba-a33d97341f2e2afa2e7e6994eb7f14e848408fb7.tar.gz
samba-a33d97341f2e2afa2e7e6994eb7f14e848408fb7.tar.bz2
samba-a33d97341f2e2afa2e7e6994eb7f14e848408fb7.zip
r25617: Make sure system include paths come after samba include paths. Patch from Timur Bakeyev.
(This used to be commit 7565c4a0dd304312898839df6789f7338cc1ea63)
Diffstat (limited to 'source4/build')
-rwxr-xr-xsource4/build/smb_build/cflags.pm37
1 files changed, 23 insertions, 14 deletions
diff --git a/source4/build/smb_build/cflags.pm b/source4/build/smb_build/cflags.pm
index e6cdff02cd..95f9cac7db 100755
--- a/source4/build/smb_build/cflags.pm
+++ b/source4/build/smb_build/cflags.pm
@@ -6,8 +6,15 @@
package cflags;
use strict;
-sub create_cflags($$$$)
-{
+use sort 'stable';
+
+sub by_path {
+ return 1 if($a =~ m#^\-I/#);
+ return -1 if($b =~ m#^\-I/#);
+ return 0;
+}
+
+sub create_cflags($$$$) {
my $CTX = shift;
my $srcdir = shift;
my $builddir = shift;
@@ -15,27 +22,29 @@ sub create_cflags($$$$)
open(CFLAGS_TXT,">$file") || die ("Can't open `$file'\n");
- my $src_ne_build = 0;
- $src_ne_build = 1 unless ($srcdir eq $builddir);
+ my $src_ne_build = ($srcdir ne $builddir) ? 1 : 0;
foreach my $key (values %{$CTX}) {
next unless defined ($key->{OBJ_LIST});
-
next unless defined ($key->{FINAL_CFLAGS});
- next unless ($#{$key->{FINAL_CFLAGS}} >= 0);
+ next unless (@{$key->{FINAL_CFLAGS}} > 0);
# Rewrite CFLAGS so that both the source and the build
# directories are in the path.
- my $cflags = "";
- foreach my $flag (@{$key->{FINAL_CFLAGS}}) {
- my $dir;
- if ($src_ne_build and ($dir) = ($flag =~ /^-I([^\/].*)$/)) {
- $cflags .= " -I$builddir/$dir";
- $cflags .= " -I$srcdir/$dir";
- } else {
- $cflags .= " $flag";
+ my @cflags = ();
+ foreach my $flag (sort by_path @{$key->{FINAL_CFLAGS}}) {
+ if($src_ne_build) {
+ if($flag =~ m#^-I([^/].*$)#) {
+ my $dir = $1;
+ $dir =~ s#^\$\((?:src|build)dir\)/?##;
+ push(@cflags, "-I$builddir/$dir", "-I$srcdir/$dir");
+ next;
+ }
}
+ push(@cflags, $flag);
}
+
+ my $cflags = join(' ', @cflags);
foreach (@{$key->{OBJ_LIST}}) {
my $ofile = $_;