diff options
Diffstat (limited to 'source4/build/smb_build')
-rw-r--r-- | source4/build/smb_build/config_mk.pl | 434 | ||||
-rw-r--r-- | source4/build/smb_build/core.m4 | 76 | ||||
-rw-r--r-- | source4/build/smb_build/depend.pl | 475 | ||||
-rw-r--r-- | source4/build/smb_build/input.pl | 128 | ||||
-rw-r--r-- | source4/build/smb_build/main.pl | 38 | ||||
-rw-r--r-- | source4/build/smb_build/makefile.pl | 852 | ||||
-rw-r--r-- | source4/build/smb_build/output.pl | 191 | ||||
-rw-r--r-- | source4/build/smb_build/public.m4 | 441 | ||||
-rw-r--r-- | source4/build/smb_build/smb_build_h.pl | 84 |
9 files changed, 2719 insertions, 0 deletions
diff --git a/source4/build/smb_build/config_mk.pl b/source4/build/smb_build/config_mk.pl new file mode 100644 index 0000000000..ba580c7c65 --- /dev/null +++ b/source4/build/smb_build/config_mk.pl @@ -0,0 +1,434 @@ +########################################################### +### 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 (<CONFIG_MK>) { + 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 = $result->{$section}{$key}{VAL}; + } elsif (defined($result->{DEFAULT}{$key})) { + $val = $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_<module>_<parameter> +# 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_<module>_<parameter> +# 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_<subsystem>_<parameter> +# 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_<subsystem>_<parameter> +# 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_<library>_<parameter> +# 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_<library>_<parameter> +# 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_<binary>_<parameter> +# 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_<binary>_<parameter> +# 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/core.m4 b/source4/build/smb_build/core.m4 new file mode 100644 index 0000000000..1dc4b36446 --- /dev/null +++ b/source4/build/smb_build/core.m4 @@ -0,0 +1,76 @@ +dnl SMB Build Core System +dnl ------------------------------------------------------- +dnl Copyright (C) Stefan (metze) Metzmacher 2004 +dnl Released under the GNU GPL +dnl ------------------------------------------------------- +dnl +dnl _SMB_BUILD_CORE( +dnl 1: outputfile +dnl ) + +dnl ####################################################### +dnl ### And now the implementation ### +dnl ####################################################### + +dnl _SMB_BUILD_CORE( +dnl 1: outputfile +dnl ) +AC_DEFUN([_SMB_BUILD_CORE], +[ + +echo "config.status: creating ./config.smb_build.pl" + +cat > config.smb_build.pl <<\_SMB_ACEOF +#!/usr/bin/perl -W +# + +use strict; + +my \$SMB_BUILD_CTX; + +_SMB_ACEOF + +cat >> config.smb_build.pl < build/smb_build/config_mk.pl +cat >> config.smb_build.pl < build/smb_build/input.pl +cat >> config.smb_build.pl < build/smb_build/depend.pl +cat >> config.smb_build.pl < build/smb_build/output.pl +cat >> config.smb_build.pl < build/smb_build/makefile.pl +cat >> config.smb_build.pl < build/smb_build/smb_build_h.pl +cat >> config.smb_build.pl < build/smb_build/main.pl + +cat >> config.smb_build.pl <<\_SMB_ACEOF +########################################################### +### First we list all info from configure ### +########################################################### +# +######################################### +## Start Ext Libs +$SMB_INFO_EXT_LIBS +## End Ext Libs +######################################### +######################################### +## Start Modules +$SMB_INFO_MODULES +## End Modules +######################################### +## Start Subsystems +$SMB_INFO_SUBSYSTEMS +## End Subsystems +######################################### +## Start Libraries +$SMB_INFO_LIBRARIES +## End Libraries +######################################### +## Start Binaries +$SMB_INFO_BINARIES +## End Binaries +######################################### + +smb_build_main(\$SMB_BUILD_CTX); + +0; +_SMB_ACEOF + +$PERL config.smb_build.pl || exit $? + +]) diff --git a/source4/build/smb_build/depend.pl b/source4/build/smb_build/depend.pl new file mode 100644 index 0000000000..23525c0f62 --- /dev/null +++ b/source4/build/smb_build/depend.pl @@ -0,0 +1,475 @@ +########################################################### +### 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 = (); + + # + # skip when the subsystem was disabled + # + if ($CTX->{INPUT}{SUBSYSTEMS}{$key}{ENABLE} ne "YES" ) { + next; + } + + # + # create the subsystems used OBJ_LIST + # + my @OBJ_LIST = (); + foreach my $elem (@{$CTX->{INPUT}{SUBSYSTEMS}{$key}{INIT_OBJ_FILES}}) { + push(@OBJ_LIST,$elem); + } + foreach my $elem (@{$CTX->{INPUT}{SUBSYSTEMS}{$key}{ADD_OBJ_FILES}}) { + push(@OBJ_LIST,$elem); + } + + # + # create the subsystems used SUBSYSTEMS_LIST + # + my @SUBSYSTEMS_LIST = (); + foreach my $elem (@{$CTX->{INPUT}{SUBSYSTEMS}{$key}{REQUIRED_SUBSYSTEMS}}) { + push(@SUBSYSTEMS_LIST,$elem); + } + + # + # create the subsystems used LIBRARIES_LIST + # + my @LIBRARIES_LIST = (); + foreach my $elem (@{$CTX->{INPUT}{SUBSYSTEMS}{$key}{REQUIRED_LIBRARIES}}) { + push(@LIBRARIES_LIST,$elem); + } + + # + # 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); + + # + # add OBJS of static modules to the subsystems used OBJ_LIST + # + foreach my $elem (@{$CTX->{INPUT}{MODULES}{$subkey}{INIT_OBJ_FILES}}) { + push(@OBJ_LIST,$elem); + } + foreach my $elem (@{$CTX->{INPUT}{MODULES}{$subkey}{ADD_OBJ_FILES}}) { + push(@OBJ_LIST,$elem); + } + + # + # add SUBSYSTEMS of static modules to the subsystems used SUBSYSTEMS_LIST + # + foreach my $elem (@{$CTX->{INPUT}{MODULES}{$subkey}{REQUIRED_SUBSYSTEMS}}) { + push(@SUBSYSTEMS_LIST,$elem); + } + + # + # add LIBRARIES of static modules to the subsystems used LIBRARIES_LIST + # + foreach my $elem (@{$CTX->{INPUT}{MODULES}{$subkey}{REQUIRED_LIBRARIES}}) { + push(@LIBRARIES_LIST,$elem); + } + } + + # + # set the lists + # + @{$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 = (); + foreach my $elem (@{$CTX->{INPUT}{MODULES}{$key}{REQUIRED_SUBSYSTEMS}}) { + push(@SUBSYSTEMS_LIST,$elem); + } + + # + # 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 = (); + foreach my $elem (@{$CTX->{INPUT}{MODULES}{$key}{REQUIRED_LIBRARIES}}) { + push(@LIBRARIES_LIST,$elem); + } + + # + # 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}{BUILD} ne "SHARED" ) { + next; + } + + # + # create the libraries used SUBSYSTEMS_LIST + # + my @SUBSYSTEMS_LIST = (); + foreach my $elem (@{$CTX->{INPUT}{LIBRARIES}{$key}{REQUIRED_SUBSYSTEMS}}) { + push(@SUBSYSTEMS_LIST,$elem); + } + + # + # 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 = (); + foreach my $elem (@{$CTX->{INPUT}{LIBRARIES}{$key}{REQUIRED_LIBRARIES}}) { + push(@LIBRARIES_LIST,$elem); + } + + # + # 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 = (); + foreach my $elem (@{$CTX->{INPUT}{BINARIES}{$key}{REQUIRED_SUBSYSTEMS}}) { + push(@SUBSYSTEMS_LIST,$elem); + } + + # + # now try to resolve the dependencies for the binary + # + @SUBSYSTEMS_LIST = _do_calc_subsystem_list($CTX, \@SUBSYSTEMS_LIST); + + # + # create the binaries used LIBRARIES_LIST + # + my @LIBRARIES_LIST = (); + foreach my $elem (@{$CTX->{INPUT}{BINARIES}{$key}{REQUIRED_LIBRARIES}}) { + push(@LIBRARIES_LIST,$elem); + } + + # + # 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; + } + + 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/input.pl b/source4/build/smb_build/input.pl new file mode 100644 index 0000000000..8b5b904f1e --- /dev/null +++ b/source4/build/smb_build/input.pl @@ -0,0 +1,128 @@ +########################################################### +### SMB Build System ### +### - the input checking functions ### +### ### +### Copyright (C) Stefan (metze) Metzmacher 2004 ### +### Released under the GNU GPL ### +########################################################### + + +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/main.pl b/source4/build/smb_build/main.pl new file mode 100644 index 0000000000..ebe8e23c1d --- /dev/null +++ b/source4/build/smb_build/main.pl @@ -0,0 +1,38 @@ +########################################################### +### SMB Build System ### +### - the main program ### +### ### +### Copyright (C) Stefan (metze) Metzmacher 2004 ### +### Released under the GNU GPL ### +########################################################### + +use Data::Dumper; +sub _dump_ctx($) +{ + my $ctx = shift; + + open (DUMP,"> config.smb_build.dump"); + + print DUMP Dumper($ctx); + + close(DUMP); + + return; +} + +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); + + _dump_ctx($SMB_BUILD_CTX); + + return 0; +}
\ No newline at end of file diff --git a/source4/build/smb_build/makefile.pl b/source4/build/smb_build/makefile.pl new file mode 100644 index 0000000000..bb7df5a9f2 --- /dev/null +++ b/source4/build/smb_build/makefile.pl @@ -0,0 +1,852 @@ +########################################################### +### 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\@ + +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 + +# 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)\\\" +PATH_FLAGS = \$(PATH_FLAGS6) \$(PASSWD_FLAGS) +"; + return $output; +} + +sub _prepare_compiler_linker($) +{ + my $ctx = shift; + my $output; + + $output = " +CC=\@CC\@ +CC_FLAGS=-I./include -I./ -I./lib \@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\@\" script/build_idl.sh FULL + +idl: build/pidl/idl.pm + \@CPP=\"\@CPP\@\" script/build_idl.sh + +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 = " +MAKEDIR = || exec false; \\ + if test -d \"\$\$dir\"; then :; else \\ + echo mkdir \"\$\$dir\"; \\ + mkdir -p \"\$\$dir\" >/dev/null 2>&1 || \\ + test -d \"\$\$dir\" || \\ + mkdir \"\$\$dir\" || \\ + exec false; fi || exec false + +bin/.dummy: + \@if (: >> \$\@ || : > \$\@) >/dev/null 2>&1; then :; else \\ + dir=bin \$(MAKEDIR); fi + \@: >> \$\@ || : > \$\@ + +dynconfig.o: dynconfig.c Makefile + \@if (: >> \$\@ || : > \$\@) >/dev/null 2>&1; then rm -f \$\@; else \\ + dir=`echo \$\@ | sed 's,/[^/]*\$\$,,;s,^\$\$,.,'` \$(MAKEDIR); fi + \@echo Compiling \$*.c + \@\$(CC) \$(CC_FLAGS) \$(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,$message,$comment) +# +# $srcext - sourcefile extension +# +# $destext - destinationfile extension +# +# $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 $message = shift; + my $comment = shift; + my $output; + + $output = " +################################### +# Start $comment +.$src.$dst: + \@if (: >> \$\@ || : > \$\@) >/dev/null 2>&1; then rm -f \$\@; else \\ + dir=`echo \$\@ | sed 's,/[^/]*\$\$,,;s,^\$\$,.,'` \$(MAKEDIR); fi + \@echo $message \$*.$src + \@\$(CC) \$(CC_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 <var> name +# $var_ctx->{OBJ_LIST} - the list of objectfiles which sould be linked to this <var> +# +# $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_objlist($) +{ + 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} +################################### +"; + + 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->{LIBRARY} - the library name +# $library_ctx->{STATIC_LIBRARY} - the static library name +# $library_ctx->{SHARED_LIBRARY} - the shared library name +# $library_ctx->{DEPEND_LIST} - the list of rules on which this library depends +# $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_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 $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}); + + $output = " +################################### +# Start Library $ctx->{LIBRARY} +# +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} +bin/$ctx->{STATIC_LIBRARY}: \$(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})) { + $output .= " +# Shared $ctx->{SHARED_LIBRARY} +bin/$ctx->{SHARED_LIBRARY}: \$(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)"; + } +$output .= " +# End Library $ctx->{LIBRARY} +################################### +"; + + 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) +# 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: \$(builddir)/include/proto.h \$(builddir)/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 \$(builddir)/include/proto.h \$(builddir)/include/build_env.h + +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)\" + +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: + +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 + +PYTHON_TDB_OBJ = lib/tdb/tdb.o lib/tdb/spinlock.o +PYTHON_TDB_PICOBJ = \$(PYTHON_TDB_OBJ:.o=.po) + +swig: scripting/swig/python/_tdb.so + +swig_clean: + -rm -f scripting/swig/python/_tdb.so scripting/swig/python/tdb.pyc \\ + scripting/swig/python/tdb.py scripting/swig/python/tdb_wrap.c \\ + scripting/swig/python/tdb_wrap.po + +scripting/swig/python/tdb.py: scripting/swig/tdb.i + swig -python scripting/swig/tdb.i + mv scripting/swig/tdb.py scripting/swig/python + mv scripting/swig/tdb_wrap.c scripting/swig/python + +scripting/swig/python/_tdb.so: scripting/swig/python/tdb.py scripting/swig/python/tdb_wrap.po \$(PYTHON_TDB_PICOBJ) + \$(SHLD) \$(LDSHFLAGS) -o scripting/swig/python/_tdb.so scripting/swig/python/tdb_wrap.po \\ + \$(PYTHON_TDB_PICOBJ) + +"; + + 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","Compiling","Rule for std objectfiles"); + $output .= _prepare_std_CC_rule("h","h.gch","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/output.pl b/source4/build/smb_build/output.pl new file mode 100644 index 0000000000..2705cd8e79 --- /dev/null +++ b/source4/build/smb_build/output.pl @@ -0,0 +1,191 @@ +########################################################### +### 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}}; + + 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 unkown 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 unkown 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($) +{ + 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 unkown 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 unkown 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}{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/public.m4 b/source4/build/smb_build/public.m4 new file mode 100644 index 0000000000..9bfcd549b8 --- /dev/null +++ b/source4/build/smb_build/public.m4 @@ -0,0 +1,441 @@ +dnl SMB Build System +dnl ---------------- +dnl ---------------- +dnl +dnl SMB_MODULE_DEFAULT( +dnl 1:name, +dnl 2:default_build +dnl ) +dnl +dnl SMB_MODULE ( +dnl 1:name, +dnl 2:subsystem, +dnl 3:default_build, +dnl 4:init_obj_files, +dnl 5:add_obj_files, +dnl 6:required_libs, +dnl 7:required_subsystems +dnl ) +dnl +dnl SMB_MODULE_MK( +dnl 1:name, +dnl 2:subsystem, +dnl 3:default_build, +dnl 4:config_mk_file +dnl ) +dnl +dnl SMB_SUBSYSTEM_ENABLE( +dnl 1:name, +dnl 2:default_build +dnl ) +dnl +dnl SMB_SUBSYSTEM( +dnl 1:name, +dnl 2:init_obj_files, +dnl 3:add_obj_files, +dnl 4:required_libs, +dnl 5:required_subsystems +dnl ) +dnl +dnl SMB_SUBSYSTEM_MK( +dnl 1:name, +dnl 2:config_mk_file +dnl ) +dnl +dnl SMB_EXT_LIB_ENABLE( +dnl 1:name, +dnl 2:default_build +dnl ) +dnl +dnl SMB_EXT_LIB( +dnl 1:name, +dnl 2:libs, +dnl 3:cflags, +dnl 4:cppflags, +dnl 5:ldflags +dnl ) +dnl +dnl SMB_LIBRARY_ENABLE( +dnl 1:name, +dnl 2:default_build +dnl ) +dnl +dnl SMB_LIBRARY( +dnl 1:name, +dnl 2:obj_files, +dnl 3:required_libs, +dnl 4:required_subsystems +dnl ) +dnl +dnl SMB_LIBRARY_MK( +dnl 1:name, +dnl 2:config_mk_file +dnl ) +dnl +dnl SMB_BINARY_ENABLE( +dnl 1:name, +dnl 2:default_build +dnl ) +dnl +dnl SMB_BINARY( +dnl 1:name, +dnl 2:build_targets, +dnl 3:install_path +dnl 4:obj_files, +dnl 5:required_libs, +dnl 6:required_subsystems +dnl ) +dnl +dnl SMB_BINARY_MK( +dnl 1:name, +dnl 2:config_mk_file +dnl ) +dnl +dnl SMB_MAKE_TARGET( +dnl 1:name +dnl 2:calledname +dnl ) +dnl +dnl SMB_AC_OUTPUT( +dnl 1: outputfile +dnl ) + +dnl ####################################################### +dnl ### And now the implementation ### +dnl ####################################################### + +dnl SMB_MODULE_DEFAULT( +dnl 1:name, +dnl 2:default_build +dnl ) +AC_DEFUN([SMB_MODULE_DEFAULT], +[ + [SMB_MODULE_DEFAULT_][$1]="$2" +]) + +dnl SMB_MODULE ( +dnl 1:name, +dnl 2:subsystem, +dnl 3:default_build, +dnl 4:init_obj_files, +dnl 5:add_obj_files, +dnl 6:required_libs, +dnl 7:required_subsystems +dnl ) +AC_DEFUN([SMB_MODULE], +[ + + if test -z "$[SMB_MODULE_DEFAULT_][$1]"; then + [SMB_MODULE_DEFAULT_][$1]=$3 + fi + + if test "$[SMB_MODULE_][$1]"; then + [SMB_MODULE_][$1]=$[SMB_MODULE_][$1] + elif test "$[SMB_MODULE_]translit([$2], [A-Z], [a-z])" -a x"$[SMB_MODULE_DEFAULT_][$1]" != xNOT; then + [SMB_MODULE_][$1]=$[SMB_MODULE_]translit([$2], [A-Z], [a-z]) + else + [SMB_MODULE_][$1]="DEFAULT"; + fi + +SMB_INFO_MODULES="$SMB_INFO_MODULES +################################### +# Start MODULE $1 +\$SMB_BUILD_CTX->{INPUT}{MODULES}{$1}{NAME} = \"$1\"; +\$SMB_BUILD_CTX->{INPUT}{MODULES}{$1}{SUBSYSTEM} = \"$2\"; +\$SMB_BUILD_CTX->{INPUT}{MODULES}{$1}{DEFAULT_BUILD} = \"$[SMB_MODULE_DEFAULT_][$1]\"; +@{\$SMB_BUILD_CTX->{INPUT}{MODULES}{$1}{INIT_OBJ_FILES}} = str2array(\"$4\"); +@{\$SMB_BUILD_CTX->{INPUT}{MODULES}{$1}{ADD_OBJ_FILES}} = str2array(\"$5\"); +@{\$SMB_BUILD_CTX->{INPUT}{MODULES}{$1}{REQUIRED_LIBRARIES}} = str2array(\"$6\"); +@{\$SMB_BUILD_CTX->{INPUT}{MODULES}{$1}{REQUIRED_SUBSYSTEMS}} = str2array(\"$7\"); +# +\$SMB_BUILD_CTX->{INPUT}{MODULES}{$1}{CHOSEN_BUILD} = \"$[SMB_MODULE_][$1]\"; +# End MODULE $1 +################################### +" +]) + +dnl SMB_MODULE_MK( +dnl 1:name, +dnl 2:subsystem, +dnl 3:default_build, +dnl 4:config_mk_file +dnl ) +AC_DEFUN([SMB_MODULE_MK], +[ + + if test -z "$[SMB_MODULE_DEFAULT_][$1]"; then + [SMB_MODULE_DEFAULT_][$1]=$3 + fi + + if test "$[SMB_MODULE_][$1]"; then + [SMB_MODULE_][$1]=$[SMB_MODULE_][$1] + elif test "$[SMB_MODULE_]translit([$2], [A-Z], [a-z])" -a x"$[SMB_MODULE_DEFAULT_][$1]" != xNOT; then + [SMB_MODULE_][$1]=$[SMB_MODULE_]translit([$2], [A-Z], [a-z]) + else + [SMB_MODULE_][$1]="DEFAULT"; + fi + +SMB_INFO_MODULES="$SMB_INFO_MODULES +################################### +# Start MODULE $1 +\$SMB_BUILD_CTX->{INPUT}{MODULES}{$1}{NAME} = \"$1\"; +\$SMB_BUILD_CTX->{INPUT}{MODULES}{$1}{SUBSYSTEM} = \"$2\"; +\$SMB_BUILD_CTX->{INPUT}{MODULES}{$1}{DEFAULT_BUILD} = \"$[SMB_MODULE_DEFAULT_][$1]\"; +@{\$SMB_BUILD_CTX->{INPUT}{MODULES}{$1}{INIT_OBJ_FILES}} = module_get_array(\"$4\", \"$1\", \"INIT_OBJ_FILES\"); +@{\$SMB_BUILD_CTX->{INPUT}{MODULES}{$1}{ADD_OBJ_FILES}} = module_get_array(\"$4\", \"$1\", \"ADD_OBJ_FILES\"); +@{\$SMB_BUILD_CTX->{INPUT}{MODULES}{$1}{REQUIRED_LIBRARIES}} = module_get_array(\"$4\", \"$1\", \"REQUIRED_LIBRARIES\"); +@{\$SMB_BUILD_CTX->{INPUT}{MODULES}{$1}{REQUIRED_SUBSYSTEMS}} = module_get_array(\"$4\", \"$1\", \"REQUIRED_SUBSYSTEMS\"); +# +\$SMB_BUILD_CTX->{INPUT}{MODULES}{$1}{CHOSEN_BUILD} = \"$[SMB_MODULE_][$1]\"; +# End MODULE $1 +################################### +" +]) + +dnl SMB_SUBSYSTEM_ENABLE( +dnl 1:name, +dnl 2:default_build +dnl ) +AC_DEFUN([SMB_SUBSYSTEM_ENABLE], +[ + [SMB_SUBSYSTEM_ENABLE_][$1]="$2" +]) + +dnl SMB_SUBSYSTEM( +dnl 1:name, +dnl 2:init_obj_files, +dnl 3:add_obj_files, +dnl 4:required_libs, +dnl 5:required_subsystems +dnl ) +AC_DEFUN([SMB_SUBSYSTEM], +[ + + if test -z "$[SMB_SUBSYSTEM_ENABLE_][$1]"; then + [SMB_SUBSYSTEM_ENABLE_][$1]="YES"; + fi + +SMB_INFO_SUBSYSTEMS="$SMB_INFO_SUBSYSTEMS +################################### +# Start Subsystem $1 +\$SMB_BUILD_CTX->{INPUT}{SUBSYSTEMS}{$1}{NAME} = \"$1\"; +@{\$SMB_BUILD_CTX->{INPUT}{SUBSYSTEMS}{$1}{INIT_OBJ_FILES}} = str2array(\"$2\"); +@{\$SMB_BUILD_CTX->{INPUT}{SUBSYSTEMS}{$1}{ADD_OBJ_FILES}} = str2array(\"$3\"); +@{\$SMB_BUILD_CTX->{INPUT}{SUBSYSTEMS}{$1}{REQUIRED_LIBRARIES}} = str2array(\"$4\"); +@{\$SMB_BUILD_CTX->{INPUT}{SUBSYSTEMS}{$1}{REQUIRED_SUBSYSTEMS}} = str2array(\"$5\"); +# +\$SMB_BUILD_CTX->{INPUT}{SUBSYSTEMS}{$1}{ENABLE} = \"$[SMB_SUBSYSTEM_ENABLE_][$1]\"; +# End Subsystem $1 +################################### +" +]) + +dnl SMB_SUBSYSTEM_MK( +dnl 1:name, +dnl 2:config_mk_file +dnl ) +AC_DEFUN([SMB_SUBSYSTEM_MK], +[ + + if test -z "$[SMB_SUBSYSTEM_ENABLE_][$1]"; then + [SMB_SUBSYSTEM_ENABLE_][$1]="YES"; + fi + +SMB_INFO_SUBSYSTEMS="$SMB_INFO_SUBSYSTEMS +################################### +# Start Subsystem $1 +\$SMB_BUILD_CTX->{INPUT}{SUBSYSTEMS}{$1}{NAME} = \"$1\"; +@{\$SMB_BUILD_CTX->{INPUT}{SUBSYSTEMS}{$1}{INIT_OBJ_FILES}} = subsystem_get_array(\"$2\", \"$1\", \"INIT_OBJ_FILES\"); +@{\$SMB_BUILD_CTX->{INPUT}{SUBSYSTEMS}{$1}{ADD_OBJ_FILES}} = subsystem_get_array(\"$2\", \"$1\", \"ADD_OBJ_FILES\"); +@{\$SMB_BUILD_CTX->{INPUT}{SUBSYSTEMS}{$1}{REQUIRED_LIBRARIES}} = subsystem_get_array(\"$2\", \"$1\", \"REQUIRED_LIBRARIES\"); +@{\$SMB_BUILD_CTX->{INPUT}{SUBSYSTEMS}{$1}{REQUIRED_SUBSYSTEMS}} = subsystem_get_array(\"$2\", \"$1\", \"REQUIRED_SUBSYSTEMS\"); +# +\$SMB_BUILD_CTX->{INPUT}{SUBSYSTEMS}{$1}{ENABLE} = \"$[SMB_SUBSYSTEM_ENABLE_][$1]\"; +# End Subsystem $1 +################################### +" +]) + +dnl SMB_EXT_LIB_ENABLE( +dnl 1:name, +dnl 2:default_build +dnl ) +AC_DEFUN([SMB_EXT_LIB_ENABLE], +[ + [SMB_EXT_LIB_ENABLE_][$1]="$2" +]) + +dnl SMB_EXT_LIB( +dnl 1:name, +dnl 2:libs, +dnl 3:cflags, +dnl 4:cppflags, +dnl 5:ldflags +dnl ) +AC_DEFUN([SMB_EXT_LIB], +[ + + if test -z "$[SMB_EXT_LIB_ENABLE_][$1]"; then + [SMB_EXT_LIB_ENABLE_][$1]="NO"; + fi + +SMB_INFO_EXT_LIBS="$SMB_INFO_EXT_LIBS +################################### +# Start Ext Lib $1 +\$SMB_BUILD_CTX->{INPUT}{EXT_LIBS}{$1}{NAME} = \"$1\"; +@{\$SMB_BUILD_CTX->{INPUT}{EXT_LIBS}{$1}{LIBS}} = str2array(\"$2\"); +@{\$SMB_BUILD_CTX->{INPUT}{EXT_LIBS}{$1}{CFLAGS}} = str2array(\"$3\"); +@{\$SMB_BUILD_CTX->{INPUT}{EXT_LIBS}{$1}{CPPFLAGS}} = str2array(\"$4\"); +@{\$SMB_BUILD_CTX->{INPUT}{EXT_LIBS}{$1}{LDFLAGS}} = str2array(\"$5\"); +# +\$SMB_BUILD_CTX->{INPUT}{EXT_LIBS}{$1}{ENABLE} = \"$[SMB_EXT_LIB_ENABLE_][$1]\"; +# End Ext Lib $1 +################################### +" +]) + + +dnl SMB_LIBRARY_ENABLE( +dnl 1:name, +dnl 2:default_build +dnl ) +AC_DEFUN([SMB_LIBRARY_ENABLE], +[ + [SMB_LIBRARY_ENABLE_][$1]="$2" +]) + +dnl SMB_LIBRARY( +dnl 1:name, +dnl 2:obj_files, +dnl 3:required_libs, +dnl 4:required_subsystems +dnl ) +AC_DEFUN([SMB_LIBRARY], +[ + + if test -z "$[SMB_LIBRARY_ENABLE_][$1]"; then + [SMB_LIBRARY_ENABLE_][$1]="YES"; + fi + +SMB_INFO_LIBRARIES="$SMB_INFO_LIBRARIES +################################### +# Start Library $1 +\$SMB_BUILD_CTX->{INPUT}{LIBRARIES}{$1}{NAME} = \"$1\"; +@{\$SMB_BUILD_CTX->{INPUT}{LIBRARIES}{$1}{OBJ_FILES}} = str2array(\"$2\"); +@{\$SMB_BUILD_CTX->{INPUT}{LIBRARIES}{$1}{REQUIRED_LIBRARIES}} = str2array(\"$3\"); +@{\$SMB_BUILD_CTX->{INPUT}{LIBRARIES}{$1}{REQUIRED_SUBSYSTEMS}} = str2array(\"$4\"); +# +\$SMB_BUILD_CTX->{INPUT}{LIBRARIES}{$1}{ENABLE} = \"$[SMB_LIBRARY_ENABLE_][$1]\"; +# End Library $1 +################################### +" +]) + +dnl SMB_LIBRARY_MK( +dnl 1:name, +dnl 2:config_mk_file +dnl ) +AC_DEFUN([SMB_LIBRARY_MK], +[ + + if test -z "$[SMB_LIBRARY_ENABLE_][$1]"; then + [SMB_LIBRARY_ENABLE_][$1]="YES"; + fi + +SMB_INFO_LIBRARIES="$SMB_INFO_LIBRARIES +################################### +# Start Library $1 +\$SMB_BUILD_CTX->{INPUT}{LIBRARIES}{$1}{NAME} = \"$1\"; +@{\$SMB_BUILD_CTX->{INPUT}{LIBRARIES}{$1}{OBJ_FILES}} = library_get_array(\"$2\", \"$1\", \"OBJ_FILES\"); +@{\$SMB_BUILD_CTX->{INPUT}{LIBRARIES}{$1}{REQUIRED_LIBRARIES}} = library_get_array(\"$2\", \"$1\", \"REQUIRED_LIBRARIES\"); +@{\$SMB_BUILD_CTX->{INPUT}{LIBRARIES}{$1}{REQUIRED_SUBSYSTEMS}} = library_get_array(\"$2\", \"$1\", \"REQUIRED_SUBSYSTEMS\"); +# +\$SMB_BUILD_CTX->{INPUT}{LIBRARIES}{$1}{ENABLE} = \"$[SMB_LIBRARY_ENABLE_][$1]\"; +# End Library $1 +################################### +" +]) + +dnl SMB_BINARY_ENABLE( +dnl 1:name, +dnl 2:default_build +dnl ) +AC_DEFUN([SMB_BINARY_ENABLE], +[ + [SMB_BINARY_ENABLE_][$1]="$2"; +]) + +dnl SMB_BINARY( +dnl 1:name, +dnl 2:build_targets, +dnl 3:install_path +dnl 4:objfiles, +dnl 5:required_libs, +dnl 6:required_subsystems +dnl ) +AC_DEFUN([SMB_BINARY], +[ + + if test -z "$[SMB_BINARY_ENABLE_][$1]"; then + [SMB_BINARY_ENABLE_][$1]="YES"; + fi + +SMB_INFO_BINARIES="$SMB_INFO_BINARIES +################################### +# Start Binary $1 +\$SMB_BUILD_CTX->{INPUT}{BINARIES}{$1}{NAME} = \"$1\"; +@{\$SMB_BUILD_CTX->{INPUT}{BINARIES}{$1}{BUILD_TARGETS}} = str2array(\"$2\"); +@{\$SMB_BUILD_CTX->{INPUT}{BINARIES}{$1}{INSTALL_PATH}} = str2array(\"$3\"); +@{\$SMB_BUILD_CTX->{INPUT}{BINARIES}{$1}{OBJ_FILES}} = str2array(\"$4\"); +@{\$SMB_BUILD_CTX->{INPUT}{BINARIES}{$1}{REQUIRED_LIBRARIES}} = str2array(\"$5\"); +@{\$SMB_BUILD_CTX->{INPUT}{BINARIES}{$1}{REQUIRED_SUBSYSTEMS}} = str2array(\"$6\"); +# +\$SMB_BUILD_CTX->{INPUT}{BINARIES}{$1}{ENABLE} = \"$[SMB_BINARY_ENABLE_][$1]\"; +# End Binary $1 +################################### +" +]) + +dnl SMB_BINARY_MK( +dnl 1:name, +dnl 2:config_mk_file +dnl ) +AC_DEFUN([SMB_BINARY_MK], +[ + + if test -z "$[SMB_BINARY_ENABLE_][$1]"; then + [SMB_BINARY_ENABLE_][$1]="YES"; + fi + +SMB_INFO_BINARIES="$SMB_INFO_BINARIES +################################### +# Start Binary $1 +\$SMB_BUILD_CTX->{INPUT}{BINARIES}{$1}{NAME} = \"$1\"; +@{\$SMB_BUILD_CTX->{INPUT}{BINARIES}{$1}{BUILD_TARGETS}} = binary_get_array(\"$2\", \"$1\", \"BUILD_TARGETS\"); +@{\$SMB_BUILD_CTX->{INPUT}{BINARIES}{$1}{INSTALL_PATH}} = binary_get_array(\"$2\", \"$1\", \"INSTALL_PATH\"); +@{\$SMB_BUILD_CTX->{INPUT}{BINARIES}{$1}{OBJ_FILES}} = binary_get_array(\"$2\", \"$1\", \"OBJ_FILES\"); +@{\$SMB_BUILD_CTX->{INPUT}{BINARIES}{$1}{REQUIRED_LIBRARIES}} = binary_get_array(\"$2\", \"$1\",\"REQUIRED_LIBRARIES\"); +@{\$SMB_BUILD_CTX->{INPUT}{BINARIES}{$1}{REQUIRED_SUBSYSTEMS}} = binary_get_array(\"$2\", \"$1\",\"REQUIRED_SUBSYSTEMS\"); +# +\$SMB_BUILD_CTX->{INPUT}{BINARIES}{$1}{ENABLE} = \"$[SMB_BINARY_ENABLE_][$1]\"; +# End Binary $1 +################################### +" +]) + +dnl SMB_MAKE_TARGET( +dnl 1:name +dnl 2:calledname +dnl ) +AC_DEFUN([SMB_MAKE_TARGET], +[ + echo "#SMB_MAKE_TARGET TOTO" +]) + +dnl SMB_AC_OUTPUT( +dnl 1: outputfile +dnl ) +AC_DEFUN([SMB_AC_OUTPUT], +[ + AC_OUTPUT([$1],[],[_SMB_BUILD_CORE([[$1][.in]])]) +]) diff --git a/source4/build/smb_build/smb_build_h.pl b/source4/build/smb_build/smb_build_h.pl new file mode 100644 index 0000000000..7a829dd684 --- /dev/null +++ b/source4/build/smb_build/smb_build_h.pl @@ -0,0 +1,84 @@ +########################################################### +### 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); + + $DEFINE->{COMMENT} = "SUBSYSTEM $NAME INIT"; + $DEFINE->{KEY} = "static_init_$name"; + $DEFINE->{VAL} = "do { \\\n"; + foreach my $subkey (@{$CTX->{DEPEND}{SUBSYSTEMS}{$key}{STATIC_MODULES_LIST}}) { + $DEFINE->{VAL} .= "\t\t$subkey\_init(); \\\n"; + } + $DEFINE->{VAL} .= "\t} while(0)"; + + 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; +} |