Include CFLAGS overrides in make file.
authorJelmer Vernooij <jelmer@samba.org>
Mon, 25 Feb 2008 17:29:04 +0000 (18:29 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Mon, 25 Feb 2008 17:29:04 +0000 (18:29 +0100)
(This used to be commit f05d5f839e18e078a59ccd262fbffaa2eb4e3672)

source4/build/smb_build/cflags.pm [deleted file]
source4/build/smb_build/main.pl
source4/build/smb_build/makefile.pm

diff --git a/source4/build/smb_build/cflags.pm b/source4/build/smb_build/cflags.pm
deleted file mode 100755 (executable)
index ad6cd42..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-# SMB Build System
-#
-#  Copyright (C) Jelmer Vernooij 2006
-#  Released under the GNU GPL
-
-package cflags;
-use strict;
-
-my $sort_available = eval "use sort 'stable'; return 1;";
-$sort_available = 0 unless defined($sort_available);
-
-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;
-       my $file = shift;
-
-       open(CFLAGS_TXT,">$file") || die ("Can't open `$file'\n");
-
-       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);
-
-               my @sorted_cflags = @{$key->{FINAL_CFLAGS}};
-               if ($sort_available) {
-                       @sorted_cflags = sort by_path @{$key->{FINAL_CFLAGS}};
-               }
-
-               # Rewrite CFLAGS so that both the source and the build
-               # directories are in the path.
-               my @cflags = ();
-               foreach my $flag (@sorted_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 = $_;
-                       my $dfile = $_;
-                       $dfile =~ s/\.o$/.d/;
-                       $dfile =~ s/\.ho$/.d/;
-                       print CFLAGS_TXT "$ofile $dfile: CFLAGS+= $cflags\n";
-               }
-       }
-       close(CFLAGS_TXT);
-
-       print __FILE__.": creating $file\n";
-}
-1;
index 924f94762cb163075744299c25d01e078725d628..86bbb44a8b7ffa464af2ee393f5504085be12692 100644 (file)
@@ -10,7 +10,6 @@ use smb_build::input;
 use smb_build::config_mk;
 use smb_build::output;
 use smb_build::env;
-use smb_build::cflags;
 use smb_build::summary;
 use smb_build::config;
 use strict;
@@ -71,7 +70,8 @@ foreach my $key (values %$OUTPUT) {
        $mkenv->Header($key) if defined($key->{PUBLIC_HEADERS});
        if ($key->{TYPE} eq "MODULE" and defined($key->{INIT_FUNCTION})) {
                $mkenv->output("$key->{SUBSYSTEM}_INIT_FUNCTIONS += \"$key->{INIT_FUNCTION},\"\n");
-               }
+       }
+       $mkenv->CFlags($key);
 }
 
 foreach my $key (values %$OUTPUT) {
@@ -97,9 +97,6 @@ foreach my $key (values %$OUTPUT) {
 
 $mkenv->write("data.mk");
 
-cflags::create_cflags($OUTPUT, $config::config{srcdir},
-                   $config::config{builddir}, "extra_cflags.txt");
-
 summary::show($OUTPUT, \%config::config);
 
 if ($shared_libs_used) {
index bed98bb2c6f1ed2e82b607f0b39c6a8d603c3ce5..8b5856648f52d9190f51e1b4dea532c98ef1117c 100644 (file)
@@ -360,4 +360,57 @@ sub write($$)
        print __FILE__.": creating $file\n";
 }
 
+my $sort_available = eval "use sort 'stable'; return 1;";
+$sort_available = 0 unless defined($sort_available);
+
+sub by_path {
+       return  1 if($a =~ m#^\-I/#);
+       return -1 if($b =~ m#^\-I/#);
+       return  0;
+}
+
+sub CFlags($$)
+{
+       my ($self, $key) = @_;
+
+       my $srcdir = $self->{config}->{srcdir};
+       my $builddir = $self->{config}->{builddir};
+
+       my $src_ne_build = ($srcdir ne $builddir) ? 1 : 0;
+
+       return unless defined ($key->{OBJ_LIST});
+       return unless defined ($key->{FINAL_CFLAGS});
+       return unless (@{$key->{FINAL_CFLAGS}} > 0);
+
+       my @sorted_cflags = @{$key->{FINAL_CFLAGS}};
+       if ($sort_available) {
+               @sorted_cflags = sort by_path @{$key->{FINAL_CFLAGS}};
+       }
+
+       # Rewrite CFLAGS so that both the source and the build
+       # directories are in the path.
+       my @cflags = ();
+       foreach my $flag (@sorted_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 = $_;
+               my $dfile = $_;
+               $dfile =~ s/\.o$/.d/;
+               $dfile =~ s/\.ho$/.d/;
+               $self->output("$ofile $dfile: CFLAGS+= $cflags\n");
+       }
+}
+
 1;