From ab440ac6f75c12989d5dc15cc75a99e62f35612f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 12 Nov 2004 01:40:02 +0000 Subject: r3690: Use perl's 'use' statement to include the build system parts rather then using "cat" (This used to be commit 4d018b2b701faa56d7e3bb7634729296b53e0acb) --- source4/build/smb_build/config_mk.pl | 434 ---------------- source4/build/smb_build/config_mk.pm | 435 ++++++++++++++++ source4/build/smb_build/core.m4 | 19 +- source4/build/smb_build/depend.pl | 458 ---------------- source4/build/smb_build/depend.pm | 459 +++++++++++++++++ source4/build/smb_build/input.pl | 139 ----- source4/build/smb_build/input.pm | 140 +++++ source4/build/smb_build/main.pl | 22 - source4/build/smb_build/main.pm | 32 ++ source4/build/smb_build/makefile.pl | 915 -------------------------------- source4/build/smb_build/makefile.pm | 917 +++++++++++++++++++++++++++++++++ source4/build/smb_build/output.pl | 262 ---------- source4/build/smb_build/output.pm | 264 ++++++++++ source4/build/smb_build/smb_build_h.pl | 132 ----- source4/build/smb_build/smb_build_h.pm | 133 +++++ 15 files changed, 2383 insertions(+), 2378 deletions(-) delete mode 100644 source4/build/smb_build/config_mk.pl create mode 100644 source4/build/smb_build/config_mk.pm delete mode 100644 source4/build/smb_build/depend.pl create mode 100644 source4/build/smb_build/depend.pm delete mode 100644 source4/build/smb_build/input.pl create mode 100644 source4/build/smb_build/input.pm delete mode 100644 source4/build/smb_build/main.pl create mode 100644 source4/build/smb_build/main.pm delete mode 100644 source4/build/smb_build/makefile.pl create mode 100644 source4/build/smb_build/makefile.pm delete mode 100644 source4/build/smb_build/output.pl create mode 100644 source4/build/smb_build/output.pm delete mode 100644 source4/build/smb_build/smb_build_h.pl create mode 100644 source4/build/smb_build/smb_build_h.pm (limited to 'source4/build') diff --git a/source4/build/smb_build/config_mk.pl b/source4/build/smb_build/config_mk.pl deleted file mode 100644 index 7a85bfa24b..0000000000 --- a/source4/build/smb_build/config_mk.pl +++ /dev/null @@ -1,434 +0,0 @@ -########################################################### -### SMB Build System ### -### - config.mk parsing functions ### -### ### -### Copyright (C) Stefan (metze) Metzmacher 2004 ### -### Released under the GNU GPL ### -########################################################### - -########################################################### -# The parsing function which parses the file -# -# $result = _parse_config_mk($filename) -# -# $filename - the path of the config.mk file -# which should be parsed -# -# $result - the resulting structure -# -# $result->{ERROR_CODE} - the error_code, '0' means success -# $result->{ERROR_STR} - the error string -# -# $result->{$key}{KEY} - the key == the variable which was parsed -# $result->{$key}{VAL} - the value of the variable -sub _parse_config_mk($) -{ - my $filename = shift; - my $result; - my $linenum = -1; - my $waiting = 0; - my $section = "GLOBAL"; - my $key; - - $result->{ERROR_CODE} = -1; - - open(CONFIG_MK, "< $filename") || die ("Can't open $filename\n"); - - while () { - my $line = $_; - my $val; - - $linenum++; - - # - # lines beginnig with '#' are ignored - # - if ($line =~ /^\#.*$/) { - next; - } - - # - # - # - if (($waiting == 0) && ($line =~ /^\[([a-zA-Z0-9_:]+)\][\t ]*$/)) { - $section = $1; - next; - } - - # - # 1.) lines with an aplhanumeric character indicate - # a new variable, - # 2.) followed by zero or more whitespaces or tabs - # 3.) then one '=' character - # 4.) followed by the value of the variable - # 5.) a newline ('\n') can be escaped by a '\' before the newline - # and the next line needs to start with a tab ('\t') - # - if (($waiting == 0) && ($line =~ /^([a-zA-Z0-9_]+)[\t ]*=(.*)$/)) { - $key = $1; - $val = $2; - - # - # when we have a '\' before the newline - # then skip it and wait for the next line. - # - if ($val =~ /(.*)(\\)$/) { - $val = $1; - $waiting = 1; - } else { - $waiting = 0; - } - - $result->{$section}{$key}{KEY} = $key; - $result->{$section}{$key}{VAL} = $val; - next; - } - - # - # when we are waiting for a value to continue then - # check if it has a leading tab. - # - if (($waiting == 1) && ($line =~ /^\t(.*)$/)) { - $val = $1; - - # - # when we have a '\' before the newline - # then skip it and wait for the next line. - # - if ($val =~ /(.*)( \\)$/) { - $val = $1; - $waiting = 1; - } else { - $waiting = 0; - } - - $result->{$section}{$key}{VAL} .= " "; - $result->{$section}{$key}{VAL} .= $val; - next; - } - - # - # catch empty lines they're ignored - # and we're no longer waiting for the value to continue - # - if ($line =~ /^$/) { - $waiting = 0; - next; - } - - close(CONFIG_MK); - - $result->{ERROR_STR} = "Bad line while parsing $filename\n$filename:$linenum: $line"; - - return $result; - } - - close(CONFIG_MK); - - $result->{ERROR_CODE} = 0; - - return $result; -} - -########################################################### -# A caching function to avoid to parse -# a file twice or more -# -# $result = _get_parse_results($filename) -# -# $filename - the path of the config.mk file -# which should be parsed -# -# $result - the resulting structure -# -# $result->{ERROR_CODE} - the error_code, '0' means success -# $result->{ERROR_STR} - the error string -# -# $result->{$key}{KEY} - the key == the variable which was parsed -# $result->{$key}{VAL} - the value of the variable -my $_get_parse_results_cache; -sub _get_parse_results($) -{ - my $filename = shift; - - if ((!defined($_get_parse_results_cache->{$filename}{ERROR_CODE})) - ||($_get_parse_results_cache->{$filename}{ERROR_CODE} != 0)) { - $_get_parse_results_cache->{$filename} = _parse_config_mk($filename); - } - - return $_get_parse_results_cache->{$filename}; -} - -########################################################### -# The fetching function to fetch the value of a variable -# out of the file -# -# $value = _fetch_var_from_config_mk($filename,$section,$variable) -# -# $filename - the path of the config.mk file -# which should be parsed -# -# $section - the section name of the variable -# -# $variable - the variable name of which we want the value -# -# $value - the value of the variable -sub _fetch_var_from_config_mk($$$) -{ - my $filename = shift; - my $section = shift; - my $key = shift; - my $val = ""; - my $result; - - $result = _get_parse_results($filename); - - if ($result->{ERROR_CODE} != 0) { - die ($result->{ERROR_STR}); - } - - if (defined($result->{$section}{$key})) { - $val = strtrim($result->{$section}{$key}{VAL}); - } elsif (defined($result->{DEFAULT}{$key})) { - $val = strtrim($result->{DEFAULT}{$key}{VAL}); - } - - return $val; -} - -########################################################### -# The fetching function to fetch the array of values of a variable -# out of the file -# -# $array = _fetch_array_from_config_mk($filename,$section,$variable) -# -# $filename - the path of the config.mk file -# which should be parsed -# -# $section - the section name of the variable -# -# $variable - the variable name of which we want the value -# -# $array - the array of values of the variable -sub _fetch_array_from_config_mk($$$) -{ - my $filename = shift; - my $section = shift; - my $key = shift; - my @val = (); - my $result; - - $result = _get_parse_results($filename); - - if ($result->{ERROR_CODE} != 0) { - die ($result->{ERROR_STR}); - } - - if (defined($result->{$section}{$key})) { - @val = str2array($result->{$section}{$key}{VAL}); - } elsif (defined($result->{DEFAULT}{$key})) { - @val = str2array($result->{DEFAULT}{$key}{VAL}); - } - - return @val; -} - -########################################################### -# A function for fetching MODULE__ -# variables out of a config.mk file -# -# $value = module_get_var($filename,$module,$parameter) -# -# $filename - the path of the config.mk file -# which should be parsed -# -# $module - the middle part of the variable name of which we want the value -# -# $parameter - the last part of the variable name of which we want the value -# -# $value - the value of the variable -sub module_get_var($$$) -{ - my $filename = shift; - my $module = shift; - my $var = shift; - - my $section = "MODULE::".$module; - - return _fetch_var_from_config_mk($filename,$section,$var); -} - -########################################################### -# A function for fetching MODULE__ -# variables out of a config.mk file -# -# $array = module_get_array($filename,$module,$parameter) -# -# $filename - the path of the config.mk file -# which should be parsed -# -# $module - the middle part of the variable name of which we want the value -# -# $parameter - the last part of the variable name of which we want the value -# -# $array - the array of values of the variable -sub module_get_array($$$) -{ - my $filename = shift; - my $module = shift; - my $var = shift; - - my $section = "MODULE::".$module; - - return _fetch_array_from_config_mk($filename,$section,$var); -} - -########################################################### -# A function for fetching SUBSYSTEM__ -# variables out of a config.mk file -# -# $value = subsystem_get_var($filename,$subsystem,$parameter) -# -# $filename - the path of the config.mk file -# which should be parsed -# -# $subsystem - the middle part of the variable name of which we want the value -# -# $parameter - the last part of the variable name of which we want the value -# -# $value - the value of the variable -sub subsystem_get_var($$$) -{ - my $filename = shift; - my $subsystem = shift; - my $var = shift; - - my $section = "SUBSYSTEM::".$subsystem; - - return _fetch_var_from_config_mk($filename,$section,$var); -} - -########################################################### -# A function for fetching SUBSYSTEM__ -# variables out of a config.mk file -# -# $array = subsystem_get_array($filename,$subsystem,$parameter) -# -# $filename - the path of the config.mk file -# which should be parsed -# -# $subsystem - the middle part of the variable name of which we want the value -# -# $parameter - the last part of the variable name of which we want the value -# -# $array - the array of values of the variable -sub subsystem_get_array($$$) -{ - my $filename = shift; - my $subsystem = shift; - my $var = shift; - - my $section = "SUBSYSTEM::".$subsystem; - - return _fetch_array_from_config_mk($filename,$section,$var); -} - -########################################################### -# A function for fetching LIBRARY__ -# variables out of a config.mk file -# -# $value = library_get_var($filename,$library,$parameter) -# -# $filename - the path of the config.mk file -# which should be parsed -# -# $library - the middle part of the variable name of which we want the value -# -# $parameter - the last part of the variable name of which we want the value -# -# $value - the value of the variable -sub library_get_var($$$) -{ - my $filename = shift; - my $library = shift; - my $var = shift; - - my $section = "LIBRARY::".$library; - - return _fetch_var_from_config_mk($filename,$section,$var); -} - -########################################################### -# A function for fetching LIBRARY__ -# variables out of a config.mk file -# -# $array = library_get_array($filename,$library,$parameter) -# -# $filename - the path of the config.mk file -# which should be parsed -# -# $library - the middle part of the variable name of which we want the value -# -# $parameter - the last part of the variable name of which we want the value -# -# $array - the array of values of the variable -sub library_get_array($$$) -{ - my $filename = shift; - my $library = shift; - my $var = shift; - - my $section = "LIBRARY::".$library; - - return _fetch_array_from_config_mk($filename,$section,$var); -} - -########################################################### -# A function for fetching BINARY__ -# variables out of a config.mk file -# -# $value = binary_get_var($filename,$binary,$parameter) -# -# $filename - the path of the config.mk file -# which should be parsed -# -# $binary - the middle part of the variable name of which we want the value -# -# $parameter - the last part of the variable name of which we want the value -# -# $value - the value of the variable -sub binary_get_var($$$) -{ - my $filename = shift; - my $binary = shift; - my $var = shift; - - my $section = "BINARY::".$binary; - - return _fetch_var_from_config_mk($filename,$section,$var); -} - -########################################################### -# A function for fetching BINARY__ -# variables out of a config.mk file -# -# $array = binary_get_array($filename,$binary,$parameter) -# -# $filename - the path of the config.mk file -# which should be parsed -# -# $binary - the middle part of the variable name of which we want the value -# -# $parameter - the last part of the variable name of which we want the value -# -# $array - the array of values of the variable -sub binary_get_array($$$) -{ - my $filename = shift; - my $binary = shift; - my $var = shift; - - my $section = "BINARY::".$binary; - - return _fetch_array_from_config_mk($filename,$section,$var); -} diff --git a/source4/build/smb_build/config_mk.pm b/source4/build/smb_build/config_mk.pm new file mode 100644 index 0000000000..eaf7079352 --- /dev/null +++ b/source4/build/smb_build/config_mk.pm @@ -0,0 +1,435 @@ +########################################################### +### SMB Build System ### +### - config.mk parsing functions ### +### ### +### Copyright (C) Stefan (metze) Metzmacher 2004 ### +### Released under the GNU GPL ### +########################################################### + +########################################################### +# The parsing function which parses the file +# +# $result = _parse_config_mk($filename) +# +# $filename - the path of the config.mk file +# which should be parsed +# +# $result - the resulting structure +# +# $result->{ERROR_CODE} - the error_code, '0' means success +# $result->{ERROR_STR} - the error string +# +# $result->{$key}{KEY} - the key == the variable which was parsed +# $result->{$key}{VAL} - the value of the variable +sub _parse_config_mk($) +{ + my $filename = shift; + my $result; + my $linenum = -1; + my $waiting = 0; + my $section = "GLOBAL"; + my $key; + + $result->{ERROR_CODE} = -1; + + open(CONFIG_MK, "< $filename") || die ("Can't open $filename\n"); + + while () { + my $line = $_; + my $val; + + $linenum++; + + # + # lines beginnig with '#' are ignored + # + if ($line =~ /^\#.*$/) { + next; + } + + # + # + # + if (($waiting == 0) && ($line =~ /^\[([a-zA-Z0-9_:]+)\][\t ]*$/)) { + $section = $1; + next; + } + + # + # 1.) lines with an aplhanumeric character indicate + # a new variable, + # 2.) followed by zero or more whitespaces or tabs + # 3.) then one '=' character + # 4.) followed by the value of the variable + # 5.) a newline ('\n') can be escaped by a '\' before the newline + # and the next line needs to start with a tab ('\t') + # + if (($waiting == 0) && ($line =~ /^([a-zA-Z0-9_]+)[\t ]*=(.*)$/)) { + $key = $1; + $val = $2; + + # + # when we have a '\' before the newline + # then skip it and wait for the next line. + # + if ($val =~ /(.*)(\\)$/) { + $val = $1; + $waiting = 1; + } else { + $waiting = 0; + } + + $result->{$section}{$key}{KEY} = $key; + $result->{$section}{$key}{VAL} = $val; + next; + } + + # + # when we are waiting for a value to continue then + # check if it has a leading tab. + # + if (($waiting == 1) && ($line =~ /^\t(.*)$/)) { + $val = $1; + + # + # when we have a '\' before the newline + # then skip it and wait for the next line. + # + if ($val =~ /(.*)( \\)$/) { + $val = $1; + $waiting = 1; + } else { + $waiting = 0; + } + + $result->{$section}{$key}{VAL} .= " "; + $result->{$section}{$key}{VAL} .= $val; + next; + } + + # + # catch empty lines they're ignored + # and we're no longer waiting for the value to continue + # + if ($line =~ /^$/) { + $waiting = 0; + next; + } + + close(CONFIG_MK); + + $result->{ERROR_STR} = "Bad line while parsing $filename\n$filename:$linenum: $line"; + + return $result; + } + + close(CONFIG_MK); + + $result->{ERROR_CODE} = 0; + + return $result; +} + +########################################################### +# A caching function to avoid to parse +# a file twice or more +# +# $result = _get_parse_results($filename) +# +# $filename - the path of the config.mk file +# which should be parsed +# +# $result - the resulting structure +# +# $result->{ERROR_CODE} - the error_code, '0' means success +# $result->{ERROR_STR} - the error string +# +# $result->{$key}{KEY} - the key == the variable which was parsed +# $result->{$key}{VAL} - the value of the variable +my $_get_parse_results_cache; +sub _get_parse_results($) +{ + my $filename = shift; + + if ((!defined($_get_parse_results_cache->{$filename}{ERROR_CODE})) + ||($_get_parse_results_cache->{$filename}{ERROR_CODE} != 0)) { + $_get_parse_results_cache->{$filename} = _parse_config_mk($filename); + } + + return $_get_parse_results_cache->{$filename}; +} + +########################################################### +# The fetching function to fetch the value of a variable +# out of the file +# +# $value = _fetch_var_from_config_mk($filename,$section,$variable) +# +# $filename - the path of the config.mk file +# which should be parsed +# +# $section - the section name of the variable +# +# $variable - the variable name of which we want the value +# +# $value - the value of the variable +sub _fetch_var_from_config_mk($$$) +{ + my $filename = shift; + my $section = shift; + my $key = shift; + my $val = ""; + my $result; + + $result = _get_parse_results($filename); + + if ($result->{ERROR_CODE} != 0) { + die ($result->{ERROR_STR}); + } + + if (defined($result->{$section}{$key})) { + $val = strtrim($result->{$section}{$key}{VAL}); + } elsif (defined($result->{DEFAULT}{$key})) { + $val = strtrim($result->{DEFAULT}{$key}{VAL}); + } + + return $val; +} + +########################################################### +# The fetching function to fetch the array of values of a variable +# out of the file +# +# $array = _fetch_array_from_config_mk($filename,$section,$variable) +# +# $filename - the path of the config.mk file +# which should be parsed +# +# $section - the section name of the variable +# +# $variable - the variable name of which we want the value +# +# $array - the array of values of the variable +sub _fetch_array_from_config_mk($$$) +{ + my $filename = shift; + my $section = shift; + my $key = shift; + my @val = (); + my $result; + + $result = _get_parse_results($filename); + + if ($result->{ERROR_CODE} != 0) { + die ($result->{ERROR_STR}); + } + + if (defined($result->{$section}{$key})) { + @val = str2array($result->{$section}{$key}{VAL}); + } elsif (defined($result->{DEFAULT}{$key})) { + @val = str2array($result->{DEFAULT}{$key}{VAL}); + } + + return @val; +} + +########################################################### +# A function for fetching MODULE__ +# variables out of a config.mk file +# +# $value = module_get_var($filename,$module,$parameter) +# +# $filename - the path of the config.mk file +# which should be parsed +# +# $module - the middle part of the variable name of which we want the value +# +# $parameter - the last part of the variable name of which we want the value +# +# $value - the value of the variable +sub module_get_var($$$) +{ + my $filename = shift; + my $module = shift; + my $var = shift; + + my $section = "MODULE::".$module; + + return _fetch_var_from_config_mk($filename,$section,$var); +} + +########################################################### +# A function for fetching MODULE__ +# variables out of a config.mk file +# +# $array = module_get_array($filename,$module,$parameter) +# +# $filename - the path of the config.mk file +# which should be parsed +# +# $module - the middle part of the variable name of which we want the value +# +# $parameter - the last part of the variable name of which we want the value +# +# $array - the array of values of the variable +sub module_get_array($$$) +{ + my $filename = shift; + my $module = shift; + my $var = shift; + + my $section = "MODULE::".$module; + + return _fetch_array_from_config_mk($filename,$section,$var); +} + +########################################################### +# A function for fetching SUBSYSTEM__ +# variables out of a config.mk file +# +# $value = subsystem_get_var($filename,$subsystem,$parameter) +# +# $filename - the path of the config.mk file +# which should be parsed +# +# $subsystem - the middle part of the variable name of which we want the value +# +# $parameter - the last part of the variable name of which we want the value +# +# $value - the value of the variable +sub subsystem_get_var($$$) +{ + my $filename = shift; + my $subsystem = shift; + my $var = shift; + + my $section = "SUBSYSTEM::".$subsystem; + + return _fetch_var_from_config_mk($filename,$section,$var); +} + +########################################################### +# A function for fetching SUBSYSTEM__ +# variables out of a config.mk file +# +# $array = subsystem_get_array($filename,$subsystem,$parameter) +# +# $filename - the path of the config.mk file +# which should be parsed +# +# $subsystem - the middle part of the variable name of which we want the value +# +# $parameter - the last part of the variable name of which we want the value +# +# $array - the array of values of the variable +sub subsystem_get_array($$$) +{ + my $filename = shift; + my $subsystem = shift; + my $var = shift; + + my $section = "SUBSYSTEM::".$subsystem; + + return _fetch_array_from_config_mk($filename,$section,$var); +} + +########################################################### +# A function for fetching LIBRARY__ +# variables out of a config.mk file +# +# $value = library_get_var($filename,$library,$parameter) +# +# $filename - the path of the config.mk file +# which should be parsed +# +# $library - the middle part of the variable name of which we want the value +# +# $parameter - the last part of the variable name of which we want the value +# +# $value - the value of the variable +sub library_get_var($$$) +{ + my $filename = shift; + my $library = shift; + my $var = shift; + + my $section = "LIBRARY::".$library; + + return _fetch_var_from_config_mk($filename,$section,$var); +} + +########################################################### +# A function for fetching LIBRARY__ +# variables out of a config.mk file +# +# $array = library_get_array($filename,$library,$parameter) +# +# $filename - the path of the config.mk file +# which should be parsed +# +# $library - the middle part of the variable name of which we want the value +# +# $parameter - the last part of the variable name of which we want the value +# +# $array - the array of values of the variable +sub library_get_array($$$) +{ + my $filename = shift; + my $library = shift; + my $var = shift; + + my $section = "LIBRARY::".$library; + + return _fetch_array_from_config_mk($filename,$section,$var); +} + +########################################################### +# A function for fetching BINARY__ +# variables out of a config.mk file +# +# $value = binary_get_var($filename,$binary,$parameter) +# +# $filename - the path of the config.mk file +# which should be parsed +# +# $binary - the middle part of the variable name of which we want the value +# +# $parameter - the last part of the variable name of which we want the value +# +# $value - the value of the variable +sub binary_get_var($$$) +{ + my $filename = shift; + my $binary = shift; + my $var = shift; + + my $section = "BINARY::".$binary; + + return _fetch_var_from_config_mk($filename,$section,$var); +} + +########################################################### +# A function for fetching BINARY__ +# variables out of a config.mk file +# +# $array = binary_get_array($filename,$binary,$parameter) +# +# $filename - the path of the config.mk file +# which should be parsed +# +# $binary - the middle part of the variable name of which we want the value +# +# $parameter - the last part of the variable name of which we want the value +# +# $array - the array of values of the variable +sub binary_get_array($$$) +{ + my $filename = shift; + my $binary = shift; + my $var = shift; + + my $section = "BINARY::".$binary; + + return _fetch_array_from_config_mk($filename,$section,$var); +} +1; diff --git a/source4/build/smb_build/core.m4 b/source4/build/smb_build/core.m4 index 0249c7e2d9..8f0959208c 100644 --- a/source4/build/smb_build/core.m4 +++ b/source4/build/smb_build/core.m4 @@ -21,29 +21,16 @@ AC_DEFUN([_SMB_BUILD_CORE], echo "config.status: creating ./config.smb_build.pl" cat > config.smb_build.pl <<\_SMB_ACEOF -#!$PERL +#!$PERL -I$srcdir/build/smb_build # use strict; my \$SMB_BUILD_CTX; -_SMB_ACEOF +use main; -echo "#line 1 \"build/smb_build/config_mk.pl\"" >> config.smb_build.pl -cat >> config.smb_build.pl < build/smb_build/config_mk.pl -echo "#line 1 \"build/smb_build/input.pl\"" >> config.smb_build.pl -cat >> config.smb_build.pl < build/smb_build/input.pl -echo "#line 1 \"build/smb_build/depend.pl\"" >> config.smb_build.pl -cat >> config.smb_build.pl < build/smb_build/depend.pl -echo "#line 1 \"build/smb_build/output.pl\"" >> config.smb_build.pl -cat >> config.smb_build.pl < build/smb_build/output.pl -echo "#line 1 \"build/smb_build/makefile.pl\"" >> config.smb_build.pl -cat >> config.smb_build.pl < build/smb_build/makefile.pl -echo "#line 1 \"build/smb_build/smb_build_h.pl\"" >> config.smb_build.pl -cat >> config.smb_build.pl < build/smb_build/smb_build_h.pl -echo "#line 1 \"build/smb_build/main.pl\"" >> config.smb_build.pl -cat >> config.smb_build.pl < build/smb_build/main.pl +_SMB_ACEOF echo "#line 8 \"build/smb_build/core.m4\"" >> config.smb_build.pl cat >> config.smb_build.pl <<\_SMB_ACEOF diff --git a/source4/build/smb_build/depend.pl b/source4/build/smb_build/depend.pl deleted file mode 100644 index a45fb725e1..0000000000 --- a/source4/build/smb_build/depend.pl +++ /dev/null @@ -1,458 +0,0 @@ -########################################################### -### SMB Build System ### -### - the dependency calculation functions ### -### ### -### Copyright (C) Stefan (metze) Metzmacher 2004 ### -### Released under the GNU GPL ### -########################################################### - -########################################################### -# This function resolves the dependencies -# for the SUBSYSTEMS_LIST -# @SUBSYSTEMS_LIST = _do_calc_subsystem_list($SMB_BUILD_CTX, \@SUBSYSTEMS_LIST); -# -# $SMB_BUILD_CTX - the global SMB_BUILD context -# -# \@SUBSYSTEMS_LIST - the reference to the SUBSYSTEMS_LIST -# -# @SUBSYSTEMS_LIST - the expanded resulting SUBSYSTEMS_LIST -# -sub _do_calc_subsystem_list($$) -{ - my $CTX = shift; - my $subsys_list = shift; - my @SUBSYSTEMS_LIST = @$subsys_list; - - # - # now try to resolve the dependencies for the library - # - my $i = 0; - my $count = $#SUBSYSTEMS_LIST; - for (;$i<=$count;$i++) { - # - # see if the current subsystem depends on other not listed subsystems - # - foreach my $elem (@{$CTX->{DEPEND}{SUBSYSTEMS}{$SUBSYSTEMS_LIST[$i]}{SUBSYSTEMS_LIST}}) { - my $seen = 0; - # - # check if it's already in the list - # - foreach my $elem2 (@SUBSYSTEMS_LIST) { - # - # check of the names matche - # - if ($elem eq $elem2) { - # - # mark it as already in the list - # - $seen = 1; - last; - } - } - - # - # if it's already there skip it - # - if ($seen == 1) { - next; - } - - # - # if it's not there add it - # and $count++ - # - push(@SUBSYSTEMS_LIST,$elem); - $count++; - } - } - - return @SUBSYSTEMS_LIST; -} - -########################################################### -# This function resolves the dependencies -# for the LIBRARIES_LIST based on the SUBSYSTEMS_LIST -# @LIBRARIES_LIST = _do_calc_libraries_list($SMB_BUILD_CTX, \@SUBSYSTEMS_LIST, \@LIBRARIES_LIST); -# -# $SMB_BUILD_CTX - the global SMB_BUILD context -# -# \@SUBSYSTEMS_LIST - the reference to the SUBSYSTEMS_LIST -# -# \@LIBRARIES_LIST - the reference to the LIBRARIES_LIST -# -# @LIBRARIES_LIST - the expanded resulting LIBRARIES_LIST -# -sub _do_calc_libraries_list($$$) -{ - my $CTX = shift; - my $subsys_list = shift; - my @SUBSYSTEMS_LIST = @$subsys_list; - my $libs_list = shift; - my @LIBRARIES_LIST = @$libs_list; - - # - # add the LIBARARIES of each subsysetm in the @SUBSYSTEMS_LIST - # - foreach my $elem (@SUBSYSTEMS_LIST) { - # - # see if the subsystem depends on a not listed LIBRARY - # - foreach my $elem1 (@{$CTX->{DEPEND}{SUBSYSTEMS}{$elem}{LIBRARIES_LIST}}) { - my $seen = 0; - # - # check if it's already in the list - # - foreach my $elem2 (@LIBRARIES_LIST) { - # - # check of the names matche - # - if ($elem1 eq $elem2) { - # - # mark it as already in the list - # - $seen = 1; - last; - } - } - - # - # if it's already there skip it - # - if ($seen == 1) { - next; - } - - # - # if it's not there add it - # - push(@LIBRARIES_LIST,$elem1); - } - } - - return @LIBRARIES_LIST; -} - -########################################################### -# This function creates the dependencies for subsystems -# _do_depend_subsystems($SMB_BUILD_CTX) -# -# $SMB_BUILD_CTX - the global SMB_BUILD context -sub _do_depend_subsystems($) -{ - my $CTX = shift; - - # - # loop on all subsystems - # - foreach my $key (sort keys %{$CTX->{INPUT}{SUBSYSTEMS}}) { - my $name = $CTX->{INPUT}{SUBSYSTEMS}{$key}{NAME}; - my @STATIC_MODULES_LIST = (); - my @INIT_FUNCTIONS = (); - - # - # skip when the subsystem was disabled - # - if ($CTX->{INPUT}{SUBSYSTEMS}{$key}{ENABLE} ne "YES" ) { - next; - } - - # - # create the subsystems used OBJ_LIST - # - my @OBJ_LIST = (); - push (@OBJ_LIST, @{$CTX->{INPUT}{SUBSYSTEMS}{$key}{INIT_OBJ_FILES}}); - push (@OBJ_LIST, @{$CTX->{INPUT}{SUBSYSTEMS}{$key}{ADD_OBJ_FILES}}); - - # - # create the subsystems used SUBSYSTEMS_LIST - # - my @SUBSYSTEMS_LIST = (); - push (@SUBSYSTEMS_LIST, (@{$CTX->{INPUT}{SUBSYSTEMS}{$key}{REQUIRED_SUBSYSTEMS}})); - # - # create the subsystems used LIBRARIES_LIST - # - my @LIBRARIES_LIST = (); - push (@LIBRARIES_LIST, @{$CTX->{INPUT}{SUBSYSTEMS}{$key}{REQUIRED_LIBRARIES}}); - - # - # now collect the info from the subsystems static modules - # - foreach my $subkey (sort keys %{$CTX->{INPUT}{MODULES}}) { - # - # we only want STATIC modules - # - if ($CTX->{INPUT}{MODULES}{$subkey}{BUILD} ne "STATIC") { - next; - } - - # - # we only want modules which belong to the current subsystem - # - if ($CTX->{INPUT}{MODULES}{$subkey}{SUBSYSTEM} ne $name) { - next; - } - - # - # add it to the STATIC_MODULES_LIST - # - push(@STATIC_MODULES_LIST,$subkey); - push (@INIT_FUNCTIONS, $CTX->{INPUT}{MODULES}{$subkey}{INIT_FUNCTION}) if $CTX->{INPUT}{MODULES}{$subkey}{INIT_FUNCTION} ne ""; - - # - # add OBJS of static modules to the subsystems used OBJ_LIST - # - push (@OBJ_LIST, (@{$CTX->{INPUT}{MODULES}{$subkey}{INIT_OBJ_FILES}})); - push (@OBJ_LIST, (@{$CTX->{INPUT}{MODULES}{$subkey}{ADD_OBJ_FILES}})); - - # - # add SUBSYSTEMS of static modules to the subsystems used SUBSYSTEMS_LIST - # - push (@SUBSYSTEMS_LIST, (@{$CTX->{INPUT}{MODULES}{$subkey}{REQUIRED_SUBSYSTEMS}})); - - # - # add LIBRARIES of static modules to the subsystems used LIBRARIES_LIST - # - push (@LIBRARIES_LIST, (@{$CTX->{INPUT}{MODULES}{$subkey}{REQUIRED_LIBRARIES}})); - } - - # - # set the lists - # - @{$CTX->{DEPEND}{SUBSYSTEMS}{$key}{INIT_FUNCTIONS}} = @INIT_FUNCTIONS; - @{$CTX->{DEPEND}{SUBSYSTEMS}{$key}{OBJ_LIST}} = @OBJ_LIST; - @{$CTX->{DEPEND}{SUBSYSTEMS}{$key}{STATIC_MODULES_LIST}} = @STATIC_MODULES_LIST; - @{$CTX->{DEPEND}{SUBSYSTEMS}{$key}{SUBSYSTEMS_LIST}} = @SUBSYSTEMS_LIST; - @{$CTX->{DEPEND}{SUBSYSTEMS}{$key}{LIBRARIES_LIST}} = @LIBRARIES_LIST; - } - - return; -} - -########################################################### -# This function creates the dependencies for ext libs -# _do_depend_ext_libs($SMB_BUILD_CTX) -# -# $SMB_BUILD_CTX - the global SMB_BUILD context -sub _do_depend_ext_libs($) -{ - my $CTX = shift; - - # - # loop over all ext libs - # - foreach my $key (sort keys %{$CTX->{INPUT}{EXT_LIBS}}) { - my $name = $CTX->{INPUT}{EXT_LIBS}{$key}{NAME}; - - # - # if it's not a shared module skip it - # - if ($CTX->{INPUT}{EXT_LIBS}{$key}{ENABLE} ne "YES") { - next; - } - - # - # set the lists - # - $CTX->{DEPEND}{EXT_LIBS}{$key}{NAME} = $name; - @{$CTX->{DEPEND}{EXT_LIBS}{$key}{LIBS}} = @{$CTX->{INPUT}{EXT_LIBS}{$key}{LIBS}}; - @{$CTX->{DEPEND}{EXT_LIBS}{$key}{CFLAGS}} = @{$CTX->{INPUT}{EXT_LIBS}{$key}{CFLAGS}}; - @{$CTX->{DEPEND}{EXT_LIBS}{$key}{CPPFLAGS}} = @{$CTX->{INPUT}{EXT_LIBS}{$key}{CPPFLAGS}}; - @{$CTX->{DEPEND}{EXT_LIBS}{$key}{LDFLAGS}} = @{$CTX->{INPUT}{EXT_LIBS}{$key}{LDFLAGS}}; - } - - return; -} - -########################################################### -# This function creates the dependencies for shared modules -# _do_depend_shared_modules($SMB_BUILD_CTX) -# -# $SMB_BUILD_CTX - the global SMB_BUILD context -sub _do_depend_shared_modules($) -{ - my $CTX = shift; - - # - # loop over all shared modules - # - foreach my $key (sort keys %{$CTX->{INPUT}{MODULES}}) { - my $name = $CTX->{INPUT}{MODULES}{$key}{NAME}; - - # - # if it's not a shared module skip it - # - if ($CTX->{INPUT}{MODULES}{$key}{BUILD} ne "SHARED" ) { - next; - } - - # - # create the shared modules used SUBSYSTEMS_LIST - # - my @SUBSYSTEMS_LIST = (); - push (@SUBSYSTEMS_LIST, (@{$CTX->{INPUT}{MODULES}{$key}{REQUIRED_SUBSYSTEMS}})); - - # - # now try to resolve the dependencies for the shared module - # - @SUBSYSTEMS_LIST = _do_calc_subsystem_list($CTX, \@SUBSYSTEMS_LIST); - - # - # create the shared modules used LIBRARIES_LIST - # - my @LIBRARIES_LIST = (); - push (@LIBRARIES_LIST, @{$CTX->{INPUT}{MODULES}{$key}{REQUIRED_LIBRARIES}}); - - # - # add the LIBARARIES of each subsysetm in the @SUBSYSTEMS_LIST - # - @LIBRARIES_LIST = _do_calc_libraries_list($CTX, \@SUBSYSTEMS_LIST, \@LIBRARIES_LIST); - - # - # set the lists - # - @{$CTX->{DEPEND}{SHARED_MODULES}{$key}{SUBSYSTEMS_LIST}} = @SUBSYSTEMS_LIST; - @{$CTX->{DEPEND}{SHARED_MODULES}{$key}{LIBRARIES_LIST}} = @LIBRARIES_LIST; - } - - return; -} - -########################################################### -# This function creates the dependencies for libraries -# _do_depend_libraries($SMB_BUILD_CTX) -# -# $SMB_BUILD_CTX - the global SMB_BUILD context -sub _do_depend_libraries($) -{ - my $CTX = shift; - - # - # loop over all libraries - # - foreach my $key (sort keys %{$CTX->{INPUT}{LIBRARIES}}) { - my $name = $CTX->{INPUT}{LIBRARIES}{$key}{NAME}; - - # - # if it's not a library skip it - # - if ($CTX->{INPUT}{LIBRARIES}{$key}{ENABLE} ne "YES" ) { - next; - } - - # - # create the libraries used SUBSYSTEMS_LIST - # - my @SUBSYSTEMS_LIST = (); - push (@SUBSYSTEMS_LIST, @{$CTX->{INPUT}{LIBRARIES}{$key}{REQUIRED_SUBSYSTEMS}}); - - # - # now try to resolve the dependencies for the library - # - @SUBSYSTEMS_LIST = _do_calc_subsystem_list($CTX, \@SUBSYSTEMS_LIST); - - # - # create the libraries used LIBRARIES_LIST - # - my @LIBRARIES_LIST = (); - push (@LIBRARIES_LIST, @{$CTX->{INPUT}{LIBRARIES}{$key}{REQUIRED_LIBRARIES}}); - - # - # add the LIBARARIES of each subsysetm in the @SUBSYSTEMS_LIST - # - @LIBRARIES_LIST = _do_calc_libraries_list($CTX, \@SUBSYSTEMS_LIST, \@LIBRARIES_LIST); - - # - # set the lists - # - @{$CTX->{DEPEND}{LIBRARIES}{$key}{SUBSYSTEMS_LIST}} = @SUBSYSTEMS_LIST; - @{$CTX->{DEPEND}{LIBRARIES}{$key}{LIBRARIES_LIST}} = @LIBRARIES_LIST; - } - - return; -} - -########################################################### -# This function creates the dependencies for binaries -# _do_depend_binaries($SMB_BUILD_CTX) -# -# $SMB_BUILD_CTX - the global SMB_BUILD context -sub _do_depend_binaries($) -{ - my $CTX = shift; - - # - # loop over all binaries - # - foreach my $key (sort keys %{$CTX->{INPUT}{BINARIES}}) { - my $name = $CTX->{INPUT}{BINARIES}{$key}{NAME}; - - # - # skip when the binary was disabled - # - if ($CTX->{INPUT}{BINARIES}{$key}{ENABLE} ne "YES" ) { - next; - } - - # - # create the binaries used SUBSYSTEMS_LIST - # - my @SUBSYSTEMS_LIST = (); - push (@SUBSYSTEMS_LIST, @{$CTX->{INPUT}{BINARIES}{$key}{REQUIRED_SUBSYSTEMS}}); - - # - # now try to resolve the dependencies for the binary - # - @SUBSYSTEMS_LIST = _do_calc_subsystem_list($CTX, \@SUBSYSTEMS_LIST); - - my @INIT_FUNCTIONS = (); - - foreach my $subkey (@SUBSYSTEMS_LIST) - { - push (@INIT_FUNCTIONS, $CTX->{INPUT}{SUBSYSTEMS}{$subkey}{INIT_FUNCTION}) if $CTX->{INPUT}{SUBSYSTEMS}{$subkey}{INIT_FUNCTION} ne ""; - - } - - # - # create the binaries used LIBRARIES_LIST - # - my @LIBRARIES_LIST = (); - push (@LIBRARIES_LIST, @{$CTX->{INPUT}{BINARIES}{$key}{REQUIRED_LIBRARIES}}); - - # - # add the LIBARARIES of each subsysetm in the @SUBSYSTEMS_LIST - # - @LIBRARIES_LIST = _do_calc_libraries_list($CTX, \@SUBSYSTEMS_LIST, \@LIBRARIES_LIST); - - # - # set the lists - # - @{$CTX->{DEPEND}{BINARIES}{$key}{SUBSYSTEMS_LIST}} = @SUBSYSTEMS_LIST; - @{$CTX->{DEPEND}{BINARIES}{$key}{LIBRARIES_LIST}} = @LIBRARIES_LIST; - @{$CTX->{DEPEND}{BINARIES}{$key}{INIT_FUNCTIONS}} = @INIT_FUNCTIONS; - } - - return; -} - -########################################################### -# This function creates the dependency tree from the SMB_BUILD -# context -# create_depend($SMB_BUILD_CTX) -# -# $SMB_BUILD_CTX - the global SMB_BUILD context -sub create_depend($) -{ - my $CTX = shift; - - _do_depend_ext_libs($CTX); - - _do_depend_subsystems($CTX); - - _do_depend_shared_modules($CTX); - - _do_depend_libraries($CTX); - - _do_depend_binaries($CTX); - - return; -} diff --git a/source4/build/smb_build/depend.pm b/source4/build/smb_build/depend.pm new file mode 100644 index 0000000000..771a83ca2c --- /dev/null +++ b/source4/build/smb_build/depend.pm @@ -0,0 +1,459 @@ +########################################################### +### SMB Build System ### +### - the dependency calculation functions ### +### ### +### Copyright (C) Stefan (metze) Metzmacher 2004 ### +### Released under the GNU GPL ### +########################################################### + +########################################################### +# This function resolves the dependencies +# for the SUBSYSTEMS_LIST +# @SUBSYSTEMS_LIST = _do_calc_subsystem_list($SMB_BUILD_CTX, \@SUBSYSTEMS_LIST); +# +# $SMB_BUILD_CTX - the global SMB_BUILD context +# +# \@SUBSYSTEMS_LIST - the reference to the SUBSYSTEMS_LIST +# +# @SUBSYSTEMS_LIST - the expanded resulting SUBSYSTEMS_LIST +# +sub _do_calc_subsystem_list($$) +{ + my $CTX = shift; + my $subsys_list = shift; + my @SUBSYSTEMS_LIST = @$subsys_list; + + # + # now try to resolve the dependencies for the library + # + my $i = 0; + my $count = $#SUBSYSTEMS_LIST; + for (;$i<=$count;$i++) { + # + # see if the current subsystem depends on other not listed subsystems + # + foreach my $elem (@{$CTX->{DEPEND}{SUBSYSTEMS}{$SUBSYSTEMS_LIST[$i]}{SUBSYSTEMS_LIST}}) { + my $seen = 0; + # + # check if it's already in the list + # + foreach my $elem2 (@SUBSYSTEMS_LIST) { + # + # check of the names matche + # + if ($elem eq $elem2) { + # + # mark it as already in the list + # + $seen = 1; + last; + } + } + + # + # if it's already there skip it + # + if ($seen == 1) { + next; + } + + # + # if it's not there add it + # and $count++ + # + push(@SUBSYSTEMS_LIST,$elem); + $count++; + } + } + + return @SUBSYSTEMS_LIST; +} + +########################################################### +# This function resolves the dependencies +# for the LIBRARIES_LIST based on the SUBSYSTEMS_LIST +# @LIBRARIES_LIST = _do_calc_libraries_list($SMB_BUILD_CTX, \@SUBSYSTEMS_LIST, \@LIBRARIES_LIST); +# +# $SMB_BUILD_CTX - the global SMB_BUILD context +# +# \@SUBSYSTEMS_LIST - the reference to the SUBSYSTEMS_LIST +# +# \@LIBRARIES_LIST - the reference to the LIBRARIES_LIST +# +# @LIBRARIES_LIST - the expanded resulting LIBRARIES_LIST +# +sub _do_calc_libraries_list($$$) +{ + my $CTX = shift; + my $subsys_list = shift; + my @SUBSYSTEMS_LIST = @$subsys_list; + my $libs_list = shift; + my @LIBRARIES_LIST = @$libs_list; + + # + # add the LIBARARIES of each subsysetm in the @SUBSYSTEMS_LIST + # + foreach my $elem (@SUBSYSTEMS_LIST) { + # + # see if the subsystem depends on a not listed LIBRARY + # + foreach my $elem1 (@{$CTX->{DEPEND}{SUBSYSTEMS}{$elem}{LIBRARIES_LIST}}) { + my $seen = 0; + # + # check if it's already in the list + # + foreach my $elem2 (@LIBRARIES_LIST) { + # + # check of the names matche + # + if ($elem1 eq $elem2) { + # + # mark it as already in the list + # + $seen = 1; + last; + } + } + + # + # if it's already there skip it + # + if ($seen == 1) { + next; + } + + # + # if it's not there add it + # + push(@LIBRARIES_LIST,$elem1); + } + } + + return @LIBRARIES_LIST; +} + +########################################################### +# This function creates the dependencies for subsystems +# _do_depend_subsystems($SMB_BUILD_CTX) +# +# $SMB_BUILD_CTX - the global SMB_BUILD context +sub _do_depend_subsystems($) +{ + my $CTX = shift; + + # + # loop on all subsystems + # + foreach my $key (sort keys %{$CTX->{INPUT}{SUBSYSTEMS}}) { + my $name = $CTX->{INPUT}{SUBSYSTEMS}{$key}{NAME}; + my @STATIC_MODULES_LIST = (); + my @INIT_FUNCTIONS = (); + + # + # skip when the subsystem was disabled + # + if ($CTX->{INPUT}{SUBSYSTEMS}{$key}{ENABLE} ne "YES" ) { + next; + } + + # + # create the subsystems used OBJ_LIST + # + my @OBJ_LIST = (); + push (@OBJ_LIST, @{$CTX->{INPUT}{SUBSYSTEMS}{$key}{INIT_OBJ_FILES}}); + push (@OBJ_LIST, @{$CTX->{INPUT}{SUBSYSTEMS}{$key}{ADD_OBJ_FILES}}); + + # + # create the subsystems used SUBSYSTEMS_LIST + # + my @SUBSYSTEMS_LIST = (); + push (@SUBSYSTEMS_LIST, (@{$CTX->{INPUT}{SUBSYSTEMS}{$key}{REQUIRED_SUBSYSTEMS}})); + # + # create the subsystems used LIBRARIES_LIST + # + my @LIBRARIES_LIST = (); + push (@LIBRARIES_LIST, @{$CTX->{INPUT}{SUBSYSTEMS}{$key}{REQUIRED_LIBRARIES}}); + + # + # now collect the info from the subsystems static modules + # + foreach my $subkey (sort keys %{$CTX->{INPUT}{MODULES}}) { + # + # we only want STATIC modules + # + if ($CTX->{INPUT}{MODULES}{$subkey}{BUILD} ne "STATIC") { + next; + } + + # + # we only want modules which belong to the current subsystem + # + if ($CTX->{INPUT}{MODULES}{$subkey}{SUBSYSTEM} ne $name) { + next; + } + + # + # add it to the STATIC_MODULES_LIST + # + push(@STATIC_MODULES_LIST,$subkey); + push (@INIT_FUNCTIONS, $CTX->{INPUT}{MODULES}{$subkey}{INIT_FUNCTION}) if $CTX->{INPUT}{MODULES}{$subkey}{INIT_FUNCTION} ne ""; + + # + # add OBJS of static modules to the subsystems used OBJ_LIST + # + push (@OBJ_LIST, (@{$CTX->{INPUT}{MODULES}{$subkey}{INIT_OBJ_FILES}})); + push (@OBJ_LIST, (@{$CTX->{INPUT}{MODULES}{$subkey}{ADD_OBJ_FILES}})); + + # + # add SUBSYSTEMS of static modules to the subsystems used SUBSYSTEMS_LIST + # + push (@SUBSYSTEMS_LIST, (@{$CTX->{INPUT}{MODULES}{$subkey}{REQUIRED_SUBSYSTEMS}})); + + # + # add LIBRARIES of static modules to the subsystems used LIBRARIES_LIST + # + push (@LIBRARIES_LIST, (@{$CTX->{INPUT}{MODULES}{$subkey}{REQUIRED_LIBRARIES}})); + } + + # + # set the lists + # + @{$CTX->{DEPEND}{SUBSYSTEMS}{$key}{INIT_FUNCTIONS}} = @INIT_FUNCTIONS; + @{$CTX->{DEPEND}{SUBSYSTEMS}{$key}{OBJ_LIST}} = @OBJ_LIST; + @{$CTX->{DEPEND}{SUBSYSTEMS}{$key}{STATIC_MODULES_LIST}} = @STATIC_MODULES_LIST; + @{$CTX->{DEPEND}{SUBSYSTEMS}{$key}{SUBSYSTEMS_LIST}} = @SUBSYSTEMS_LIST; + @{$CTX->{DEPEND}{SUBSYSTEMS}{$key}{LIBRARIES_LIST}} = @LIBRARIES_LIST; + } + + return; +} + +########################################################### +# This function creates the dependencies for ext libs +# _do_depend_ext_libs($SMB_BUILD_CTX) +# +# $SMB_BUILD_CTX - the global SMB_BUILD context +sub _do_depend_ext_libs($) +{ + my $CTX = shift; + + # + # loop over all ext libs + # + foreach my $key (sort keys %{$CTX->{INPUT}{EXT_LIBS}}) { + my $name = $CTX->{INPUT}{EXT_LIBS}{$key}{NAME}; + + # + # if it's not a shared module skip it + # + if ($CTX->{INPUT}{EXT_LIBS}{$key}{ENABLE} ne "YES") { + next; + } + + # + # set the lists + # + $CTX->{DEPEND}{EXT_LIBS}{$key}{NAME} = $name; + @{$CTX->{DEPEND}{EXT_LIBS}{$key}{LIBS}} = @{$CTX->{INPUT}{EXT_LIBS}{$key}{LIBS}}; + @{$CTX->{DEPEND}{EXT_LIBS}{$key}{CFLAGS}} = @{$CTX->{INPUT}{EXT_LIBS}{$key}{CFLAGS}}; + @{$CTX->{DEPEND}{EXT_LIBS}{$key}{CPPFLAGS}} = @{$CTX->{INPUT}{EXT_LIBS}{$key}{CPPFLAGS}}; + @{$CTX->{DEPEND}{EXT_LIBS}{$key}{LDFLAGS}} = @{$CTX->{INPUT}{EXT_LIBS}{$key}{LDFLAGS}}; + } + + return; +} + +########################################################### +# This function creates the dependencies for shared modules +# _do_depend_shared_modules($SMB_BUILD_CTX) +# +# $SMB_BUILD_CTX - the global SMB_BUILD context +sub _do_depend_shared_modules($) +{ + my $CTX = shift; + + # + # loop over all shared modules + # + foreach my $key (sort keys %{$CTX->{INPUT}{MODULES}}) { + my $name = $CTX->{INPUT}{MODULES}{$key}{NAME}; + + # + # if it's not a shared module skip it + # + if ($CTX->{INPUT}{MODULES}{$key}{BUILD} ne "SHARED" ) { + next; + } + + # + # create the shared modules used SUBSYSTEMS_LIST + # + my @SUBSYSTEMS_LIST = (); + push (@SUBSYSTEMS_LIST, (@{$CTX->{INPUT}{MODULES}{$key}{REQUIRED_SUBSYSTEMS}})); + + # + # now try to resolve the dependencies for the shared module + # + @SUBSYSTEMS_LIST = _do_calc_subsystem_list($CTX, \@SUBSYSTEMS_LIST); + + # + # create the shared modules used LIBRARIES_LIST + # + my @LIBRARIES_LIST = (); + push (@LIBRARIES_LIST, @{$CTX->{INPUT}{MODULES}{$key}{REQUIRED_LIBRARIES}}); + + # + # add the LIBARARIES of each subsysetm in the @SUBSYSTEMS_LIST + # + @LIBRARIES_LIST = _do_calc_libraries_list($CTX, \@SUBSYSTEMS_LIST, \@LIBRARIES_LIST); + + # + # set the lists + # + @{$CTX->{DEPEND}{SHARED_MODULES}{$key}{SUBSYSTEMS_LIST}} = @SUBSYSTEMS_LIST; + @{$CTX->{DEPEND}{SHARED_MODULES}{$key}{LIBRARIES_LIST}} = @LIBRARIES_LIST; + } + + return; +} + +########################################################### +# This function creates the dependencies for libraries +# _do_depend_libraries($SMB_BUILD_CTX) +# +# $SMB_BUILD_CTX - the global SMB_BUILD context +sub _do_depend_libraries($) +{ + my $CTX = shift; + + # + # loop over all libraries + # + foreach my $key (sort keys %{$CTX->{INPUT}{LIBRARIES}}) { + my $name = $CTX->{INPUT}{LIBRARIES}{$key}{NAME}; + + # + # if it's not a library skip it + # + if ($CTX->{INPUT}{LIBRARIES}{$key}{ENABLE} ne "YES" ) { + next; + } + + # + # create the libraries used SUBSYSTEMS_LIST + # + my @SUBSYSTEMS_LIST = (); + push (@SUBSYSTEMS_LIST, @{$CTX->{INPUT}{LIBRARIES}{$key}{REQUIRED_SUBSYSTEMS}}); + + # + # now try to resolve the dependencies for the library + # + @SUBSYSTEMS_LIST = _do_calc_subsystem_list($CTX, \@SUBSYSTEMS_LIST); + + # + # create the libraries used LIBRARIES_LIST + # + my @LIBRARIES_LIST = (); + push (@LIBRARIES_LIST, @{$CTX->{INPUT}{LIBRARIES}{$key}{REQUIRED_LIBRARIES}}); + + # + # add the LIBARARIES of each subsysetm in the @SUBSYSTEMS_LIST + # + @LIBRARIES_LIST = _do_calc_libraries_list($CTX, \@SUBSYSTEMS_LIST, \@LIBRARIES_LIST); + + # + # set the lists + # + @{$CTX->{DEPEND}{LIBRARIES}{$key}{SUBSYSTEMS_LIST}} = @SUBSYSTEMS_LIST; + @{$CTX->{DEPEND}{LIBRARIES}{$key}{LIBRARIES_LIST}} = @LIBRARIES_LIST; + } + + return; +} + +########################################################### +# This function creates the dependencies for binaries +# _do_depend_binaries($SMB_BUILD_CTX) +# +# $SMB_BUILD_CTX - the global SMB_BUILD context +sub _do_depend_binaries($) +{ + my $CTX = shift; + + # + # loop over all binaries + # + foreach my $key (sort keys %{$CTX->{INPUT}{BINARIES}}) { + my $name = $CTX->{INPUT}{BINARIES}{$key}{NAME}; + + # + # skip when the binary was disabled + # + if ($CTX->{INPUT}{BINARIES}{$key}{ENABLE} ne "YES" ) { + next; + } + + # + # create the binaries used SUBSYSTEMS_LIST + # + my @SUBSYSTEMS_LIST = (); + push (@SUBSYSTEMS_LIST, @{$CTX->{INPUT}{BINARIES}{$key}{REQUIRED_SUBSYSTEMS}}); + + # + # now try to resolve the dependencies for the binary + # + @SUBSYSTEMS_LIST = _do_calc_subsystem_list($CTX, \@SUBSYSTEMS_LIST); + + my @INIT_FUNCTIONS = (); + + foreach my $subkey (@SUBSYSTEMS_LIST) + { + push (@INIT_FUNCTIONS, $CTX->{INPUT}{SUBSYSTEMS}{$subkey}{INIT_FUNCTION}) if $CTX->{INPUT}{SUBSYSTEMS}{$subkey}{INIT_FUNCTION} ne ""; + + } + + # + # create the binaries used LIBRARIES_LIST + # + my @LIBRARIES_LIST = (); + push (@LIBRARIES_LIST, @{$CTX->{INPUT}{BINARIES}{$key}{REQUIRED_LIBRARIES}}); + + # + # add the LIBARARIES of each subsysetm in the @SUBSYSTEMS_LIST + # + @LIBRARIES_LIST = _do_calc_libraries_list($CTX, \@SUBSYSTEMS_LIST, \@LIBRARIES_LIST); + + # + # set the lists + # + @{$CTX->{DEPEND}{BINARIES}{$key}{SUBSYSTEMS_LIST}} = @SUBSYSTEMS_LIST; + @{$CTX->{DEPEND}{BINARIES}{$key}{LIBRARIES_LIST}} = @LIBRARIES_LIST; + @{$CTX->{DEPEND}{BINARIES}{$key}{INIT_FUNCTIONS}} = @INIT_FUNCTIONS; + } + + return; +} + +########################################################### +# This function creates the dependency tree from the SMB_BUILD +# context +# create_depend($SMB_BUILD_CTX) +# +# $SMB_BUILD_CTX - the global SMB_BUILD context +sub create_depend($) +{ + my $CTX = shift; + + _do_depend_ext_libs($CTX); + + _do_depend_subsystems($CTX); + + _do_depend_shared_modules($CTX); + + _do_depend_libraries($CTX); + + _do_depend_binaries($CTX); + + return; +} +1; diff --git a/source4/build/smb_build/input.pl b/source4/build/smb_build/input.pl deleted file mode 100644 index 8488a33c3c..0000000000 --- a/source4/build/smb_build/input.pl +++ /dev/null @@ -1,139 +0,0 @@ -########################################################### -### SMB Build System ### -### - the input checking functions ### -### ### -### Copyright (C) Stefan (metze) Metzmacher 2004 ### -### Released under the GNU GPL ### -########################################################### - -sub strtrim($) -{ - my $str = shift; - my @ar = (); - - $str =~ s/^[\t\n ]*//g; - - $str =~ s/[\t\n ]*$//g; - - return $str; -} - -sub str2array($) -{ - my $str = shift; - my @ar = (); - - $str =~ s/^[\t\n ]*//g; - - $str =~ s/[\t\n ]*$//g; - - $str =~ s/([\t\n ]+)/ /g; - - if (length($str)==0) { - return (); - } - - @ar = split(/[ \t\n]/,$str); - - return @ar; -} - -sub _check_subsystems($) -{ - 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; - } - } - - return; -} - -sub _check_modules($) -{ - my $CTX = 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; - } - - if ($build eq "DEFAULT") { - $build = $default_build; - $use_default = 1; - } - - 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; - } - } - - return; -} - -sub _check_libraries($) -{ - my $CTX = 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; - } - } - - return; -} - -sub _check_binaries($) -{ - my $CTX = 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; - } - } - - return; -} - -########################################################### -# This function checks the input from the configure script -# -# check_input($SMB_BUILD_CTX) -# -# $SMB_BUILD_CTX - the global SMB_BUILD context -sub check_input($) -{ - my $CTX = shift; - - _check_subsystems($CTX); - - _check_modules($CTX); - - _check_libraries($CTX); - - _check_binaries($CTX); - - return; -} diff --git a/source4/build/smb_build/input.pm b/source4/build/smb_build/input.pm new file mode 100644 index 0000000000..d3737ea7d1 --- /dev/null +++ b/source4/build/smb_build/input.pm @@ -0,0 +1,140 @@ +########################################################### +### SMB Build System ### +### - the input checking functions ### +### ### +### Copyright (C) Stefan (metze) Metzmacher 2004 ### +### Released under the GNU GPL ### +########################################################### + +sub strtrim($) +{ + my $str = shift; + my @ar = (); + + $str =~ s/^[\t\n ]*//g; + + $str =~ s/[\t\n ]*$//g; + + return $str; +} + +sub str2array($) +{ + my $str = shift; + my @ar = (); + + $str =~ s/^[\t\n ]*//g; + + $str =~ s/[\t\n ]*$//g; + + $str =~ s/([\t\n ]+)/ /g; + + if (length($str)==0) { + return (); + } + + @ar = split(/[ \t\n]/,$str); + + return @ar; +} + +sub _check_subsystems($) +{ + 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; + } + } + + return; +} + +sub _check_modules($) +{ + my $CTX = 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; + } + + if ($build eq "DEFAULT") { + $build = $default_build; + $use_default = 1; + } + + 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; + } + } + + return; +} + +sub _check_libraries($) +{ + my $CTX = 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; + } + } + + return; +} + +sub _check_binaries($) +{ + my $CTX = 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; + } + } + + return; +} + +########################################################### +# This function checks the input from the configure script +# +# check_input($SMB_BUILD_CTX) +# +# $SMB_BUILD_CTX - the global SMB_BUILD context +sub check_input($) +{ + my $CTX = shift; + + _check_subsystems($CTX); + + _check_modules($CTX); + + _check_libraries($CTX); + + _check_binaries($CTX); + + return; +} +1; diff --git a/source4/build/smb_build/main.pl b/source4/build/smb_build/main.pl deleted file mode 100644 index 18d3de3991..0000000000 --- a/source4/build/smb_build/main.pl +++ /dev/null @@ -1,22 +0,0 @@ -########################################################### -### SMB Build System ### -### - the main program ### -### ### -### Copyright (C) Stefan (metze) Metzmacher 2004 ### -### Released under the GNU GPL ### -########################################################### - -sub smb_build_main($) -{ - check_input($SMB_BUILD_CTX); - - create_depend($SMB_BUILD_CTX); - - create_output($SMB_BUILD_CTX); - - create_makefile_in($SMB_BUILD_CTX); - - create_smb_build_h($SMB_BUILD_CTX); - - return 0; -} diff --git a/source4/build/smb_build/main.pm b/source4/build/smb_build/main.pm new file mode 100644 index 0000000000..4df7be7dae --- /dev/null +++ b/source4/build/smb_build/main.pm @@ -0,0 +1,32 @@ +########################################################### +### SMB Build System ### +### - the main program ### +### ### +### Copyright (C) Stefan (metze) Metzmacher 2004 ### +### Released under the GNU GPL ### +########################################################### + +use makefile; +use depend; +use smb_build_h; +use input; +use config_mk; +use output; +use strict; + +sub smb_build_main($) +{ + my $SMB_BUILD_CTX = shift; + check_input($SMB_BUILD_CTX); + + create_depend($SMB_BUILD_CTX); + + create_output($SMB_BUILD_CTX); + + create_makefile_in($SMB_BUILD_CTX); + + create_smb_build_h($SMB_BUILD_CTX); + + return 0; +} +1; diff --git a/source4/build/smb_build/makefile.pl b/source4/build/smb_build/makefile.pl deleted file mode 100644 index a5e86e76f0..0000000000 --- a/source4/build/smb_build/makefile.pl +++ /dev/null @@ -1,915 +0,0 @@ -########################################################### -### SMB Build System ### -### - create output for Makefile ### -### ### -### Copyright (C) Stefan (metze) Metzmacher 2004 ### -### Released under the GNU GPL ### -########################################################### - -sub _prepare_command_interpreters($) -{ - my $ctx = shift; - my $output; - - $output = " -SHELL=/bin/sh -PERL=\@PERL\@ -"; - return $output; -} - -sub _prepare_path_vars($) -{ - my $ctx = shift; - my $output; - - $output = " -prefix=\@prefix\@ -exec_prefix=\@exec_prefix\@ -VPATH=\@srcdir\@ -srcdir=\@srcdir\@ -builddir=\@builddir\@ -eparserdir=\@eparserdir\@ - -BASEDIR= \@prefix\@ -BINDIR = \@bindir\@ -SBINDIR = \@sbindir\@ -LIBDIR = \@libdir\@ -CONFIGDIR = \@configdir\@ -VARDIR = \@localstatedir\@ - - -# The permissions to give the executables -INSTALLPERMS = 0755 - -# set these to where to find various files -# These can be overridden by command line switches (see smbd(8)) -# or in smb.conf (see smb.conf(5)) -LOGFILEBASE = \@logfilebase\@ -CONFIGFILE = \$(CONFIGDIR)/smb.conf -LMHOSTSFILE = \$(CONFIGDIR)/lmhosts -NCALRPCDIR = \@localstatedir\@/ncalrpc - -# This is where smbpasswd et al go -PRIVATEDIR = \@privatedir\@ -SMB_PASSWD_FILE = \$(PRIVATEDIR)/smbpasswd - -# the directory where lock files go -LOCKDIR = \@lockdir\@ - -# the directory where pid files go -PIDDIR = \@piddir\@ - -PASSWD_FLAGS = -DSMB_PASSWD_FILE=\\\"\$(SMB_PASSWD_FILE)\\\" -DPRIVATE_DIR=\\\"\$(PRIVATEDIR)\\\" -PATH_FLAGS1 = -DCONFIGFILE=\\\"\$(CONFIGFILE)\\\" -DSBINDIR=\\\"\$(SBINDIR)\\\" -PATH_FLAGS2 = \$(PATH_FLAGS1) -DBINDIR=\\\"\$(BINDIR)\\\" -PATH_FLAGS3 = \$(PATH_FLAGS2) -DLMHOSTSFILE=\\\"\$(LMHOSTSFILE)\\\" -PATH_FLAGS4 = \$(PATH_FLAGS3) -DLOCKDIR=\\\"\$(LOCKDIR)\\\" -DPIDDIR=\\\"\$(PIDDIR)\\\" -PATH_FLAGS5 = \$(PATH_FLAGS4) -DLIBDIR=\\\"\$(LIBDIR)\\\" \\ - -DLOGFILEBASE=\\\"\$(LOGFILEBASE)\\\" -DSHLIBEXT=\\\"\@SHLIBEXT\@\\\" -PATH_FLAGS6 = \$(PATH_FLAGS5) -DCONFIGDIR=\\\"\$(CONFIGDIR)\\\" -DNCALRPCDIR=\\\"\$(NCALRPCDIR)\\\" -PATH_FLAGS = \$(PATH_FLAGS6) \$(PASSWD_FLAGS) -"; - return $output; -} - -sub _prepare_compiler_linker($) -{ - my $ctx = shift; - my $output; - - $output = " -CC=\@CC\@ -CC_FLAGS=-Iinclude -I. -I\$(srcdir)/include -I\$(srcdir) -Ilib \@CFLAGS\@ \@CPPFLAGS\@ - -LD=\@CC\@ -LD_FLAGS=\@LDFLAGS\@ \@CFLAGS\@ - -STLD=ar -STLD_FLAGS=-rc - -SHLD=\@CC\@ -SHLD_FLAGS=\@LDSHFLAGS\@ \@LDFLAGS\@ -"; - return $output; -} - -sub _prepare_default_rule($) -{ - my $ctx = shift; - my $output; - - $output = " -default: all -"; - return $output; -} - -sub _prepare_SUFFIXES($) -{ - my $ctx = shift; - my $output; - - $output = " -.SUFFIXES: -.SUFFIXES: .c .o .h .h.gch .a .so -"; - return $output; -} - -sub _prepare_IDL($) -{ - my $ctx = shift; - my $output; - - $output = " -idl_full: build/pidl/idl.pm - CPP=\"\@CPP\@\" PERL=\"\$(PERL)\" script/build_idl.sh FULL - -idl: build/pidl/idl.pm - \@CPP=\"\@CPP\@\" script/build_idl.sh PARTIAL - -eparser_idl: build/pidl/idl.pm - CPP=\"\@CPP\@\" PERL=\"\$(PERL)\" EPARSERPREFIX=\"\$(eparserdir)\" script/build_idl.sh EPARSER - -build/pidl/idl.pm: build/pidl/idl.yp - -yapp -s build/pidl/idl.yp - -pch: proto include/includes.h.gch - -pch_clean: - -rm -f include/includes.h.gch - -basics: idl proto_exists - -"; - return $output; -} - -sub _prepare_dummy_MAKEDIR() -{ - my $ctx = shift; - my $output; - - $output = " -bin/.dummy: - \@: >> \$\@ || : > \$\@ - -dynconfig.o: dynconfig.c Makefile - \@echo Compiling \$*.c - \@\$(CC) \$(CC_FLAGS) \@PICFLAG\@ \$(PATH_FLAGS) -c \$< -o \$\@ -\@BROKEN_CC\@ -mv `echo \$\@ | sed 's%^.*/%%g'` \$\@ - -"; - return $output; -} - -########################################################### -# This function creates a standard make rule which is using $(CC) -# -# $output = _prepare_std_CC_rule($srcext,$destext,$flags,$message,$comment) -# -# $srcext - sourcefile extension -# -# $destext - destinationfile extension -# -# $flags - additional compiler flags -# -# $message - logmessage which is echoed while running this rule -# -# $comment - just a comment what this rule should do -# -# $output - the resulting output buffer -sub _prepare_std_CC_rule($$$$$) -{ - my $src = shift; - my $dst = shift; - my $flags = shift; - my $message = shift; - my $comment = shift; - my $flagsstr = ""; - my $output; - - $output = " -################################### -# Start $comment -.$src.$dst: - \@echo $message \$*.$src - \@\$(CC) \$(CC_FLAGS) $flags -c \$< -o \$\@ -\@BROKEN_CC\@ -mv `echo \$\@ | sed 's%^.*/%%g'` \$\@ -#End $comment -################################### -"; - - return $output; -} - -sub array2oneperline($) -{ - my $array = shift; - my $i; - my $output = ""; - - foreach my $str (@{$array}) { - if (!defined($str)) { - next; - } - - $output .= " \\\n\t\t"; - $output .= $str; - } - - return $output; -} - -sub array2oneline($) -{ - my $array = shift; - my $i; - my $output = ""; - - foreach my $str (@{$array}) { - if (!defined($str)) { - next; - } - - $output .= $str; - $output .= " "; - } - - return $output; -} - -########################################################### -# This function creates a object file list -# -# $output = _prepare_var_obj_list($var, $var_ctx) -# -# $var_ctx - the subsystem context -# -# $var_ctx->{NAME} - the name -# $var_ctx->{OBJ_LIST} - the list of objectfiles which sould be linked to this -# -# $output - the resulting output buffer -sub _prepare_var_obj_list($$) -{ - my $var = shift; - my $ctx = shift; - my $tmpobjlist; - my $output; - - $tmpobjlist = array2oneperline($ctx->{OBJ_LIST}); - - $output = " -################################### -# Start $var $ctx->{NAME} OBJ LIST -$var\_$ctx->{NAME}_OBJS =$tmpobjlist -# End $var $ctx->{NAME} OBJ LIST -################################### -"; - - return $output; -} - -########################################################### -# This function creates a object file list for a subsystem -# -# $output = _prepare_subsystem_obj_list($subsystem_ctx) -# -# $subsystem_ctx - the subsystem context -# -# $subsystem_ctx->{NAME} - the subsystem name -# $subsystem_ctx->{OBJ_LIST} - the list of objectfiles which sould be linked to this subsystem -# -# $output - the resulting output buffer -sub _prepare_subsystem_obj_list($) -{ - my $ctx = shift; - - return _prepare_var_obj_list("SUBSYSTEM",$ctx); -} - -########################################################### -# This function creates a object file list for a module -# -# $output = _prepare_module_obj_and_lib_list($module_ctx) -# -# $module_ctx - the module context -# -# $module_ctx->{NAME} - the module binary name -# $module_ctx->{OBJ_LIST} - the list of objectfiles which sould be linked to this module -# -# $output - the resulting output buffer -sub _prepare_module_obj_list($) -{ - my $ctx = shift; - - return _prepare_var_obj_list("MODULE",$ctx); - -} - -########################################################### -# This function creates a make rule for linking a shared module -# -# $output = _prepare_shared_module_rule($module_ctx) -# -# $module_ctx - the module context -# -# $module_ctx->{MODULE} - the module binary name -# $module_ctx->{DEPEND_LIST} - the list of rules on which this module depends -# $module_ctx->{LINK_LIST} - the list of objectfiles and external libraries -# which sould be linked to this module -# $module_ctx->{LINK_FLAGS} - linker flags used by this module -# -# $output - the resulting output buffer -sub _prepare_shared_module_rule($) -{ - my $ctx = shift; - my $tmpdepend; - my $tmplink; - my $tmpflag; - my $output; - - $tmpdepend = array2oneperline($ctx->{DEPEND_LIST}); - $tmplink = array2oneperline($ctx->{LINK_LIST}); - $tmpflag = array2oneperline($ctx->{LINK_FLAGS}); - - $output = " -################################### -# Start Module $ctx->{MODULE} -MODULE_$ctx->{NAME}_DEPEND_LIST =$tmpdepend -MODULE_$ctx->{NAME}_LINK_LIST =$tmplink -MODULE_$ctx->{NAME}_LINK_FLAGS =$tmpflag -# -bin/$ctx->{MODULE}: \$(MODULE_$ctx->{NAME}_DEPEND_LIST) bin/.dummy - \@echo Linking \$\@ - \@\$(SHLD) \$(SHLD_FLAGS) -o \$\@ \\ - \$(MODULE_$ctx->{NAME}_LINK_FLAGS) \\ - \$(MODULE_$ctx->{NAME}_LINK_LIST) -module_$ctx->{MODULE}: basics bin/$ctx->{MODULE} -# Module $ctx->{MODULE} -################################### -"; - - return $output; -} - -########################################################### -# This function creates a object file list for a library -# -# $output = _prepare_library_obj_and_lib_list($library_ctx) -# -# $library_ctx - the library context -# -# $library_ctx->{NAME} - the library binary name -# $library_ctx->{OBJ_LIST} - the list of objectfiles which sould be linked to this library -# -# $output - the resulting output buffer -sub _prepare_library_obj_list($) -{ - my $ctx = shift; - - return _prepare_var_obj_list("LIBRARY",$ctx); - -} - -########################################################### -# This function creates a make rule for linking a library -# -# $output = _prepare_library_rule($library_ctx) -# -# $library_ctx - the library context -# -# $library_ctx->{NAME} - the library name -# -# $library_ctx->{DEPEND_LIST} - the list of rules on which this library depends -# -# $library_ctx->{STATIC_LIBRARY_NAME} - the static library name -# $library_ctx->{STATIC_LINK_LIST} - the list of objectfiles which sould be linked -# to this static library -# $library_ctx->{STATIC_LINK_FLAGS} - linker flags used by this static library -# -# $library_ctx->{SHARED_LIBRARY_NAME} - the shared library name -# $library_ctx->{SHARED_LIBRARY_REALNAME} - the shared library real name -# $library_ctx->{SHARED_LIBRARY_SONAME} - the shared library soname -# $library_ctx->{SHARED_LINK_LIST} - the list of objectfiles and external libraries -# which sould be linked to this shared library -# $library_ctx->{SHARED_LINK_FLAGS} - linker flags used by this shared library -# -# $output - the resulting output buffer -sub _prepare_library_rule($) -{ - my $ctx = shift; - my $tmpdepend; - my $tmpstlink; - my $tmpstflag; - my $tmpshlink; - my $tmpshflag; - my $tmprules; - my $output; - - $tmpdepend = array2oneperline($ctx->{DEPEND_LIST}); - - $tmpstlink = array2oneperline($ctx->{STATIC_LINK_LIST}); - $tmpstflag = array2oneperline($ctx->{STATIC_LINK_FLAGS}); - - $tmpshlink = array2oneperline($ctx->{SHARED_LINK_LIST}); - $tmpshflag = array2oneperline($ctx->{SHARED_LINK_FLAGS}); - - $tmprules = "bin/$ctx->{STATIC_LIBRARY_NAME}"; - - $output = " -################################### -# Start Library $ctx->{NAME} -# -LIBRARY_$ctx->{NAME}_DEPEND_LIST =$tmpdepend -# -LIBRARY_$ctx->{NAME}_STATIC_LINK_LIST =$tmpstlink -LIBRARY_$ctx->{NAME}_STATIC_LINK_FLAGS =$tmpstflag -# -LIBRARY_$ctx->{NAME}_SHARED_LINK_LIST =$tmpshlink -LIBRARY_$ctx->{NAME}_SHARED_LINK_FLAGS =$tmpshflag -# -# Static $ctx->{STATIC_LIBRARY_NAME} -bin/$ctx->{STATIC_LIBRARY_NAME}: \$(LIBRARY_$ctx->{NAME}_DEPEND_LIST) bin/.dummy - \@echo Linking \$\@ - \@\$(STLD) \$(STLD_FLAGS) \$\@ \\ - \$(LIBRARY_$ctx->{NAME}_STATIC_LINK_FLAGS) \\ - \$(LIBRARY_$ctx->{NAME}_STATIC_LINK_LIST) -"; - - if (defined($ctx->{SHARED_LIBRARY_NAME})) { - $output .= " -# Shared $ctx->{SHARED_LIBRARY_REALNAME} -bin/$ctx->{SHARED_LIBRARY_REALNAME}: \$(LIBRARY_$ctx->{NAME}_DEPEND_LIST) bin/.dummy - \@echo Linking \$\@ - \@\$(SHLD) \$(SHLD_FLAGS) -o \$\@ \\ - \$(LIBRARY_$ctx->{NAME}_SHARED_LINK_FLAGS) \\ - \$(LIBRARY_$ctx->{NAME}_SHARED_LINK_LIST) -# Symlink $ctx->{SHARED_LIBRARY_SONAME} -bin/$ctx->{SHARED_LIBRARY_SONAME}: bin/$ctx->{SHARED_LIBRARY_REALNAME} bin/.dummy - \@echo Symlink \$\@ - \@ln -sf $ctx->{SHARED_LIBRARY_REALNAME} \$\@ -# Symlink $ctx->{SHARED_LIBRARY_NAME} -bin/$ctx->{SHARED_LIBRARY_NAME}: bin/$ctx->{SHARED_LIBRARY_SONAME} bin/.dummy - \@echo Symlink \$\@ - \@ln -sf $ctx->{SHARED_LIBRARY_SONAME} \$\@ -"; - $tmprules .= " bin/$ctx->{SHARED_LIBRARY_NAME}" - } - - $output .= " -library_$ctx->{NAME}: basics $tmprules -# End Library $ctx->{NAME} -################################### -"; - - return $output; -} - -########################################################### -# This function creates a object file list for a binary -# -# $output = _prepare_binary_obj_and_lib_list($binary_ctx) -# -# $binary_ctx - the binary context -# -# $binary_ctx->{NAME} - the binary name -# $binary_ctx->{OBJ_LIST} - the list of objectfiles which sould be linked to this binary -# -# $output - the resulting output buffer -sub _prepare_binary_obj_list($) -{ - my $ctx = shift; - - return _prepare_var_obj_list("BINARY",$ctx); - -} - -########################################################### -# This function creates a make rule for linking a binary -# -# $output = _prepare_binary_rule($binary_ctx) -# -# $binary_ctx - the binary context -# -# $binary_ctx->{NAME} - the binary name -# $binary_ctx->{BINARY} - the binary binary name -# -# $binary_ctx->{DEPEND_LIST} - the list of rules on which this binary depends -# $binary_ctx->{LINK_LIST} - the list of objectfiles and external libraries -# which sould be linked to this binary -# $binary_ctx->{LINK_FLAGS} - linker flags used by this binary -# -# $output - the resulting output buffer -sub _prepare_binary_rule($) -{ - my $ctx = shift; - my $tmpdepend; - my $tmplink; - my $tmpflag; - my $output; - - $tmpdepend = array2oneperline($ctx->{DEPEND_LIST}); - $tmplink = array2oneperline($ctx->{LINK_LIST}); - $tmpflag = array2oneperline($ctx->{LINK_FLAGS}); - - $output = " -################################### -# Start Binary $ctx->{BINARY} -# -BINARY_$ctx->{NAME}_DEPEND_LIST =$tmpdepend -BINARY_$ctx->{NAME}_LINK_LIST =$tmplink -BINARY_$ctx->{NAME}_LINK_FLAGS =$tmpflag -# -bin/$ctx->{BINARY}: bin/.dummy \$(BINARY_$ctx->{NAME}_DEPEND_LIST) - \@echo Linking \$\@ - \@\$(LD) \$(LD_FLAGS) -o \$\@ \\ - \$(BINARY_$ctx->{NAME}_LINK_FLAGS) \\ - \$(BINARY_$ctx->{NAME}_LINK_LIST) -binary_$ctx->{BINARY}: basics bin/$ctx->{BINARY} -# End Binary $ctx->{BINARY} -################################### -"; - - return $output; -} - -########################################################### -# This function creates a object file list for make proto -# -# $output = _prepare_proto_obj_list($proto_ctx) -# -# $proto_ctx - the proto context - -# $proto_ctx->{OBJ_LIST} - the list of objectfiles which sould be scanned by make proto -# -# $output - the resulting output buffer -sub _prepare_proto_obj_list($) -{ - my $ctx = shift; - my $tmplist; - my $output; - - $tmplist = array2oneperline($ctx->{OBJ_LIST}); - - $output = " -################################### -# Start PROTO OBJ LIST -PROTO_OBJS =$tmplist -# End PROTO OBJ LIST -################################### -"; - - return $output; -} - -sub _prepare_proto_rules() -{ - my $output = ""; - - $output .= " -# Making this target will just make sure that the prototype files -# exist, not necessarily that they are up to date. Since they're -# removed by 'make clean' this will always be run when you do anything -# afterwards. -proto_exists: include/proto.h include/build_env.h - -delheaders: pch_clean - -rm -f \$(builddir)/include/proto.h \$(builddir)/include/build_env.h: - -include/proto.h: - \@cd \$(srcdir) && \$(SHELL) script/mkproto.sh \"\$(PERL)\" \\ - -h _PROTO_H_ \$(builddir)/include/proto.h \\ - \$(PROTO_OBJS) - -include/build_env.h: - \@echo Building include/build_env.h - \@cd \$(srcdir) && \$(SHELL) script/build_env.sh \$(srcdir) \$(builddir) \$(CC) > \$(builddir)/include/build_env.h - -# 'make headers' or 'make proto' calls a subshell because we need to -# make sure these commands are executed in sequence even for a -# parallel make. -headers: delheaders proto_exists - -proto: idl headers - -proto_test: - \@[ -f \$(builddir)/include/proto.h ] || \$(MAKE) proto - -clean: delheaders - -rm -f *.o */*.o */*/*.o */*/*/*.o bin/* - -rm -rf librpc/gen_* - -distclean: clean - -rm -f bin/.dummy - -rm -f include/config.h - -rm -f Makefile* - -rm -f config.status - -rm -f config.smb_build.* - -rm -f config.log config.cache - -removebackup: - -rm -f *.bak *~ */*.bak */*~ */*/*.bak */*/*~ */*/*/*.bak */*/*/*~ - -realdistclean: distclean removebackup - -rm -f include/config.h.in - -rm -f lib/version.h - -rm -f configure -"; - - return $output; -} - -sub _prepare_make_target($) -{ - my $ctx = shift; - my $tmpdepend; - my $output; - - $tmpdepend = array2oneperline($ctx->{DEPEND_LIST}); - - $output = " -################################### -# Start Target $ctx->{TARGET} -$ctx->{TARGET}: basics $tmpdepend -# End Target $ctx->{TARGET} -################################### -"; - - return $output; -} - -sub _prepare_obj_lists($) -{ - my $CTX = shift; - my $output = ""; - - foreach my $key (sort keys %{$CTX->{OUTPUT}{SUBSYSTEMS}}) { - $output .= _prepare_subsystem_obj_list(\%{$CTX->{OUTPUT}{SUBSYSTEMS}{$key}}); - } - - foreach my $key (sort keys %{$CTX->{OUTPUT}{SHARED_MODULES}}) { - $output .= _prepare_module_obj_list(\%{$CTX->{OUTPUT}{SHARED_MODULES}{$key}}); - } - - foreach my $key (sort keys %{$CTX->{OUTPUT}{LIBRARIES}}) { - $output .= _prepare_library_obj_list(\%{$CTX->{OUTPUT}{LIBRARIES}{$key}}); - } - - foreach my $key (sort keys %{$CTX->{OUTPUT}{BINARIES}}) { - $output .= _prepare_binary_obj_list(\%{$CTX->{OUTPUT}{BINARIES}{$key}}); - } - - $output .= _prepare_proto_obj_list(\%{$CTX->{OUTPUT}{PROTO}}); - - return $output; -} - -sub _prepare_install_rules($) -{ - my $CTX = shift; - my $output = ""; - - $output .= " - -showlayout: - \@echo \"Samba will be installed into:\" - \@echo \" basedir: \$(BASEDIR)\" - \@echo \" bindir: \$(BINDIR)\" - \@echo \" sbindir: \$(SBINDIR)\" - \@echo \" libdir: \$(LIBDIR)\" - \@echo \" vardir: \$(VARDIR)\" - \@echo \" privatedir: \$(PRIVATEDIR)\" - \@echo \" piddir: \$(PIDDIR)\" - \@echo \" lockdir: \$(LOCKDIR)\" - -SBIN_PROGS = bin/smbd - -BIN_PROGS = bin/smbclient - -TORTURE_PROGS = bin/smbtorture \\ - bin/gentest \\ - bin/locktest \\ - bin/masktest \\ - bin/ndrdump - -LDB_PROGS = bin/ldbadd \\ - bin/ldbdel \\ - bin/ldbmodify \\ - bin/ldbedit \\ - bin/ldbsearch - -REG_PROGS = bin/regpatch \\ - bin/regshell \\ - bin/regtree \\ - bin/regpatch \\ - bin/regdiff - -install: showlayout installbin installtorture installldb installreg installdat - -# DESTDIR is used here to prevent packagers wasting their time -# duplicating the Makefile. Remove it and you will have the privelege -# of package each samba release for muliple versions of multiple -# distributions and operating systems, or at least supplying patches -# to all the packaging files required for this, prior to committing -# the removal of DESTDIR. Do not remove it even though you think it -# is not used - -installdirs: - \@\$(SHELL) \$(srcdir)/script/installdirs.sh \$(DESTDIR)\$(BASEDIR) \$(DESTDIR)\$(BINDIR) \$(DESTDIR)\$(SBINDIR) \$(DESTDIR)\$(LIBDIR) \$(DESTDIR)\$(VARDIR) \$(DESTDIR)\$(PRIVATEDIR) \$(DESTDIR)\$(PIDDIR) \$(DESTDIR)\$(LOCKDIR) - -installbin: all installdirs - \@\$(SHELL) \$(srcdir)/script/installbin.sh \$(INSTALLPERMS) \$(DESTDIR)\$(BASEDIR) \$(DESTDIR)\$(SBINDIR) \$(DESTDIR)\$(LIBDIR) \$(DESTDIR)\$(VARDIR) \$(SBIN_PROGS) - \@\$(SHELL) \$(srcdir)/script/installbin.sh \$(INSTALLPERMS) \$(DESTDIR)\$(BASEDIR) \$(DESTDIR)\$(BINDIR) \$(DESTDIR)\$(LIBDIR) \$(DESTDIR)\$(VARDIR) \$(BIN_PROGS) - -installtorture: all installdirs - \@\$(SHELL) \$(srcdir)/script/installbin.sh \$(INSTALLPERMS) \$(DESTDIR)\$(BASEDIR) \$(DESTDIR)\$(BINDIR) \$(DESTDIR)\$(LIBDIR) \$(DESTDIR)\$(VARDIR) \$(TORTURE_PROGS) - -installldb: all installdirs - \@\$(SHELL) \$(srcdir)/script/installbin.sh \$(INSTALLPERMS) \$(DESTDIR)\$(BASEDIR) \$(DESTDIR)\$(BINDIR) \$(DESTDIR)\$(LIBDIR) \$(DESTDIR)\$(VARDIR) \$(LDB_PROGS) - -installreg: all installdirs - \@\$(SHELL) \$(srcdir)/script/installbin.sh \$(INSTALLPERMS) \$(DESTDIR)\$(BASEDIR) \$(DESTDIR)\$(BINDIR) \$(DESTDIR)\$(LIBDIR) \$(DESTDIR)\$(VARDIR) \$(REG_PROGS) - -installdat: installdirs - \@\$(SHELL) \$(srcdir)/script/installdat.sh \$(DESTDIR)\$(LIBDIR) \$(srcdir) - -uninstall: uninstallbin uninstalltorture uninstallldb uninstallreg - -uninstallbin: - \@\$(SHELL) \$(srcdir)/script/uninstallbin.sh \$(INSTALLPERMS) \$(DESTDIR)\$(BASEDIR) \$(DESTDIR)\$(SBINDIR) \$(DESTDIR)\$(LIBDIR) \$(DESTDIR)\$(VARDIR) \$(DESTDIR)\$(SBIN_PROGS) - -uninstalltorture: - \@\$(SHELL) \$(srcdir)/script/uninstallbin.sh \$(INSTALLPERMS) \$(DESTDIR)\$(BASEDIR) \$(DESTDIR)\$(BINDIR) \$(DESTDIR)\$(LIBDIR) \$(DESTDIR)\$(VARDIR) \$(DESTDIR)\$(TORTURE_PROGS) - -uninstallldb: - \@\$(SHELL) \$(srcdir)/script/uninstallbin.sh \$(INSTALLPERMS) \$(DESTDIR)\$(BASEDIR) \$(DESTDIR)\$(BINDIR) \$(DESTDIR)\$(LIBDIR) \$(DESTDIR)\$(VARDIR) \$(DESTDIR)\$(LDB_PROGS) - -uninstallreg: - \@\$(SHELL) \$(srcdir)/script/uninstallbin.sh \$(INSTALLPERMS) \$(DESTDIR)\$(BASEDIR) \$(DESTDIR)\$(BINDIR) \$(DESTDIR)\$(LIBDIR) \$(DESTDIR)\$(VARDIR) \$(DESTDIR)\$(REG_PROGS) - -# Swig extensions - -swig: scripting/swig/_tdb.so scripting/swig/_dcerpc.so - -PYTHON_TDB_OBJ = lib/tdb/common/tdb.o lib/tdb/common/spinlock.o - -scripting/swig/tdb.py: scripting/swig/tdb.i - swig -python scripting/swig/tdb.i - -scripting/swig/_tdb.so: scripting/swig/tdb.py scripting/swig/tdb_wrap.o \$(PYTHON_TDB_OBJ) - \$(SHLD) \$(SHLD_FLAGS) -o scripting/swig/_tdb.so scripting/swig/tdb_wrap.o \\ - \$(PYTHON_TDB_OBJ) - -PYTHON_DCERPC_OBJ = \$(SUBSYSTEM_LIBRPC_RAW_OBJS) \\ - \$(SUBSYSTEM_LIBDCOM_OBJS) \\ - \$(SUBSYSTEM_LIBNDR_RAW_OBJS) \\ - \$(SUBSYSTEM_LIBNDR_GEN_OBJS) \\ - \$(SUBSYSTEM_LIBBASIC_OBJS) \\ - \$(SUBSYSTEM_CONFIG_OBJS) \\ - \$(SUBSYSTEM_LIBTDB_OBJS) \\ - \$(SUBSYSTEM_SCHANNELDB_OBJS) \\ - \$(SUBSYSTEM_GENSEC_OBJS) \\ - \$(SUBSYSTEM_LIBCLI_UTILS_OBJS) \\ - \$(SUBSYSTEM_LIBCLI_RAW_OBJS) \\ - \$(SUBSYSTEM_LIBCLI_AUTH_OBJS) \\ - \$(SUBSYSTEM_LIBCLI_NMB_OBJS) \\ - \$(SUBSYSTEM_AUTH_OBJS) \\ - \$(SUBSYSTEM_SAMDB_OBJS) \\ - \$(SUBSYSTEM_LIBLDB_OBJS) \\ - \$(SUBSYSTEM_CHARSET_OBJS) \\ - \$(SUBSYSTEM_LIBSMB_OBJS) \\ - \$(SUBSYSTEM_DCERPC_COMMON_OBJS) \\ - \$(SUBSYSTEM_LIB_WINBIND_CLIENT_OBJS) \\ - \$(SUBSYSTEM_SOCKET_OBJS) \\ - \$(SUBSYSTEM_LIBREPLACE_OBJS) \\ - \$(SUBSYSTEM_LIBNETIF_OBJS) \\ - \$(SUBSYSTEM_LIBCRYPTO_OBJS) - -PYTHON_DCERPC_LIBS = -lldap - -SWIG_INCLUDES = librpc/gen_ndr/samr.i librpc/gen_ndr/lsa.i librpc/gen_ndr/winreg.i librpc/gen_ndr/spoolss.i - -scripting/swig/dcerpc.py: scripting/swig/dcerpc.i scripting/swig/samba.i scripting/swig/status_codes.i \$(SWIG_INCLUDES) - swig -python scripting/swig/dcerpc.i - -scripting/swig/_dcerpc.so: scripting/swig/dcerpc.py scripting/swig/dcerpc_wrap.o \$(PYTHON_DCERPC_OBJ) - \$(SHLD) \$(SHLD_FLAGS) -o scripting/swig/_dcerpc.so scripting/swig/dcerpc_wrap.o \$(PYTHON_DCERPC_OBJ) \$(PYTHON_DCERPC_LIBS) - -swig_clean: - -rm -f scripting/swig/_tdb.so scripting/swig/tdb.pyc \\ - scripting/swig/tdb.py scripting/swig/tdb_wrap.c \\ - scripting/swig/tdb_wrap.o - -everything: all - -etags: - etags `find \$(srcdir) -name \"*.[ch]\"` - -ctags: - ctags `find \$(srcdir) -name \"*.[ch]\"` - -"; - - return $output; -} - -sub _prepare_rule_lists($) -{ - my $CTX = shift; - my $output = ""; - - foreach my $key (sort keys %{$CTX->{OUTPUT}{SHARED_MODULES}}) { - $output .= _prepare_shared_module_rule(\%{$CTX->{OUTPUT}{SHARED_MODULES}{$key}}); - } - - foreach my $key (sort keys %{$CTX->{OUTPUT}{LIBRARIES}}) { - $output .= _prepare_library_rule(\%{$CTX->{OUTPUT}{LIBRARIES}{$key}}); - } - - foreach my $key (sort keys %{$CTX->{OUTPUT}{BINARIES}}) { - $output .= _prepare_binary_rule(\%{$CTX->{OUTPUT}{BINARIES}{$key}}); - } - - my $idl_ctx; - $output .= _prepare_IDL($idl_ctx); - - $output .= _prepare_proto_rules(); - - $output .= _prepare_install_rules($CTX); - - return $output; -} - -########################################################### -# This function prepares the output for Makefile -# -# $output = _prepare_makefile_in($SMB_BUILD_CTX) -# -# $SMB_BUILD_CTX - the global SMB_BUILD context -# -# $output - the resulting output buffer -sub _prepare_makefile_in($) -{ - my $CTX = shift; - my $output; - - $output = "########################################\n"; - $output .= "# Autogenerated by config.smb_build.pl #\n"; - $output .= "########################################\n"; - - my $cmd_ctx; - $output .= _prepare_command_interpreters($cmd_ctx); - - my $path_ctx; - $output .= _prepare_path_vars($path_ctx); - - my $compiler_ctx; - $output .= _prepare_compiler_linker($compiler_ctx); - - my $rules_ctx; - $output .= _prepare_default_rule($rules_ctx); - - my $suffix_ctx; - $output .= _prepare_SUFFIXES($suffix_ctx); - - $output .= _prepare_dummy_MAKEDIR(); - - $output .= _prepare_std_CC_rule("c","o","\@PICFLAG\@","Compiling","Rule for std objectfiles"); - $output .= _prepare_std_CC_rule("h","h.gch","\@PICFLAG\@","Precompiling","Rule for precompiled headerfiles"); - - $output .= _prepare_obj_lists($CTX); - - $output .= _prepare_rule_lists($CTX); - - $output .= _prepare_make_target(\%{$CTX->{OUTPUT}{TARGETS}{ALL}}); - - return $output; -} - -########################################################### -# This function creates Makefile.in from the SMB_BUILD -# context -# -# create_makefile_in($SMB_BUILD_CTX) -# -# $SMB_BUILD_CTX - the global SMB_BUILD context -# -# $output - the resulting output buffer -sub create_makefile_in($) -{ - my $CTX = shift; - my $output; - - $output = _prepare_makefile_in($CTX); - - open(MAKEFILE_IN,"> Makefile.in") || die ("Can't open Makefile.in\n"); - - print MAKEFILE_IN $output; - - close(MAKEFILE_IN); - - print "config.smb_build.pl: creating Makefile.in\n"; - return; -} diff --git a/source4/build/smb_build/makefile.pm b/source4/build/smb_build/makefile.pm new file mode 100644 index 0000000000..0e0da317f5 --- /dev/null +++ b/source4/build/smb_build/makefile.pm @@ -0,0 +1,917 @@ +########################################################### +### SMB Build System ### +### - create output for Makefile ### +### ### +### Copyright (C) Stefan (metze) Metzmacher 2004 ### +### Released under the GNU GPL ### +########################################################### + +sub _prepare_command_interpreters($) +{ + my $ctx = shift; + my $output; + + $output = " +SHELL=/bin/sh +PERL=\@PERL\@ +"; + return $output; +} + +sub _prepare_path_vars($) +{ + my $ctx = shift; + my $output; + + $output = " +prefix=\@prefix\@ +exec_prefix=\@exec_prefix\@ +VPATH=\@srcdir\@ +srcdir=\@srcdir\@ +builddir=\@builddir\@ +eparserdir=\@eparserdir\@ + +BASEDIR= \@prefix\@ +BINDIR = \@bindir\@ +SBINDIR = \@sbindir\@ +LIBDIR = \@libdir\@ +CONFIGDIR = \@configdir\@ +VARDIR = \@localstatedir\@ + + +# The permissions to give the executables +INSTALLPERMS = 0755 + +# set these to where to find various files +# These can be overridden by command line switches (see smbd(8)) +# or in smb.conf (see smb.conf(5)) +LOGFILEBASE = \@logfilebase\@ +CONFIGFILE = \$(CONFIGDIR)/smb.conf +LMHOSTSFILE = \$(CONFIGDIR)/lmhosts +NCALRPCDIR = \@localstatedir\@/ncalrpc + +# This is where smbpasswd et al go +PRIVATEDIR = \@privatedir\@ +SMB_PASSWD_FILE = \$(PRIVATEDIR)/smbpasswd + +# the directory where lock files go +LOCKDIR = \@lockdir\@ + +# the directory where pid files go +PIDDIR = \@piddir\@ + +PASSWD_FLAGS = -DSMB_PASSWD_FILE=\\\"\$(SMB_PASSWD_FILE)\\\" -DPRIVATE_DIR=\\\"\$(PRIVATEDIR)\\\" +PATH_FLAGS1 = -DCONFIGFILE=\\\"\$(CONFIGFILE)\\\" -DSBINDIR=\\\"\$(SBINDIR)\\\" +PATH_FLAGS2 = \$(PATH_FLAGS1) -DBINDIR=\\\"\$(BINDIR)\\\" +PATH_FLAGS3 = \$(PATH_FLAGS2) -DLMHOSTSFILE=\\\"\$(LMHOSTSFILE)\\\" +PATH_FLAGS4 = \$(PATH_FLAGS3) -DLOCKDIR=\\\"\$(LOCKDIR)\\\" -DPIDDIR=\\\"\$(PIDDIR)\\\" +PATH_FLAGS5 = \$(PATH_FLAGS4) -DLIBDIR=\\\"\$(LIBDIR)\\\" \\ + -DLOGFILEBASE=\\\"\$(LOGFILEBASE)\\\" -DSHLIBEXT=\\\"\@SHLIBEXT\@\\\" +PATH_FLAGS6 = \$(PATH_FLAGS5) -DCONFIGDIR=\\\"\$(CONFIGDIR)\\\" -DNCALRPCDIR=\\\"\$(NCALRPCDIR)\\\" +PATH_FLAGS = \$(PATH_FLAGS6) \$(PASSWD_FLAGS) +"; + return $output; +} + +sub _prepare_compiler_linker($) +{ + my $ctx = shift; + my $output; + + $output = " +CC=\@CC\@ +CC_FLAGS=-Iinclude -I. -I\$(srcdir)/include -I\$(srcdir) -Ilib \@CFLAGS\@ \@CPPFLAGS\@ + +LD=\@CC\@ +LD_FLAGS=\@LDFLAGS\@ \@CFLAGS\@ + +STLD=ar +STLD_FLAGS=-rc + +SHLD=\@CC\@ +SHLD_FLAGS=\@LDSHFLAGS\@ \@LDFLAGS\@ +"; + return $output; +} + +sub _prepare_default_rule($) +{ + my $ctx = shift; + my $output; + + $output = " +default: all +"; + return $output; +} + +sub _prepare_SUFFIXES($) +{ + my $ctx = shift; + my $output; + + $output = " +.SUFFIXES: +.SUFFIXES: .c .o .h .h.gch .a .so +"; + return $output; +} + +sub _prepare_IDL($) +{ + my $ctx = shift; + my $output; + + $output = " +idl_full: build/pidl/idl.pm + CPP=\"\@CPP\@\" PERL=\"\$(PERL)\" script/build_idl.sh FULL + +idl: build/pidl/idl.pm + \@CPP=\"\@CPP\@\" script/build_idl.sh PARTIAL + +eparser_idl: build/pidl/idl.pm + CPP=\"\@CPP\@\" PERL=\"\$(PERL)\" EPARSERPREFIX=\"\$(eparserdir)\" script/build_idl.sh EPARSER + +build/pidl/idl.pm: build/pidl/idl.yp + -yapp -s build/pidl/idl.yp + +pch: proto include/includes.h.gch + +pch_clean: + -rm -f include/includes.h.gch + +basics: idl proto_exists + +"; + return $output; +} + +sub _prepare_dummy_MAKEDIR() +{ + my $ctx = shift; + my $output; + + $output = " +bin/.dummy: + \@: >> \$\@ || : > \$\@ + +dynconfig.o: dynconfig.c Makefile + \@echo Compiling \$*.c + \@\$(CC) \$(CC_FLAGS) \@PICFLAG\@ \$(PATH_FLAGS) -c \$< -o \$\@ +\@BROKEN_CC\@ -mv `echo \$\@ | sed 's%^.*/%%g'` \$\@ + +"; + return $output; +} + +########################################################### +# This function creates a standard make rule which is using $(CC) +# +# $output = _prepare_std_CC_rule($srcext,$destext,$flags,$message,$comment) +# +# $srcext - sourcefile extension +# +# $destext - destinationfile extension +# +# $flags - additional compiler flags +# +# $message - logmessage which is echoed while running this rule +# +# $comment - just a comment what this rule should do +# +# $output - the resulting output buffer +sub _prepare_std_CC_rule($$$$$) +{ + my $src = shift; + my $dst = shift; + my $flags = shift; + my $message = shift; + my $comment = shift; + my $flagsstr = ""; + my $output; + + $output = " +################################### +# Start $comment +.$src.$dst: + \@echo $message \$*.$src + \@\$(CC) \$(CC_FLAGS) $flags -c \$< -o \$\@ +\@BROKEN_CC\@ -mv `echo \$\@ | sed 's%^.*/%%g'` \$\@ +#End $comment +################################### +"; + + return $output; +} + +sub array2oneperline($) +{ + my $array = shift; + my $i; + my $output = ""; + + foreach my $str (@{$array}) { + if (!defined($str)) { + next; + } + + $output .= " \\\n\t\t"; + $output .= $str; + } + + return $output; +} + +sub array2oneline($) +{ + my $array = shift; + my $i; + my $output = ""; + + foreach my $str (@{$array}) { + if (!defined($str)) { + next; + } + + $output .= $str; + $output .= " "; + } + + return $output; +} + +########################################################### +# This function creates a object file list +# +# $output = _prepare_var_obj_list($var, $var_ctx) +# +# $var_ctx - the subsystem context +# +# $var_ctx->{NAME} - the name +# $var_ctx->{OBJ_LIST} - the list of objectfiles which sould be linked to this +# +# $output - the resulting output buffer +sub _prepare_var_obj_list($$) +{ + my $var = shift; + my $ctx = shift; + my $tmpobjlist; + my $output; + + $tmpobjlist = array2oneperline($ctx->{OBJ_LIST}); + + $output = " +################################### +# Start $var $ctx->{NAME} OBJ LIST +$var\_$ctx->{NAME}_OBJS =$tmpobjlist +# End $var $ctx->{NAME} OBJ LIST +################################### +"; + + return $output; +} + +########################################################### +# This function creates a object file list for a subsystem +# +# $output = _prepare_subsystem_obj_list($subsystem_ctx) +# +# $subsystem_ctx - the subsystem context +# +# $subsystem_ctx->{NAME} - the subsystem name +# $subsystem_ctx->{OBJ_LIST} - the list of objectfiles which sould be linked to this subsystem +# +# $output - the resulting output buffer +sub _prepare_subsystem_obj_list($) +{ + my $ctx = shift; + + return _prepare_var_obj_list("SUBSYSTEM",$ctx); +} + +########################################################### +# This function creates a object file list for a module +# +# $output = _prepare_module_obj_and_lib_list($module_ctx) +# +# $module_ctx - the module context +# +# $module_ctx->{NAME} - the module binary name +# $module_ctx->{OBJ_LIST} - the list of objectfiles which sould be linked to this module +# +# $output - the resulting output buffer +sub _prepare_module_obj_list($) +{ + my $ctx = shift; + + return _prepare_var_obj_list("MODULE",$ctx); + +} + +########################################################### +# This function creates a make rule for linking a shared module +# +# $output = _prepare_shared_module_rule($module_ctx) +# +# $module_ctx - the module context +# +# $module_ctx->{MODULE} - the module binary name +# $module_ctx->{DEPEND_LIST} - the list of rules on which this module depends +# $module_ctx->{LINK_LIST} - the list of objectfiles and external libraries +# which sould be linked to this module +# $module_ctx->{LINK_FLAGS} - linker flags used by this module +# +# $output - the resulting output buffer +sub _prepare_shared_module_rule($) +{ + my $ctx = shift; + my $tmpdepend; + my $tmplink; + my $tmpflag; + my $output; + + $tmpdepend = array2oneperline($ctx->{DEPEND_LIST}); + $tmplink = array2oneperline($ctx->{LINK_LIST}); + $tmpflag = array2oneperline($ctx->{LINK_FLAGS}); + + $output = " +################################### +# Start Module $ctx->{MODULE} +MODULE_$ctx->{NAME}_DEPEND_LIST =$tmpdepend +MODULE_$ctx->{NAME}_LINK_LIST =$tmplink +MODULE_$ctx->{NAME}_LINK_FLAGS =$tmpflag +# +bin/$ctx->{MODULE}: \$(MODULE_$ctx->{NAME}_DEPEND_LIST) bin/.dummy + \@echo Linking \$\@ + \@\$(SHLD) \$(SHLD_FLAGS) -o \$\@ \\ + \$(MODULE_$ctx->{NAME}_LINK_FLAGS) \\ + \$(MODULE_$ctx->{NAME}_LINK_LIST) +module_$ctx->{MODULE}: basics bin/$ctx->{MODULE} +# Module $ctx->{MODULE} +################################### +"; + + return $output; +} + +########################################################### +# This function creates a object file list for a library +# +# $output = _prepare_library_obj_and_lib_list($library_ctx) +# +# $library_ctx - the library context +# +# $library_ctx->{NAME} - the library binary name +# $library_ctx->{OBJ_LIST} - the list of objectfiles which sould be linked to this library +# +# $output - the resulting output buffer +sub _prepare_library_obj_list($) +{ + my $ctx = shift; + + return _prepare_var_obj_list("LIBRARY",$ctx); + +} + +########################################################### +# This function creates a make rule for linking a library +# +# $output = _prepare_library_rule($library_ctx) +# +# $library_ctx - the library context +# +# $library_ctx->{NAME} - the library name +# +# $library_ctx->{DEPEND_LIST} - the list of rules on which this library depends +# +# $library_ctx->{STATIC_LIBRARY_NAME} - the static library name +# $library_ctx->{STATIC_LINK_LIST} - the list of objectfiles which sould be linked +# to this static library +# $library_ctx->{STATIC_LINK_FLAGS} - linker flags used by this static library +# +# $library_ctx->{SHARED_LIBRARY_NAME} - the shared library name +# $library_ctx->{SHARED_LIBRARY_REALNAME} - the shared library real name +# $library_ctx->{SHARED_LIBRARY_SONAME} - the shared library soname +# $library_ctx->{SHARED_LINK_LIST} - the list of objectfiles and external libraries +# which sould be linked to this shared library +# $library_ctx->{SHARED_LINK_FLAGS} - linker flags used by this shared library +# +# $output - the resulting output buffer +sub _prepare_library_rule($) +{ + my $ctx = shift; + my $tmpdepend; + my $tmpstlink; + my $tmpstflag; + my $tmpshlink; + my $tmpshflag; + my $tmprules; + my $output; + + $tmpdepend = array2oneperline($ctx->{DEPEND_LIST}); + + $tmpstlink = array2oneperline($ctx->{STATIC_LINK_LIST}); + $tmpstflag = array2oneperline($ctx->{STATIC_LINK_FLAGS}); + + $tmpshlink = array2oneperline($ctx->{SHARED_LINK_LIST}); + $tmpshflag = array2oneperline($ctx->{SHARED_LINK_FLAGS}); + + $tmprules = "bin/$ctx->{STATIC_LIBRARY_NAME}"; + + $output = " +################################### +# Start Library $ctx->{NAME} +# +LIBRARY_$ctx->{NAME}_DEPEND_LIST =$tmpdepend +# +LIBRARY_$ctx->{NAME}_STATIC_LINK_LIST =$tmpstlink +LIBRARY_$ctx->{NAME}_STATIC_LINK_FLAGS =$tmpstflag +# +LIBRARY_$ctx->{NAME}_SHARED_LINK_LIST =$tmpshlink +LIBRARY_$ctx->{NAME}_SHARED_LINK_FLAGS =$tmpshflag +# +# Static $ctx->{STATIC_LIBRARY_NAME} +bin/$ctx->{STATIC_LIBRARY_NAME}: \$(LIBRARY_$ctx->{NAME}_DEPEND_LIST) bin/.dummy + \@echo Linking \$\@ + \@\$(STLD) \$(STLD_FLAGS) \$\@ \\ + \$(LIBRARY_$ctx->{NAME}_STATIC_LINK_FLAGS) \\ + \$(LIBRARY_$ctx->{NAME}_STATIC_LINK_LIST) +"; + + if (defined($ctx->{SHARED_LIBRARY_NAME})) { + $output .= " +# Shared $ctx->{SHARED_LIBRARY_REALNAME} +bin/$ctx->{SHARED_LIBRARY_REALNAME}: \$(LIBRARY_$ctx->{NAME}_DEPEND_LIST) bin/.dummy + \@echo Linking \$\@ + \@\$(SHLD) \$(SHLD_FLAGS) -o \$\@ \\ + \$(LIBRARY_$ctx->{NAME}_SHARED_LINK_FLAGS) \\ + \$(LIBRARY_$ctx->{NAME}_SHARED_LINK_LIST) +# Symlink $ctx->{SHARED_LIBRARY_SONAME} +bin/$ctx->{SHARED_LIBRARY_SONAME}: bin/$ctx->{SHARED_LIBRARY_REALNAME} bin/.dummy + \@echo Symlink \$\@ + \@ln -sf $ctx->{SHARED_LIBRARY_REALNAME} \$\@ +# Symlink $ctx->{SHARED_LIBRARY_NAME} +bin/$ctx->{SHARED_LIBRARY_NAME}: bin/$ctx->{SHARED_LIBRARY_SONAME} bin/.dummy + \@echo Symlink \$\@ + \@ln -sf $ctx->{SHARED_LIBRARY_SONAME} \$\@ +"; + $tmprules .= " bin/$ctx->{SHARED_LIBRARY_NAME}" + } + + $output .= " +library_$ctx->{NAME}: basics $tmprules +# End Library $ctx->{NAME} +################################### +"; + + return $output; +} + +########################################################### +# This function creates a object file list for a binary +# +# $output = _prepare_binary_obj_and_lib_list($binary_ctx) +# +# $binary_ctx - the binary context +# +# $binary_ctx->{NAME} - the binary name +# $binary_ctx->{OBJ_LIST} - the list of objectfiles which sould be linked to this binary +# +# $output - the resulting output buffer +sub _prepare_binary_obj_list($) +{ + my $ctx = shift; + + return _prepare_var_obj_list("BINARY",$ctx); + +} + +########################################################### +# This function creates a make rule for linking a binary +# +# $output = _prepare_binary_rule($binary_ctx) +# +# $binary_ctx - the binary context +# +# $binary_ctx->{NAME} - the binary name +# $binary_ctx->{BINARY} - the binary binary name +# +# $binary_ctx->{DEPEND_LIST} - the list of rules on which this binary depends +# $binary_ctx->{LINK_LIST} - the list of objectfiles and external libraries +# which sould be linked to this binary +# $binary_ctx->{LINK_FLAGS} - linker flags used by this binary +# +# $output - the resulting output buffer +sub _prepare_binary_rule($) +{ + my $ctx = shift; + my $tmpdepend; + my $tmplink; + my $tmpflag; + my $output; + + $tmpdepend = array2oneperline($ctx->{DEPEND_LIST}); + $tmplink = array2oneperline($ctx->{LINK_LIST}); + $tmpflag = array2oneperline($ctx->{LINK_FLAGS}); + + $output = " +################################### +# Start Binary $ctx->{BINARY} +# +BINARY_$ctx->{NAME}_DEPEND_LIST =$tmpdepend +BINARY_$ctx->{NAME}_LINK_LIST =$tmplink +BINARY_$ctx->{NAME}_LINK_FLAGS =$tmpflag +# +bin/$ctx->{BINARY}: bin/.dummy \$(BINARY_$ctx->{NAME}_DEPEND_LIST) + \@echo Linking \$\@ + \@\$(LD) \$(LD_FLAGS) -o \$\@ \\ + \$(BINARY_$ctx->{NAME}_LINK_FLAGS) \\ + \$(BINARY_$ctx->{NAME}_LINK_LIST) +binary_$ctx->{BINARY}: basics bin/$ctx->{BINARY} +# End Binary $ctx->{BINARY} +################################### +"; + + return $output; +} + +########################################################### +# This function creates a object file list for make proto +# +# $output = _prepare_proto_obj_list($proto_ctx) +# +# $proto_ctx - the proto context + +# $proto_ctx->{OBJ_LIST} - the list of objectfiles which sould be scanned by make proto +# +# $output - the resulting output buffer +sub _prepare_proto_obj_list($) +{ + my $ctx = shift; + my $tmplist; + my $output; + + $tmplist = array2oneperline($ctx->{OBJ_LIST}); + + $output = " +################################### +# Start PROTO OBJ LIST +PROTO_OBJS =$tmplist +# End PROTO OBJ LIST +################################### +"; + + return $output; +} + +sub _prepare_proto_rules() +{ + my $output = ""; + + $output .= " +# Making this target will just make sure that the prototype files +# exist, not necessarily that they are up to date. Since they're +# removed by 'make clean' this will always be run when you do anything +# afterwards. +proto_exists: include/proto.h include/build_env.h + +delheaders: pch_clean + -rm -f \$(builddir)/include/proto.h \$(builddir)/include/build_env.h: + +include/proto.h: + \@cd \$(srcdir) && \$(SHELL) script/mkproto.sh \"\$(PERL)\" \\ + -h _PROTO_H_ \$(builddir)/include/proto.h \\ + \$(PROTO_OBJS) + +include/build_env.h: + \@echo Building include/build_env.h + \@cd \$(srcdir) && \$(SHELL) script/build_env.sh \$(srcdir) \$(builddir) \$(CC) > \$(builddir)/include/build_env.h + +# 'make headers' or 'make proto' calls a subshell because we need to +# make sure these commands are executed in sequence even for a +# parallel make. +headers: delheaders proto_exists + +proto: idl headers + +proto_test: + \@[ -f \$(builddir)/include/proto.h ] || \$(MAKE) proto + +clean: delheaders + -rm -f *.o */*.o */*/*.o */*/*/*.o bin/* + -rm -rf librpc/gen_* + +distclean: clean + -rm -f bin/.dummy + -rm -f include/config.h + -rm -f Makefile* + -rm -f config.status + -rm -f config.smb_build.* + -rm -f config.log config.cache + +removebackup: + -rm -f *.bak *~ */*.bak */*~ */*/*.bak */*/*~ */*/*/*.bak */*/*/*~ + +realdistclean: distclean removebackup + -rm -f include/config.h.in + -rm -f lib/version.h + -rm -f configure +"; + + return $output; +} + +sub _prepare_make_target($) +{ + my $ctx = shift; + my $tmpdepend; + my $output; + + $tmpdepend = array2oneperline($ctx->{DEPEND_LIST}); + + $output = " +################################### +# Start Target $ctx->{TARGET} +$ctx->{TARGET}: basics $tmpdepend +# End Target $ctx->{TARGET} +################################### +"; + + return $output; +} + +sub _prepare_obj_lists($) +{ + my $CTX = shift; + my $output = ""; + + foreach my $key (sort keys %{$CTX->{OUTPUT}{SUBSYSTEMS}}) { + $output .= _prepare_subsystem_obj_list(\%{$CTX->{OUTPUT}{SUBSYSTEMS}{$key}}); + } + + foreach my $key (sort keys %{$CTX->{OUTPUT}{SHARED_MODULES}}) { + $output .= _prepare_module_obj_list(\%{$CTX->{OUTPUT}{SHARED_MODULES}{$key}}); + } + + foreach my $key (sort keys %{$CTX->{OUTPUT}{LIBRARIES}}) { + $output .= _prepare_library_obj_list(\%{$CTX->{OUTPUT}{LIBRARIES}{$key}}); + } + + foreach my $key (sort keys %{$CTX->{OUTPUT}{BINARIES}}) { + $output .= _prepare_binary_obj_list(\%{$CTX->{OUTPUT}{BINARIES}{$key}}); + } + + $output .= _prepare_proto_obj_list(\%{$CTX->{OUTPUT}{PROTO}}); + + return $output; +} + +sub _prepare_install_rules($) +{ + my $CTX = shift; + my $output = ""; + + $output .= " + +showlayout: + \@echo \"Samba will be installed into:\" + \@echo \" basedir: \$(BASEDIR)\" + \@echo \" bindir: \$(BINDIR)\" + \@echo \" sbindir: \$(SBINDIR)\" + \@echo \" libdir: \$(LIBDIR)\" + \@echo \" vardir: \$(VARDIR)\" + \@echo \" privatedir: \$(PRIVATEDIR)\" + \@echo \" piddir: \$(PIDDIR)\" + \@echo \" lockdir: \$(LOCKDIR)\" + +SBIN_PROGS = bin/smbd + +BIN_PROGS = bin/smbclient + +TORTURE_PROGS = bin/smbtorture \\ + bin/gentest \\ + bin/locktest \\ + bin/masktest \\ + bin/ndrdump + +LDB_PROGS = bin/ldbadd \\ + bin/ldbdel \\ + bin/ldbmodify \\ + bin/ldbedit \\ + bin/ldbsearch + +REG_PROGS = bin/regpatch \\ + bin/regshell \\ + bin/regtree \\ + bin/regpatch \\ + bin/regdiff + +install: showlayout installbin installtorture installldb installreg installdat + +# DESTDIR is used here to prevent packagers wasting their time +# duplicating the Makefile. Remove it and you will have the privelege +# of package each samba release for muliple versions of multiple +# distributions and operating systems, or at least supplying patches +# to all the packaging files required for this, prior to committing +# the removal of DESTDIR. Do not remove it even though you think it +# is not used + +installdirs: + \@\$(SHELL) \$(srcdir)/script/installdirs.sh \$(DESTDIR)\$(BASEDIR) \$(DESTDIR)\$(BINDIR) \$(DESTDIR)\$(SBINDIR) \$(DESTDIR)\$(LIBDIR) \$(DESTDIR)\$(VARDIR) \$(DESTDIR)\$(PRIVATEDIR) \$(DESTDIR)\$(PIDDIR) \$(DESTDIR)\$(LOCKDIR) + +installbin: all installdirs + \@\$(SHELL) \$(srcdir)/script/installbin.sh \$(INSTALLPERMS) \$(DESTDIR)\$(BASEDIR) \$(DESTDIR)\$(SBINDIR) \$(DESTDIR)\$(LIBDIR) \$(DESTDIR)\$(VARDIR) \$(SBIN_PROGS) + \@\$(SHELL) \$(srcdir)/script/installbin.sh \$(INSTALLPERMS) \$(DESTDIR)\$(BASEDIR) \$(DESTDIR)\$(BINDIR) \$(DESTDIR)\$(LIBDIR) \$(DESTDIR)\$(VARDIR) \$(BIN_PROGS) + +installtorture: all installdirs + \@\$(SHELL) \$(srcdir)/script/installbin.sh \$(INSTALLPERMS) \$(DESTDIR)\$(BASEDIR) \$(DESTDIR)\$(BINDIR) \$(DESTDIR)\$(LIBDIR) \$(DESTDIR)\$(VARDIR) \$(TORTURE_PROGS) + +installldb: all installdirs + \@\$(SHELL) \$(srcdir)/script/installbin.sh \$(INSTALLPERMS) \$(DESTDIR)\$(BASEDIR) \$(DESTDIR)\$(BINDIR) \$(DESTDIR)\$(LIBDIR) \$(DESTDIR)\$(VARDIR) \$(LDB_PROGS) + +installreg: all installdirs + \@\$(SHELL) \$(srcdir)/script/installbin.sh \$(INSTALLPERMS) \$(DESTDIR)\$(BASEDIR) \$(DESTDIR)\$(BINDIR) \$(DESTDIR)\$(LIBDIR) \$(DESTDIR)\$(VARDIR) \$(REG_PROGS) + +installdat: installdirs + \@\$(SHELL) \$(srcdir)/script/installdat.sh \$(DESTDIR)\$(LIBDIR) \$(srcdir) + +uninstall: uninstallbin uninstalltorture uninstallldb uninstallreg + +uninstallbin: + \@\$(SHELL) \$(srcdir)/script/uninstallbin.sh \$(INSTALLPERMS) \$(DESTDIR)\$(BASEDIR) \$(DESTDIR)\$(SBINDIR) \$(DESTDIR)\$(LIBDIR) \$(DESTDIR)\$(VARDIR) \$(DESTDIR)\$(SBIN_PROGS) + +uninstalltorture: + \@\$(SHELL) \$(srcdir)/script/uninstallbin.sh \$(INSTALLPERMS) \$(DESTDIR)\$(BASEDIR) \$(DESTDIR)\$(BINDIR) \$(DESTDIR)\$(LIBDIR) \$(DESTDIR)\$(VARDIR) \$(DESTDIR)\$(TORTURE_PROGS) + +uninstallldb: + \@\$(SHELL) \$(srcdir)/script/uninstallbin.sh \$(INSTALLPERMS) \$(DESTDIR)\$(BASEDIR) \$(DESTDIR)\$(BINDIR) \$(DESTDIR)\$(LIBDIR) \$(DESTDIR)\$(VARDIR) \$(DESTDIR)\$(LDB_PROGS) + +uninstallreg: + \@\$(SHELL) \$(srcdir)/script/uninstallbin.sh \$(INSTALLPERMS) \$(DESTDIR)\$(BASEDIR) \$(DESTDIR)\$(BINDIR) \$(DESTDIR)\$(LIBDIR) \$(DESTDIR)\$(VARDIR) \$(DESTDIR)\$(REG_PROGS) + +# Swig extensions + +swig: scripting/swig/_tdb.so scripting/swig/_dcerpc.so + +PYTHON_TDB_OBJ = lib/tdb/common/tdb.o lib/tdb/common/spinlock.o + +scripting/swig/tdb.py: scripting/swig/tdb.i + swig -python scripting/swig/tdb.i + +scripting/swig/_tdb.so: scripting/swig/tdb.py scripting/swig/tdb_wrap.o \$(PYTHON_TDB_OBJ) + \$(SHLD) \$(SHLD_FLAGS) -o scripting/swig/_tdb.so scripting/swig/tdb_wrap.o \\ + \$(PYTHON_TDB_OBJ) + +PYTHON_DCERPC_OBJ = \$(SUBSYSTEM_LIBRPC_RAW_OBJS) \\ + \$(SUBSYSTEM_LIBDCOM_OBJS) \\ + \$(SUBSYSTEM_LIBNDR_RAW_OBJS) \\ + \$(SUBSYSTEM_LIBNDR_GEN_OBJS) \\ + \$(SUBSYSTEM_LIBBASIC_OBJS) \\ + \$(SUBSYSTEM_CONFIG_OBJS) \\ + \$(SUBSYSTEM_LIBTDB_OBJS) \\ + \$(SUBSYSTEM_SCHANNELDB_OBJS) \\ + \$(SUBSYSTEM_GENSEC_OBJS) \\ + \$(SUBSYSTEM_LIBCLI_UTILS_OBJS) \\ + \$(SUBSYSTEM_LIBCLI_RAW_OBJS) \\ + \$(SUBSYSTEM_LIBCLI_AUTH_OBJS) \\ + \$(SUBSYSTEM_LIBCLI_NMB_OBJS) \\ + \$(SUBSYSTEM_AUTH_OBJS) \\ + \$(SUBSYSTEM_SAMDB_OBJS) \\ + \$(SUBSYSTEM_LIBLDB_OBJS) \\ + \$(SUBSYSTEM_CHARSET_OBJS) \\ + \$(SUBSYSTEM_LIBSMB_OBJS) \\ + \$(SUBSYSTEM_DCERPC_COMMON_OBJS) \\ + \$(SUBSYSTEM_LIB_WINBIND_CLIENT_OBJS) \\ + \$(SUBSYSTEM_SOCKET_OBJS) \\ + \$(SUBSYSTEM_LIBREPLACE_OBJS) \\ + \$(SUBSYSTEM_LIBNETIF_OBJS) \\ + \$(SUBSYSTEM_LIBCRYPTO_OBJS) + +PYTHON_DCERPC_LIBS = -lldap + +SWIG_INCLUDES = librpc/gen_ndr/samr.i librpc/gen_ndr/lsa.i librpc/gen_ndr/winreg.i librpc/gen_ndr/spoolss.i + +scripting/swig/dcerpc.py: scripting/swig/dcerpc.i scripting/swig/samba.i scripting/swig/status_codes.i \$(SWIG_INCLUDES) + swig -python scripting/swig/dcerpc.i + +scripting/swig/_dcerpc.so: scripting/swig/dcerpc.py scripting/swig/dcerpc_wrap.o \$(PYTHON_DCERPC_OBJ) + \$(SHLD) \$(SHLD_FLAGS) -o scripting/swig/_dcerpc.so scripting/swig/dcerpc_wrap.o \$(PYTHON_DCERPC_OBJ) \$(PYTHON_DCERPC_LIBS) + +swig_clean: + -rm -f scripting/swig/_tdb.so scripting/swig/tdb.pyc \\ + scripting/swig/tdb.py scripting/swig/tdb_wrap.c \\ + scripting/swig/tdb_wrap.o + +everything: all + +etags: + etags `find \$(srcdir) -name \"*.[ch]\"` + +ctags: + ctags `find \$(srcdir) -name \"*.[ch]\"` + +"; + + return $output; +} + +sub _prepare_rule_lists($) +{ + my $CTX = shift; + my $output = ""; + + foreach my $key (sort keys %{$CTX->{OUTPUT}{SHARED_MODULES}}) { + $output .= _prepare_shared_module_rule(\%{$CTX->{OUTPUT}{SHARED_MODULES}{$key}}); + } + + foreach my $key (sort keys %{$CTX->{OUTPUT}{LIBRARIES}}) { + $output .= _prepare_library_rule(\%{$CTX->{OUTPUT}{LIBRARIES}{$key}}); + } + + foreach my $key (sort keys %{$CTX->{OUTPUT}{BINARIES}}) { + $output .= _prepare_binary_rule(\%{$CTX->{OUTPUT}{BINARIES}{$key}}); + } + + my $idl_ctx; + $output .= _prepare_IDL($idl_ctx); + + $output .= _prepare_proto_rules(); + + $output .= _prepare_install_rules($CTX); + + return $output; +} + +########################################################### +# This function prepares the output for Makefile +# +# $output = _prepare_makefile_in($SMB_BUILD_CTX) +# +# $SMB_BUILD_CTX - the global SMB_BUILD context +# +# $output - the resulting output buffer +sub _prepare_makefile_in($) +{ + my $CTX = shift; + my $output; + + $output = "########################################\n"; + $output .= "# Autogenerated by config.smb_build.pl #\n"; + $output .= "########################################\n"; + + my $cmd_ctx; + $output .= _prepare_command_interpreters($cmd_ctx); + + my $path_ctx; + $output .= _prepare_path_vars($path_ctx); + + my $compiler_ctx; + $output .= _prepare_compiler_linker($compiler_ctx); + + my $rules_ctx; + $output .= _prepare_default_rule($rules_ctx); + + my $suffix_ctx; + $output .= _prepare_SUFFIXES($suffix_ctx); + + $output .= _prepare_dummy_MAKEDIR(); + + $output .= _prepare_std_CC_rule("c","o","\@PICFLAG\@","Compiling","Rule for std objectfiles"); + $output .= _prepare_std_CC_rule("h","h.gch","\@PICFLAG\@","Precompiling","Rule for precompiled headerfiles"); + + $output .= _prepare_obj_lists($CTX); + + $output .= _prepare_rule_lists($CTX); + + $output .= _prepare_make_target(\%{$CTX->{OUTPUT}{TARGETS}{ALL}}); + + return $output; +} + +########################################################### +# This function creates Makefile.in from the SMB_BUILD +# context +# +# create_makefile_in($SMB_BUILD_CTX) +# +# $SMB_BUILD_CTX - the global SMB_BUILD context +# +# $output - the resulting output buffer +sub create_makefile_in($) +{ + my $CTX = shift; + my $output; + + $output = _prepare_makefile_in($CTX); + + open(MAKEFILE_IN,"> Makefile.in") || die ("Can't open Makefile.in\n"); + + print MAKEFILE_IN $output; + + close(MAKEFILE_IN); + + print "config.smb_build.pl: creating Makefile.in\n"; + return; +} + +1; diff --git a/source4/build/smb_build/output.pl b/source4/build/smb_build/output.pl deleted file mode 100644 index 800f743efe..0000000000 --- a/source4/build/smb_build/output.pl +++ /dev/null @@ -1,262 +0,0 @@ -########################################################### -### SMB Build System ### -### - the output generating functions ### -### ### -### Copyright (C) Stefan (metze) Metzmacher 2004 ### -### Released under the GNU GPL ### -########################################################### - -sub _generate_ext_libs($) -{ - my $CTX = shift; - - # - # loop over all binaries - # - foreach my $key (sort keys %{$CTX->{DEPEND}{EXT_LIBS}}) { - my $NAME = $CTX->{INPUT}{EXT_LIBS}{$key}{NAME}; - - # - # set the lists - # - $CTX->{OUTPUT}{EXT_LIBS}{$key}{NAME} = $NAME; - @{$CTX->{OUTPUT}{EXT_LIBS}{$key}{LIBS}} = @{$CTX->{DEPEND}{EXT_LIBS}{$key}{LIBS}}; - @{$CTX->{OUTPUT}{EXT_LIBS}{$key}{CFLAGS}} = @{$CTX->{DEPEND}{EXT_LIBS}{$key}{CFLAGS}}; - @{$CTX->{OUTPUT}{EXT_LIBS}{$key}{CPPFLAGS}} = @{$CTX->{DEPEND}{EXT_LIBS}{$key}{CPPFLAGS}}; - @{$CTX->{OUTPUT}{EXT_LIBS}{$key}{LDFLAGS}} = @{$CTX->{DEPEND}{EXT_LIBS}{$key}{LDFLAGS}}; - } - - return; -} - -sub _generate_subsystems($) -{ - my $CTX = shift; - - # - # loop over all subsystems - # - foreach my $key (sort keys %{$CTX->{DEPEND}{SUBSYSTEMS}}) { - my $NAME = $CTX->{INPUT}{SUBSYSTEMS}{$key}{NAME}; - my @OBJ_LIST = @{$CTX->{DEPEND}{SUBSYSTEMS}{$key}{OBJ_LIST}}; - - if ($CTX->{INPUT}{SUBSYSTEMS}{$key}{NOPROTO} ne "YES") { - push(@{$CTX->{OUTPUT}{PROTO}{OBJ_LIST}},"\$(SUBSYSTEM_$key\_OBJS)"); - } - - # - # set the lists - # - $CTX->{OUTPUT}{SUBSYSTEMS}{$key}{NAME} = $NAME; - @{$CTX->{OUTPUT}{SUBSYSTEMS}{$key}{OBJ_LIST}} = @OBJ_LIST; - } - - return; -} - -sub _generate_shared_modules($) -{ - my $CTX = shift; - - # - # loop over all shared modules - # - foreach my $key (sort keys %{$CTX->{DEPEND}{SHARED_MODULES}}) { - my $NAME = $CTX->{INPUT}{MODULES}{$key}{NAME}; - my @OBJ_LIST = (); - # - my $MODULE = $NAME.".so"; - my @DEPEND_LIST = ("\$(MODULE_$NAME\_OBJS)"); - my @LINK_LIST = ("\$(MODULE_$NAME\_OBJS)"); - my @LINK_FLAGS = (); - - push(@{$CTX->{OUTPUT}{PROTO}{OBJ_LIST}},"\$(MODULE_$key\_OBJS)"); - push(@{$CTX->{OUTPUT}{TARGETS}{ALL}{DEPEND_LIST}},"bin/$MODULE"); - - push(@OBJ_LIST,@{$CTX->{INPUT}{MODULES}{$key}{INIT_OBJ_FILES}}); - push(@OBJ_LIST,@{$CTX->{INPUT}{MODULES}{$key}{ADD_OBJ_FILES}}); - - foreach my $elem (@{$CTX->{DEPEND}{SHARED_MODULES}{$key}{SUBSYSTEMS_LIST}}) { - if (!defined($CTX->{DEPEND}{SUBSYSTEMS}{$elem})) { - die("Shared Module[$NAME] depends on unknown Subsystem[$elem]!\n"); - } - push(@DEPEND_LIST,"\$(SUBSYSTEM_$elem\_OBJS)"); - push(@LINK_LIST,"\$(SUBSYSTEM_$elem\_OBJS)"); - } - - foreach my $elem (@{$CTX->{DEPEND}{SHARED_MODULES}{$key}{LIBRARIES_LIST}}) { - if (!defined($CTX->{DEPEND}{EXT_LIBS}{$elem})) { - die("Share Module[$NAME] depends on unknown External Library[$elem]!\n"); - } - push(@LINK_LIST,@{$CTX->{DEPEND}{EXT_LIBS}{$elem}{LIBS}}); - push(@LINK_FLAGS,@{$CTX->{DEPEND}{EXT_LIBS}{$elem}{LDFLAGS}}); - } - - # - # set the lists - # - $CTX->{OUTPUT}{SHARED_MODULES}{$key}{NAME} = $NAME; - @{$CTX->{OUTPUT}{SHARED_MODULES}{$key}{OBJ_LIST}} = @OBJ_LIST; - # - $CTX->{OUTPUT}{SHARED_MODULES}{$key}{MODULE} = $MODULE; - @{$CTX->{OUTPUT}{SHARED_MODULES}{$key}{DEPEND_LIST}} = @DEPEND_LIST; - @{$CTX->{OUTPUT}{SHARED_MODULES}{$key}{LINK_LIST}} = @LINK_LIST; - @{$CTX->{OUTPUT}{SHARED_MODULES}{$key}{LINK_FLAGS}} = @LINK_FLAGS; - } - - return; -} - -sub _generate_libraries($) -{ - my $CTX = shift; - - # - # loop over all binaries - # - foreach my $key (sort keys %{$CTX->{DEPEND}{LIBRARIES}}) { - my $NAME = $CTX->{INPUT}{LIBRARIES}{$key}{NAME}; - my @OBJ_LIST = @{$CTX->{INPUT}{LIBRARIES}{$key}{OBJ_FILES}}; - my $MAJOR_VERSION = $CTX->{INPUT}{LIBRARIES}{$key}{MAJOR_VERSION}; - my $MINOR_VERSION = $CTX->{INPUT}{LIBRARIES}{$key}{MINOR_VERSION}; - my $RELEASE_VERSION = $CTX->{INPUT}{LIBRARIES}{$key}{RELEASE_VERSION}; - # - my @DEPEND_LIST = ("\$(LIBRARY_$NAME\_OBJS)"); - - my $STATIC_LIBRARY_NAME = $NAME.".a"; - my @STATIC_LINK_LIST = ("\$(LIBRARY_$NAME\_OBJS)"); - my @STATIC_LINK_FLAGS = (); - - my $SHARED_LIBRARY_NAME = $NAME.".so"; - my $SHARED_LIBRARY_SONAME = $SHARED_LIBRARY_NAME.".$MAJOR_VERSION"; - my $SHARED_LIBRARY_REALNAME = $SHARED_LIBRARY_SONAME.".$MINOR_VERSION.$RELEASE_VERSION"; - my @SHARED_LINK_LIST = ("\$(LIBRARY_$NAME\_OBJS)"); - my @SHARED_LINK_FLAGS = ("\@SONAMEFLAG\@$SHARED_LIBRARY_SONAME"); - - push(@{$CTX->{OUTPUT}{PROTO}{OBJ_LIST}},"\$(LIBRARY_$key\_OBJS)"); - - # - # not add to 'make all' for now - # - - foreach my $elem (@{$CTX->{DEPEND}{LIBRARIES}{$key}{SUBSYSTEMS_LIST}}) { - if (!defined($CTX->{DEPEND}{SUBSYSTEMS}{$elem})) { - die("Library[$NAME] depends on unknown Subsystem[$elem]!\n"); - } - push(@DEPEND_LIST,"\$(SUBSYSTEM_$elem\_OBJS)"); - push(@STATIC_LINK_LIST,"\$(SUBSYSTEM_$elem\_OBJS)"); - push(@SHARED_LINK_LIST,"\$(SUBSYSTEM_$elem\_OBJS)"); - } - - foreach my $elem (@{$CTX->{DEPEND}{LIBRARIES}{$key}{LIBRARIES_LIST}}) { - if (!defined($CTX->{DEPEND}{EXT_LIBS}{$elem})) { - die("Library[$NAME] depends on unknown External Library[$elem]!\n"); - } - push(@SHARED_LINK_LIST,@{$CTX->{DEPEND}{EXT_LIBS}{$elem}{LIBS}}); - push(@SHARED_LINK_FLAGS,@{$CTX->{DEPEND}{EXT_LIBS}{$elem}{LDFLAGS}}); - } - - # - # set the lists - # - $CTX->{OUTPUT}{LIBRARIES}{$key}{NAME} = $NAME; - @{$CTX->{OUTPUT}{LIBRARIES}{$key}{OBJ_LIST}} = @OBJ_LIST; - # - @{$CTX->{OUTPUT}{LIBRARIES}{$key}{DEPEND_LIST}} = @DEPEND_LIST; - - $CTX->{OUTPUT}{LIBRARIES}{$key}{STATIC_LIBRARY_NAME} = $STATIC_LIBRARY_NAME; - @{$CTX->{OUTPUT}{LIBRARIES}{$key}{STATIC_LINK_LIST}} = @STATIC_LINK_LIST; - @{$CTX->{OUTPUT}{LIBRARIES}{$key}{STATIC_LINK_FLAGS}} = @STATIC_LINK_FLAGS; - - $CTX->{OUTPUT}{LIBRARIES}{$key}{SHARED_LIBRARY_NAME} = $SHARED_LIBRARY_NAME; - $CTX->{OUTPUT}{LIBRARIES}{$key}{SHARED_LIBRARY_REALNAME} = $SHARED_LIBRARY_REALNAME; - $CTX->{OUTPUT}{LIBRARIES}{$key}{SHARED_LIBRARY_SONAME} = $SHARED_LIBRARY_SONAME; - @{$CTX->{OUTPUT}{LIBRARIES}{$key}{SHARED_LINK_LIST}} = @SHARED_LINK_LIST; - @{$CTX->{OUTPUT}{LIBRARIES}{$key}{SHARED_LINK_FLAGS}} = @SHARED_LINK_FLAGS; - } - - return; -} - -sub _generate_binaries($) -{ - my $CTX = shift; - - # - # loop over all binaries - # - foreach my $key (sort keys %{$CTX->{DEPEND}{BINARIES}}) { - my $NAME = $CTX->{INPUT}{BINARIES}{$key}{NAME}; - my @OBJ_LIST = @{$CTX->{INPUT}{BINARIES}{$key}{OBJ_FILES}}; - # - my $BINARY = $NAME; - my @DEPEND_LIST = ("\$(BINARY_$NAME\_OBJS)"); - my @LINK_LIST = ("\$(BINARY_$NAME\_OBJS)"); - my @LINK_FLAGS = (); - - push(@{$CTX->{OUTPUT}{PROTO}{OBJ_LIST}},"\$(BINARY_$key\_OBJS)"); - push(@{$CTX->{OUTPUT}{TARGETS}{ALL}{DEPEND_LIST}},"bin/$BINARY"); - - foreach my $elem (@{$CTX->{DEPEND}{BINARIES}{$key}{SUBSYSTEMS_LIST}}) { - if (!defined($CTX->{DEPEND}{SUBSYSTEMS}{$elem})) { - die("Binary[$NAME] depends on unknown Subsystem[$elem]!\n"); - } - push(@DEPEND_LIST,"\$(SUBSYSTEM_$elem\_OBJS)"); - push(@LINK_LIST,"\$(SUBSYSTEM_$elem\_OBJS)"); - } - - foreach my $elem (@{$CTX->{DEPEND}{BINARIES}{$key}{LIBRARIES_LIST}}) { - if (!defined($CTX->{DEPEND}{EXT_LIBS}{$elem})) { - die("Binary[$NAME] depends on unknown External Library[$elem]!\n"); - } - push(@LINK_LIST,@{$CTX->{DEPEND}{EXT_LIBS}{$elem}{LIBS}}); - push(@LINK_FLAGS,@{$CTX->{DEPEND}{EXT_LIBS}{$elem}{LDFLAGS}}); - } - - # Export all symbols... - push(@LINK_FLAGS,@{$CTX->{BUILD_ENV}{LD}{DYNEXP}}); - - # - # set the lists - # - $CTX->{OUTPUT}{BINARIES}{$key}{NAME} = $NAME; - @{$CTX->{OUTPUT}{BINARIES}{$key}{OBJ_LIST}} = @OBJ_LIST; - # - $CTX->{OUTPUT}{BINARIES}{$key}{BINARY} = $BINARY; - @{$CTX->{OUTPUT}{BINARIES}{$key}{DEPEND_LIST}} = @DEPEND_LIST; - @{$CTX->{OUTPUT}{BINARIES}{$key}{LINK_LIST}} = @LINK_LIST; - @{$CTX->{OUTPUT}{BINARIES}{$key}{LINK_FLAGS}} = @LINK_FLAGS; - } - - return; -} - -########################################################### -# This function generates the output -# -# create_output($SMB_BUILD_CTX) -# -# $SMB_BUILD_CTX - the global SMB_BUILD context -sub create_output($) -{ - my $CTX = shift; - - $CTX->{OUTPUT}{PROTO} = (); - @{$CTX->{OUTPUT}{PROTO}{OBJ_LIST}} = (); - - $CTX->{OUTPUT}{TARGETS}{ALL} = (); - $CTX->{OUTPUT}{TARGETS}{ALL}{TARGET} = "all"; - @{$CTX->{OUTPUT}{TARGETS}{ALL}{DEPEND_LIST}} = (); - - _generate_ext_libs($CTX); - - _generate_subsystems($CTX); - - _generate_shared_modules($CTX); - - _generate_libraries($CTX); - - _generate_binaries($CTX); - - return; -} diff --git a/source4/build/smb_build/output.pm b/source4/build/smb_build/output.pm new file mode 100644 index 0000000000..42b4403e73 --- /dev/null +++ b/source4/build/smb_build/output.pm @@ -0,0 +1,264 @@ +########################################################### +### SMB Build System ### +### - the output generating functions ### +### ### +### Copyright (C) Stefan (metze) Metzmacher 2004 ### +### Released under the GNU GPL ### +########################################################### + +sub _generate_ext_libs($) +{ + my $CTX = shift; + + # + # loop over all binaries + # + foreach my $key (sort keys %{$CTX->{DEPEND}{EXT_LIBS}}) { + my $NAME = $CTX->{INPUT}{EXT_LIBS}{$key}{NAME}; + + # + # set the lists + # + $CTX->{OUTPUT}{EXT_LIBS}{$key}{NAME} = $NAME; + @{$CTX->{OUTPUT}{EXT_LIBS}{$key}{LIBS}} = @{$CTX->{DEPEND}{EXT_LIBS}{$key}{LIBS}}; + @{$CTX->{OUTPUT}{EXT_LIBS}{$key}{CFLAGS}} = @{$CTX->{DEPEND}{EXT_LIBS}{$key}{CFLAGS}}; + @{$CTX->{OUTPUT}{EXT_LIBS}{$key}{CPPFLAGS}} = @{$CTX->{DEPEND}{EXT_LIBS}{$key}{CPPFLAGS}}; + @{$CTX->{OUTPUT}{EXT_LIBS}{$key}{LDFLAGS}} = @{$CTX->{DEPEND}{EXT_LIBS}{$key}{LDFLAGS}}; + } + + return; +} + +sub _generate_subsystems($) +{ + my $CTX = shift; + + # + # loop over all subsystems + # + foreach my $key (sort keys %{$CTX->{DEPEND}{SUBSYSTEMS}}) { + my $NAME = $CTX->{INPUT}{SUBSYSTEMS}{$key}{NAME}; + my @OBJ_LIST = @{$CTX->{DEPEND}{SUBSYSTEMS}{$key}{OBJ_LIST}}; + + if ($CTX->{INPUT}{SUBSYSTEMS}{$key}{NOPROTO} ne "YES") { + push(@{$CTX->{OUTPUT}{PROTO}{OBJ_LIST}},"\$(SUBSYSTEM_$key\_OBJS)"); + } + + # + # set the lists + # + $CTX->{OUTPUT}{SUBSYSTEMS}{$key}{NAME} = $NAME; + @{$CTX->{OUTPUT}{SUBSYSTEMS}{$key}{OBJ_LIST}} = @OBJ_LIST; + } + + return; +} + +sub _generate_shared_modules($) +{ + my $CTX = shift; + + # + # loop over all shared modules + # + foreach my $key (sort keys %{$CTX->{DEPEND}{SHARED_MODULES}}) { + my $NAME = $CTX->{INPUT}{MODULES}{$key}{NAME}; + my @OBJ_LIST = (); + # + my $MODULE = $NAME.".so"; + my @DEPEND_LIST = ("\$(MODULE_$NAME\_OBJS)"); + my @LINK_LIST = ("\$(MODULE_$NAME\_OBJS)"); + my @LINK_FLAGS = (); + + push(@{$CTX->{OUTPUT}{PROTO}{OBJ_LIST}},"\$(MODULE_$key\_OBJS)"); + push(@{$CTX->{OUTPUT}{TARGETS}{ALL}{DEPEND_LIST}},"bin/$MODULE"); + + push(@OBJ_LIST,@{$CTX->{INPUT}{MODULES}{$key}{INIT_OBJ_FILES}}); + push(@OBJ_LIST,@{$CTX->{INPUT}{MODULES}{$key}{ADD_OBJ_FILES}}); + + foreach my $elem (@{$CTX->{DEPEND}{SHARED_MODULES}{$key}{SUBSYSTEMS_LIST}}) { + if (!defined($CTX->{DEPEND}{SUBSYSTEMS}{$elem})) { + die("Shared Module[$NAME] depends on unknown Subsystem[$elem]!\n"); + } + push(@DEPEND_LIST,"\$(SUBSYSTEM_$elem\_OBJS)"); + push(@LINK_LIST,"\$(SUBSYSTEM_$elem\_OBJS)"); + } + + foreach my $elem (@{$CTX->{DEPEND}{SHARED_MODULES}{$key}{LIBRARIES_LIST}}) { + if (!defined($CTX->{DEPEND}{EXT_LIBS}{$elem})) { + die("Share Module[$NAME] depends on unknown External Library[$elem]!\n"); + } + push(@LINK_LIST,@{$CTX->{DEPEND}{EXT_LIBS}{$elem}{LIBS}}); + push(@LINK_FLAGS,@{$CTX->{DEPEND}{EXT_LIBS}{$elem}{LDFLAGS}}); + } + + # + # set the lists + # + $CTX->{OUTPUT}{SHARED_MODULES}{$key}{NAME} = $NAME; + @{$CTX->{OUTPUT}{SHARED_MODULES}{$key}{OBJ_LIST}} = @OBJ_LIST; + # + $CTX->{OUTPUT}{SHARED_MODULES}{$key}{MODULE} = $MODULE; + @{$CTX->{OUTPUT}{SHARED_MODULES}{$key}{DEPEND_LIST}} = @DEPEND_LIST; + @{$CTX->{OUTPUT}{SHARED_MODULES}{$key}{LINK_LIST}} = @LINK_LIST; + @{$CTX->{OUTPUT}{SHARED_MODULES}{$key}{LINK_FLAGS}} = @LINK_FLAGS; + } + + return; +} + +sub _generate_libraries($) +{ + my $CTX = shift; + + # + # loop over all binaries + # + foreach my $key (sort keys %{$CTX->{DEPEND}{LIBRARIES}}) { + my $NAME = $CTX->{INPUT}{LIBRARIES}{$key}{NAME}; + my @OBJ_LIST = @{$CTX->{INPUT}{LIBRARIES}{$key}{OBJ_FILES}}; + my $MAJOR_VERSION = $CTX->{INPUT}{LIBRARIES}{$key}{MAJOR_VERSION}; + my $MINOR_VERSION = $CTX->{INPUT}{LIBRARIES}{$key}{MINOR_VERSION}; + my $RELEASE_VERSION = $CTX->{INPUT}{LIBRARIES}{$key}{RELEASE_VERSION}; + # + my @DEPEND_LIST = ("\$(LIBRARY_$NAME\_OBJS)"); + + my $STATIC_LIBRARY_NAME = $NAME.".a"; + my @STATIC_LINK_LIST = ("\$(LIBRARY_$NAME\_OBJS)"); + my @STATIC_LINK_FLAGS = (); + + my $SHARED_LIBRARY_NAME = $NAME.".so"; + my $SHARED_LIBRARY_SONAME = $SHARED_LIBRARY_NAME.".$MAJOR_VERSION"; + my $SHARED_LIBRARY_REALNAME = $SHARED_LIBRARY_SONAME.".$MINOR_VERSION.$RELEASE_VERSION"; + my @SHARED_LINK_LIST = ("\$(LIBRARY_$NAME\_OBJS)"); + my @SHARED_LINK_FLAGS = ("\@SONAMEFLAG\@$SHARED_LIBRARY_SONAME"); + + push(@{$CTX->{OUTPUT}{PROTO}{OBJ_LIST}},"\$(LIBRARY_$key\_OBJS)"); + + # + # not add to 'make all' for now + # + + foreach my $elem (@{$CTX->{DEPEND}{LIBRARIES}{$key}{SUBSYSTEMS_LIST}}) { + if (!defined($CTX->{DEPEND}{SUBSYSTEMS}{$elem})) { + die("Library[$NAME] depends on unknown Subsystem[$elem]!\n"); + } + push(@DEPEND_LIST,"\$(SUBSYSTEM_$elem\_OBJS)"); + push(@STATIC_LINK_LIST,"\$(SUBSYSTEM_$elem\_OBJS)"); + push(@SHARED_LINK_LIST,"\$(SUBSYSTEM_$elem\_OBJS)"); + } + + foreach my $elem (@{$CTX->{DEPEND}{LIBRARIES}{$key}{LIBRARIES_LIST}}) { + if (!defined($CTX->{DEPEND}{EXT_LIBS}{$elem})) { + die("Library[$NAME] depends on unknown External Library[$elem]!\n"); + } + push(@SHARED_LINK_LIST,@{$CTX->{DEPEND}{EXT_LIBS}{$elem}{LIBS}}); + push(@SHARED_LINK_FLAGS,@{$CTX->{DEPEND}{EXT_LIBS}{$elem}{LDFLAGS}}); + } + + # + # set the lists + # + $CTX->{OUTPUT}{LIBRARIES}{$key}{NAME} = $NAME; + @{$CTX->{OUTPUT}{LIBRARIES}{$key}{OBJ_LIST}} = @OBJ_LIST; + # + @{$CTX->{OUTPUT}{LIBRARIES}{$key}{DEPEND_LIST}} = @DEPEND_LIST; + + $CTX->{OUTPUT}{LIBRARIES}{$key}{STATIC_LIBRARY_NAME} = $STATIC_LIBRARY_NAME; + @{$CTX->{OUTPUT}{LIBRARIES}{$key}{STATIC_LINK_LIST}} = @STATIC_LINK_LIST; + @{$CTX->{OUTPUT}{LIBRARIES}{$key}{STATIC_LINK_FLAGS}} = @STATIC_LINK_FLAGS; + + $CTX->{OUTPUT}{LIBRARIES}{$key}{SHARED_LIBRARY_NAME} = $SHARED_LIBRARY_NAME; + $CTX->{OUTPUT}{LIBRARIES}{$key}{SHARED_LIBRARY_REALNAME} = $SHARED_LIBRARY_REALNAME; + $CTX->{OUTPUT}{LIBRARIES}{$key}{SHARED_LIBRARY_SONAME} = $SHARED_LIBRARY_SONAME; + @{$CTX->{OUTPUT}{LIBRARIES}{$key}{SHARED_LINK_LIST}} = @SHARED_LINK_LIST; + @{$CTX->{OUTPUT}{LIBRARIES}{$key}{SHARED_LINK_FLAGS}} = @SHARED_LINK_FLAGS; + } + + return; +} + +sub _generate_binaries($) +{ + my $CTX = shift; + + # + # loop over all binaries + # + foreach my $key (sort keys %{$CTX->{DEPEND}{BINARIES}}) { + my $NAME = $CTX->{INPUT}{BINARIES}{$key}{NAME}; + my @OBJ_LIST = @{$CTX->{INPUT}{BINARIES}{$key}{OBJ_FILES}}; + # + my $BINARY = $NAME; + my @DEPEND_LIST = ("\$(BINARY_$NAME\_OBJS)"); + my @LINK_LIST = ("\$(BINARY_$NAME\_OBJS)"); + my @LINK_FLAGS = (); + + push(@{$CTX->{OUTPUT}{PROTO}{OBJ_LIST}},"\$(BINARY_$key\_OBJS)"); + push(@{$CTX->{OUTPUT}{TARGETS}{ALL}{DEPEND_LIST}},"bin/$BINARY"); + + foreach my $elem (@{$CTX->{DEPEND}{BINARIES}{$key}{SUBSYSTEMS_LIST}}) { + if (!defined($CTX->{DEPEND}{SUBSYSTEMS}{$elem})) { + die("Binary[$NAME] depends on unknown Subsystem[$elem]!\n"); + } + push(@DEPEND_LIST,"\$(SUBSYSTEM_$elem\_OBJS)"); + push(@LINK_LIST,"\$(SUBSYSTEM_$elem\_OBJS)"); + } + + foreach my $elem (@{$CTX->{DEPEND}{BINARIES}{$key}{LIBRARIES_LIST}}) { + if (!defined($CTX->{DEPEND}{EXT_LIBS}{$elem})) { + die("Binary[$NAME] depends on unknown External Library[$elem]!\n"); + } + push(@LINK_LIST,@{$CTX->{DEPEND}{EXT_LIBS}{$elem}{LIBS}}); + push(@LINK_FLAGS,@{$CTX->{DEPEND}{EXT_LIBS}{$elem}{LDFLAGS}}); + } + + # Export all symbols... + push(@LINK_FLAGS,@{$CTX->{BUILD_ENV}{LD}{DYNEXP}}); + + # + # set the lists + # + $CTX->{OUTPUT}{BINARIES}{$key}{NAME} = $NAME; + @{$CTX->{OUTPUT}{BINARIES}{$key}{OBJ_LIST}} = @OBJ_LIST; + # + $CTX->{OUTPUT}{BINARIES}{$key}{BINARY} = $BINARY; + @{$CTX->{OUTPUT}{BINARIES}{$key}{DEPEND_LIST}} = @DEPEND_LIST; + @{$CTX->{OUTPUT}{BINARIES}{$key}{LINK_LIST}} = @LINK_LIST; + @{$CTX->{OUTPUT}{BINARIES}{$key}{LINK_FLAGS}} = @LINK_FLAGS; + } + + return; +} + +########################################################### +# This function generates the output +# +# create_output($SMB_BUILD_CTX) +# +# $SMB_BUILD_CTX - the global SMB_BUILD context +sub create_output($) +{ + my $CTX = shift; + + $CTX->{OUTPUT}{PROTO} = (); + @{$CTX->{OUTPUT}{PROTO}{OBJ_LIST}} = (); + + $CTX->{OUTPUT}{TARGETS}{ALL} = (); + $CTX->{OUTPUT}{TARGETS}{ALL}{TARGET} = "all"; + @{$CTX->{OUTPUT}{TARGETS}{ALL}{DEPEND_LIST}} = (); + + _generate_ext_libs($CTX); + + _generate_subsystems($CTX); + + _generate_shared_modules($CTX); + + _generate_libraries($CTX); + + _generate_binaries($CTX); + + return; +} + +1; diff --git a/source4/build/smb_build/smb_build_h.pl b/source4/build/smb_build/smb_build_h.pl deleted file mode 100644 index cd6cb29525..0000000000 --- a/source4/build/smb_build/smb_build_h.pl +++ /dev/null @@ -1,132 +0,0 @@ -########################################################### -### SMB Build System ### -### - create output for smb_build.h ### -### ### -### Copyright (C) Stefan (metze) Metzmacher 2004 ### -### Released under the GNU GPL ### -########################################################### - -sub _add_define_section($) -{ - my $DEFINE = shift; - my $output = ""; - - $output .= " -/* $DEFINE->{COMMENT} */ -#define $DEFINE->{KEY} $DEFINE->{VAL} -"; - - return $output; -} - -sub _prepare_smb_build_h($) -{ - my $CTX = shift; - my $output = ""; - - # - # loop over all subsystems - # - foreach my $key (sort keys %{$CTX->{DEPEND}{SUBSYSTEMS}}) { - my $NAME = $CTX->{INPUT}{SUBSYSTEMS}{$key}{NAME}; - my $DEFINE = (); - my $name = lc($NAME); - - # - # Static modules - # - $DEFINE->{COMMENT} = "SUBSYSTEM $NAME INIT"; - $DEFINE->{KEY} = $name . "_init_static_modules"; - $DEFINE->{VAL} = "do { \\\n"; - foreach my $subkey (@{$CTX->{DEPEND}{SUBSYSTEMS}{$key}{INIT_FUNCTIONS}}) { - $DEFINE->{VAL} .= "\t\textern NTSTATUS $subkey(void); \\\n"; - } - - foreach my $subkey (@{$CTX->{DEPEND}{SUBSYSTEMS}{$key}{INIT_FUNCTIONS}}) { - $DEFINE->{VAL} .= "\t\t$subkey(); \\\n"; - } - $DEFINE->{VAL} .= "\t} while(0)"; - - push(@{$CTX->{OUTPUT}{SMB_BUILD_H}},$DEFINE); - } - - # - # loop over all binaries - # - foreach my $key (sort keys %{$CTX->{DEPEND}{BINARIES}}) { - my $NAME = $CTX->{INPUT}{BINARIES}{$key}{NAME}; - my $DEFINE = (); - my $name = lc($NAME); - - # - # Static modules - # - $DEFINE->{COMMENT} = "BINARY $NAME INIT"; - $DEFINE->{KEY} = $name . "_init_subsystems"; - $DEFINE->{VAL} = "do { \\\n"; - foreach my $subkey (@{$CTX->{DEPEND}{BINARIES}{$key}{INIT_FUNCTIONS}}) { - $DEFINE->{VAL} .= "\t\tif (NT_STATUS_IS_ERR($subkey())) exit(1); \\\n"; - } - $DEFINE->{VAL} .= "\t} while(0)"; - - push(@{$CTX->{OUTPUT}{SMB_BUILD_H}},$DEFINE); - } - - # - # Shared modules - # - foreach my $key (sort keys %{$CTX->{INPUT}{MODULES}}) { - next if ($CTX->{INPUT}{MODULES}{$key}{BUILD} ne "SHARED"); - - my $name = $CTX->{INPUT}{MODULES}{$key}{NAME}; - my $func = $CTX->{INPUT}{MODULES}{$key}{INIT_FUNCTION}; - next if $func eq ""; - - my $DEFINE = (); - - $DEFINE->{COMMENT} = "$name is built shared"; - $DEFINE->{KEY} = $func; - $DEFINE->{VAL} = "init_module"; - - push(@{$CTX->{OUTPUT}{SMB_BUILD_H}},$DEFINE); - } - - # - # loop over all SMB_BUILD_H define sections - # - foreach my $key (@{$CTX->{OUTPUT}{SMB_BUILD_H}}) { - $output .= _add_define_section($key); - } - - return $output; -} - -########################################################### -# This function creates include/smb_build.h from the SMB_BUILD -# context -# -# create_smb_build_h($SMB_BUILD_CTX) -# -# $SMB_BUILD_CTX - the global SMB_BUILD context -# -# $output - the resulting output buffer -sub create_smb_build_h($) -{ - my $CTX = shift; - my $output = "/* autogenerated by config.smb_build.pl */\n"; - - $output .= _prepare_smb_build_h($CTX); - - # - # TODO: check if directory include/ exists - # - - open(SMB_BUILD_H,"> include/smb_build.h") || die ("Can't open include/smb_build.h\n"); - - print SMB_BUILD_H $output; - - close(SMB_BUILD_H); - - print "config.smb_build.pl: creating include/smb_build.h\n"; - return; -} diff --git a/source4/build/smb_build/smb_build_h.pm b/source4/build/smb_build/smb_build_h.pm new file mode 100644 index 0000000000..bc12b9a268 --- /dev/null +++ b/source4/build/smb_build/smb_build_h.pm @@ -0,0 +1,133 @@ +########################################################### +### SMB Build System ### +### - create output for smb_build.h ### +### ### +### Copyright (C) Stefan (metze) Metzmacher 2004 ### +### Released under the GNU GPL ### +########################################################### + +sub _add_define_section($) +{ + my $DEFINE = shift; + my $output = ""; + + $output .= " +/* $DEFINE->{COMMENT} */ +#define $DEFINE->{KEY} $DEFINE->{VAL} +"; + + return $output; +} + +sub _prepare_smb_build_h($) +{ + my $CTX = shift; + my $output = ""; + + # + # loop over all subsystems + # + foreach my $key (sort keys %{$CTX->{DEPEND}{SUBSYSTEMS}}) { + my $NAME = $CTX->{INPUT}{SUBSYSTEMS}{$key}{NAME}; + my $DEFINE = (); + my $name = lc($NAME); + + # + # Static modules + # + $DEFINE->{COMMENT} = "SUBSYSTEM $NAME INIT"; + $DEFINE->{KEY} = $name . "_init_static_modules"; + $DEFINE->{VAL} = "do { \\\n"; + foreach my $subkey (@{$CTX->{DEPEND}{SUBSYSTEMS}{$key}{INIT_FUNCTIONS}}) { + $DEFINE->{VAL} .= "\t\textern NTSTATUS $subkey(void); \\\n"; + } + + foreach my $subkey (@{$CTX->{DEPEND}{SUBSYSTEMS}{$key}{INIT_FUNCTIONS}}) { + $DEFINE->{VAL} .= "\t\t$subkey(); \\\n"; + } + $DEFINE->{VAL} .= "\t} while(0)"; + + push(@{$CTX->{OUTPUT}{SMB_BUILD_H}},$DEFINE); + } + + # + # loop over all binaries + # + foreach my $key (sort keys %{$CTX->{DEPEND}{BINARIES}}) { + my $NAME = $CTX->{INPUT}{BINARIES}{$key}{NAME}; + my $DEFINE = (); + my $name = lc($NAME); + + # + # Static modules + # + $DEFINE->{COMMENT} = "BINARY $NAME INIT"; + $DEFINE->{KEY} = $name . "_init_subsystems"; + $DEFINE->{VAL} = "do { \\\n"; + foreach my $subkey (@{$CTX->{DEPEND}{BINARIES}{$key}{INIT_FUNCTIONS}}) { + $DEFINE->{VAL} .= "\t\tif (NT_STATUS_IS_ERR($subkey())) exit(1); \\\n"; + } + $DEFINE->{VAL} .= "\t} while(0)"; + + push(@{$CTX->{OUTPUT}{SMB_BUILD_H}},$DEFINE); + } + + # + # Shared modules + # + foreach my $key (sort keys %{$CTX->{INPUT}{MODULES}}) { + next if ($CTX->{INPUT}{MODULES}{$key}{BUILD} ne "SHARED"); + + my $name = $CTX->{INPUT}{MODULES}{$key}{NAME}; + my $func = $CTX->{INPUT}{MODULES}{$key}{INIT_FUNCTION}; + next if $func eq ""; + + my $DEFINE = (); + + $DEFINE->{COMMENT} = "$name is built shared"; + $DEFINE->{KEY} = $func; + $DEFINE->{VAL} = "init_module"; + + push(@{$CTX->{OUTPUT}{SMB_BUILD_H}},$DEFINE); + } + + # + # loop over all SMB_BUILD_H define sections + # + foreach my $key (@{$CTX->{OUTPUT}{SMB_BUILD_H}}) { + $output .= _add_define_section($key); + } + + return $output; +} + +########################################################### +# This function creates include/smb_build.h from the SMB_BUILD +# context +# +# create_smb_build_h($SMB_BUILD_CTX) +# +# $SMB_BUILD_CTX - the global SMB_BUILD context +# +# $output - the resulting output buffer +sub create_smb_build_h($) +{ + my $CTX = shift; + my $output = "/* autogenerated by config.smb_build.pl */\n"; + + $output .= _prepare_smb_build_h($CTX); + + # + # TODO: check if directory include/ exists + # + + open(SMB_BUILD_H,"> include/smb_build.h") || die ("Can't open include/smb_build.h\n"); + + print SMB_BUILD_H $output; + + close(SMB_BUILD_H); + + print "config.smb_build.pl: creating include/smb_build.h\n"; + return; +} +1; -- cgit