########################################################### ### 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} = "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); } # # 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 $DEFINE = (); $DEFINE->{COMMENT} = "$name is built shared"; $DEFINE->{KEY} = "$name\_init"; $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; }