Author: jelmer
Date: 2007-10-10 23:58:29 +0000 (Wed, 10 Oct 2007)
New Revision: 25617

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=25617

Log:
Make sure system include paths come after samba include paths. Patch from Timur 
Bakeyev.
Modified:
   branches/SAMBA_4_0/
   branches/SAMBA_4_0/source/build/smb_build/cflags.pm


Changeset:

Property changes on: branches/SAMBA_4_0
___________________________________________________________________
Name: bzr:revision-info
...skipped...
Name: bzr:revision-id:v3-trunk0
...skipped...

Modified: branches/SAMBA_4_0/source/build/smb_build/cflags.pm
===================================================================
--- branches/SAMBA_4_0/source/build/smb_build/cflags.pm 2007-10-10 23:25:22 UTC 
(rev 25616)
+++ branches/SAMBA_4_0/source/build/smb_build/cflags.pm 2007-10-10 23:58:29 UTC 
(rev 25617)
@@ -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 @@
 
        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 = $_;

Reply via email to