From 4924d03e6dbd84e8aec4f1e9f2ccc8619a5f6768 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze@samba.org>
Date: Sun, 22 Apr 2007 11:40:11 +0000
Subject: r22455: split dependecies array for compiling and linking and use
 better names:-)

calculate the CFLAGS only based on the public dependencies when recursing

metze
(This used to be commit 62f9d0ce1cdc5eb84b76004220fc7d1eb4a72f15)
---
 source4/build/smb_build/input.pm  | 30 +++++++++++++++++++-----------
 source4/build/smb_build/output.pm |  4 ++--
 2 files changed, 21 insertions(+), 13 deletions(-)

(limited to 'source4')

diff --git a/source4/build/smb_build/input.pm b/source4/build/smb_build/input.pm
index 3b8da8c964..5bbb69499f 100644
--- a/source4/build/smb_build/input.pm
+++ b/source4/build/smb_build/input.pm
@@ -162,10 +162,10 @@ sub import_integrated($$)
 	}
 }
 
-sub calc_unique_deps($$$$$$)
+sub calc_unique_deps($$$$$$$$)
 {
-	sub calc_unique_deps($$$$$$);
-	my ($name, $INPUT, $deps, $udeps, $withlibs, $busy) = @_;
+	sub calc_unique_deps($$$$$$$$);
+	my ($name, $INPUT, $deps, $udeps, $withlibs, $forward, $pubonly, $busy) = @_;
 
 	foreach my $n (@$deps) {
 		die("Dependency unknown: $n") unless (defined($INPUT->{$n}));
@@ -173,17 +173,19 @@ sub calc_unique_deps($$$$$$)
 		next if (grep /^$n$/, @$udeps);
 		my $dep = $INPUT->{$n};
 
+		push (@{$udeps}, $dep->{NAME}) if $forward;
+
  		if (defined ($dep->{OUTPUT_TYPE}) && 
 			($withlibs or 
 			(@{$dep->{OUTPUT_TYPE}}[0] eq "INTEGRATED") or 
 			(@{$dep->{OUTPUT_TYPE}}[0] eq "STATIC_LIBRARY"))) {
 				push (@$busy, $dep->{NAME});
-			        calc_unique_deps($dep->{NAME}, $INPUT, $dep->{PUBLIC_DEPENDENCIES}, $udeps, $withlibs, $busy);
-			        calc_unique_deps($dep->{NAME}, $INPUT, $dep->{PRIVATE_DEPENDENCIES}, $udeps, $withlibs, $busy);
+			        calc_unique_deps($dep->{NAME}, $INPUT, $dep->{PUBLIC_DEPENDENCIES}, $udeps, $withlibs, $forward, $pubonly, $busy);
+			        calc_unique_deps($dep->{NAME}, $INPUT, $dep->{PRIVATE_DEPENDENCIES}, $udeps, $withlibs, $forward, $pubonly, $busy) unless $pubonly;
 				pop (@$busy);
 	        }
 
-		unshift (@{$udeps}, $dep->{NAME});
+		unshift (@{$udeps}, $dep->{NAME}) unless $forward;
 	}
 }
 
@@ -242,15 +244,21 @@ sub check($$$$$)
 	}
 
 	foreach my $part (values %$INPUT) {
-		$part->{UNIQUE_DEPENDENCIES} = [];
-		calc_unique_deps($part->{NAME}, $INPUT, $part->{PUBLIC_DEPENDENCIES}, $part->{UNIQUE_DEPENDENCIES}, 0, []);
-		calc_unique_deps($part->{NAME}, $INPUT, $part->{PRIVATE_DEPENDENCIES}, $part->{UNIQUE_DEPENDENCIES}, 0, []);
+		$part->{UNIQUE_DEPENDENCIES_LINK} = [];
+		calc_unique_deps($part->{NAME}, $INPUT, $part->{PUBLIC_DEPENDENCIES}, $part->{UNIQUE_DEPENDENCIES_LINK}, 0, 0, 0, []);
+		calc_unique_deps($part->{NAME}, $INPUT, $part->{PRIVATE_DEPENDENCIES}, $part->{UNIQUE_DEPENDENCIES_LINK}, 0, 0, 0, []);
+	}
+
+	foreach my $part (values %$INPUT) {
+		$part->{UNIQUE_DEPENDENCIES_COMPILE} = [];
+		calc_unique_deps($part->{NAME}, $INPUT, $part->{PUBLIC_DEPENDENCIES}, $part->{UNIQUE_DEPENDENCIES_COMPILE}, 1, 1, 1, []);
+		calc_unique_deps($part->{NAME}, $INPUT, $part->{PRIVATE_DEPENDENCIES}, $part->{UNIQUE_DEPENDENCIES_COMPILE}, 1, 1, 1, []);
 	}
 
 	foreach my $part (values %$INPUT) {
 		$part->{UNIQUE_DEPENDENCIES_ALL} = [];
-		calc_unique_deps($part->{NAME}, $INPUT, $part->{PUBLIC_DEPENDENCIES}, $part->{UNIQUE_DEPENDENCIES_ALL}, 1, []);
-		calc_unique_deps($part->{NAME}, $INPUT, $part->{PRIVATE_DEPENDENCIES}, $part->{UNIQUE_DEPENDENCIES_ALL}, 1, []);
+		calc_unique_deps($part->{NAME}, $INPUT, $part->{PUBLIC_DEPENDENCIES}, $part->{UNIQUE_DEPENDENCIES_ALL}, 1, 0, 0, []);
+		calc_unique_deps($part->{NAME}, $INPUT, $part->{PRIVATE_DEPENDENCIES}, $part->{UNIQUE_DEPENDENCIES_ALL}, 1, 0, 0, []);
 	}
 
 	return $INPUT;
diff --git a/source4/build/smb_build/output.pm b/source4/build/smb_build/output.pm
index b7fd53e645..ec273b894a 100644
--- a/source4/build/smb_build/output.pm
+++ b/source4/build/smb_build/output.pm
@@ -148,7 +148,7 @@ sub create_output($$)
 		merge_array(\$part->{FINAL_CFLAGS}, $part->{CPPFLAGS});
 		merge_array(\$part->{FINAL_CFLAGS}, $part->{CFLAGS});
 
-		foreach (reverse @{$part->{UNIQUE_DEPENDENCIES_ALL}}) {
+		foreach (@{$part->{UNIQUE_DEPENDENCIES_COMPILE}}) {
 			my $elem = $depend->{$_};
 			next if $elem == $part;
 
@@ -157,7 +157,7 @@ sub create_output($$)
 		}
 
 		# Always import the link options of the unique dependencies
-		foreach (@{$part->{UNIQUE_DEPENDENCIES}}) {
+		foreach (@{$part->{UNIQUE_DEPENDENCIES_LINK}}) {
 			my $elem = $depend->{$_};
 			next if $elem == $part;
 
-- 
cgit