diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2004-11-14 13:52:16 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:05:47 -0500 |
commit | 7367d23713a34a6c29a492adb365292399adffe8 (patch) | |
tree | 200c3610aef4c495210599861220dd2d72546805 /source4/build/smb_build/input.pm | |
parent | f0b954968c19722b7f42a4bcd367d5f815efdc47 (diff) | |
download | samba-7367d23713a34a6c29a492adb365292399adffe8.tar.gz samba-7367d23713a34a6c29a492adb365292399adffe8.tar.bz2 samba-7367d23713a34a6c29a492adb365292399adffe8.zip |
r3730: More build system fixes and simplifications
the hierarchy in the init functions is correct now
will also make it easier to implement some other features
(This used to be commit cbe819a75568403ac8850ea4d344c607a46d61c2)
Diffstat (limited to 'source4/build/smb_build/input.pm')
-rw-r--r-- | source4/build/smb_build/input.pm | 151 |
1 files changed, 95 insertions, 56 deletions
diff --git a/source4/build/smb_build/input.pm b/source4/build/smb_build/input.pm index a6d5b25f41..c4a4052d8f 100644 --- a/source4/build/smb_build/input.pm +++ b/source4/build/smb_build/input.pm @@ -3,12 +3,15 @@ ### - the input checking functions ### ### ### ### Copyright (C) Stefan (metze) Metzmacher 2004 ### +### Copyright (C) Jelmer Vernooij 2004 ### ### Released under the GNU GPL ### ########################################################### use strict; package input; +our $srcdir = "."; + sub strtrim($) { my $str = shift; @@ -41,85 +44,95 @@ sub str2array($) return @ar; } -sub _check_subsystems($) +sub check_subsystem($$) { my $CTX = shift; - - foreach my $subsys (sort keys %{$CTX->{INPUT}{SUBSYSTEMS}}) { - if ($CTX->{INPUT}{SUBSYSTEMS}{$subsys}{ENABLE} ne "YES") { - printf("Subsystem: %s disabled!\n",$CTX->{INPUT}{SUBSYSTEMS}{$subsys}{NAME}); - next; - } + my $subsys = shift; + if ($subsys->{ENABLE} ne "YES") { + printf("Subsystem: %s disabled!\n",$subsys->{NAME}); } - - return; + + # FIXME: Make this configurable (so it can be STATIC_LIBRARY, for example) + $subsys->{OUTPUT_TYPE} = "OBJLIST"; } -sub _check_modules($) +sub check_module($$) { my $CTX = shift; + my $mod = shift; - foreach my $mod (sort keys %{$CTX->{INPUT}{MODULES}}) { - my $subsys = $CTX->{INPUT}{MODULES}{$mod}{SUBSYSTEM}; - my $default_build = $CTX->{INPUT}{MODULES}{$mod}{DEFAULT_BUILD}; - my $build = $CTX->{INPUT}{MODULES}{$mod}{CHOSEN_BUILD}; - my $use_default = 0; - - if (!(defined($CTX->{INPUT}{SUBSYSTEMS}{$subsys}))) { - $CTX->{INPUT}{MODULES}{$mod}{BUILD} = "NOT"; - printf("Module: %s...PARENT SUBSYSTEM DISABLED\n",$mod); - next; - } + my $use_default = 0; - if ($build eq "DEFAULT") { - $build = $default_build; - $use_default = 1; - } + if (!(defined($CTX->{INPUT}{$mod->{SUBSYSTEM}}))) { + $mod->{BUILD} = "NOT"; + $mod->{ENABLE} = "NO"; + printf("Module: %s...PARENT SUBSYSTEM DISABLED\n",$mod->{NAME}); + return; + } - if ($build eq "SHARED") { - $CTX->{INPUT}{MODULES}{$mod}{BUILD} = "SHARED"; - printf("Module: %s...shared\n",$mod); - } elsif ($build eq "STATIC") { - $CTX->{INPUT}{MODULES}{$mod}{BUILD} = "STATIC"; - printf("Module: %s...static\n",$mod); - } else { - $CTX->{INPUT}{MODULES}{$mod}{BUILD} = "NOT"; - printf("Module: %s...not\n",$mod); - next; - } + if ($mod->{CHOSEN_BUILD} eq "DEFAULT") { + $mod->{CHOSEN_BUILD} = $mod->{DEFAULT_BUILD}; } - return; + if ($mod->{CHOSEN_BUILD} eq "SHARED") { + $mod->{ENABLE} = "YES"; + $mod->{OUTPUT_TYPE} = "SHARED_LIBRARY"; + push (@{$mod->{REQUIRED_SUBSYSTEMS}}, $mod->{SUBSYSTEM}); + printf("Module: %s...shared\n",$mod->{NAME}); + } elsif ($mod->{CHOSEN_BUILD} eq "STATIC") { + $mod->{ENABLE} = "YES"; + push (@{$CTX->{INPUT}{$mod->{SUBSYSTEM}}{REQUIRED_SUBSYSTEMS}}, $mod->{NAME}); + printf("Module: %s...static\n",$mod->{NAME}); + $mod->{OUTPUT_TYPE} = "OBJLIST"; + } else { + $mod->{ENABLE} = "NO"; + printf("Module: %s...not\n",$mod->{NAME}); + return; + } } -sub _check_libraries($) +sub check_library($$) { my $CTX = shift; + my $lib = shift; - foreach my $lib (sort keys %{$CTX->{INPUT}{LIBRARIES}}) { - if ($CTX->{INPUT}{LIBRARIES}{$lib}{ENABLE} ne "YES") { - printf("Library: %s...disabled\n",$CTX->{INPUT}{LIBRARIES}{$lib}{NAME}); - next; - } + if ($lib->{ENABLE} ne "YES") { + printf("Library: %s...disabled\n",$lib->{NAME}); + return; } - return; + $lib->{OUTPUT_TYPE} = "SHARED_LIBRARY"; } -sub _check_binaries($) +sub check_binary($$) { my $CTX = shift; + my $bin = shift; - foreach my $bin (sort keys %{$CTX->{INPUT}{BINARIES}}) { - if ($CTX->{INPUT}{BINARIES}{$bin}{ENABLE} ne "YES") { - printf("Binary: %s...disabled\n",$CTX->{INPUT}{BINARIES}{$bin}{NAME}); - next; - } + if ($bin->{ENABLE} ne "YES") { + printf("Binary: %s...disabled\n",$bin->{NAME}); + return; } - return; + $bin->{OUTPUT_TYPE} = "BINARY"; +} + +sub calc_unique_deps +{ + my $deps = shift; + my $udeps = shift; + + foreach my $dep (@{$deps}) { + if (not defined($udeps->{$$dep->{NAME}})) { + $udeps->{$$dep->{NAME}} = "BUSY"; + calc_unique_deps($$dep->{DEPENDENCIES}, $udeps); + $udeps->{$$dep->{NAME}} = $$dep; + } + } } + + ########################################################### # This function checks the input from the configure script # @@ -130,14 +143,40 @@ sub check($) { my $CTX = shift; - _check_subsystems($CTX); + foreach my $part (values %{$CTX->{INPUT}}) { + check_subsystem($CTX, $part) if ($part->{TYPE} eq "SUBSYSTEM"); + check_module($CTX, $part) if ($part->{TYPE} eq "MODULE"); + check_library($CTX, $part) if ($part->{TYPE} eq "LIBRARY"); + check_binary($CTX, $part) if ($part->{TYPE} eq "BINARY"); + + #FIXME: REQUIRED_LIBRARIES needs to go + if (defined($part->{REQUIRED_LIBRARIES})) { + push(@{$part->{REQUIRED_SUBSYSTEMS}}, @{$part->{REQUIRED_LIBRARIES}}); + delete ($part->{REQUIRED_LIBRARIES}); + } + } + + my %depend = %{$CTX->{INPUT}}; - _check_modules($CTX); + foreach my $part (values %depend) { + + # Generate list of dependencies + $part->{DEPENDENCIES} = []; - _check_libraries($CTX); + foreach my $key (@{$part->{REQUIRED_SUBSYSTEMS}}) { + die("$part->{NAME} has undefined dependency $key\n") if not defined($depend{$key}); + push (@{$part->{DEPENDENCIES}}, \$depend{$key}); + } - _check_binaries($CTX); + delete ($part->{REQUIRED_SUBSYSTEMS}); + } - return; + foreach my $part (values %depend) { + $part->{UNIQUE_DEPENDENCIES} = {}; + calc_unique_deps($part->{DEPENDENCIES}, $part->{UNIQUE_DEPENDENCIES}); + } + + return %depend; } + 1; |