diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2005-10-26 23:36:04 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:45:18 -0500 |
commit | 1437535a24a3d33352ba310adefeca6862cc94f3 (patch) | |
tree | b418cbdd1fb797a954b9ee14553f2aa2ad434a93 | |
parent | 4dc5da1335a8dc39b4e6153ce7da75d429d343de (diff) | |
download | samba-1437535a24a3d33352ba310adefeca6862cc94f3.tar.gz samba-1437535a24a3d33352ba310adefeca6862cc94f3.tar.bz2 samba-1437535a24a3d33352ba310adefeca6862cc94f3.zip |
r11311: Move some more logic to env
(This used to be commit 990419bac7ce335ffcec84017614eb9642a6ece6)
-rw-r--r-- | source4/build/smb_build/env.pm | 33 | ||||
-rw-r--r-- | source4/build/smb_build/main.pl | 21 | ||||
-rw-r--r-- | source4/build/smb_build/makefile.pm | 57 |
3 files changed, 79 insertions, 32 deletions
diff --git a/source4/build/smb_build/env.pm b/source4/build/smb_build/env.pm index 9e52e1974d..b3dcbb8456 100644 --- a/source4/build/smb_build/env.pm +++ b/source4/build/smb_build/env.pm @@ -17,11 +17,16 @@ sub new($$) my ($name, $config) = @_; my $self = { }; bless $self, $name; - $self->set_config($config); + + $self->{items} = {}; + $self->{info} = {}; + + $self->_set_config($config); + return $self; } -sub set_config($$) +sub _set_config($$) { my ($self, $config) = @_; @@ -69,4 +74,28 @@ __EOF__ close(OUT); } +sub Import($$) +{ + my ($self,$items) = @_; + + foreach (keys %$items) { + if (defined($self->{items})) { + print "Warning: Importing $_ twice!\n"; + } + $self->{items}->{$_} = $items->{$_}; + } +} + +sub GetInfo($$) +{ + my ($self,$name) = @_; + + unless (defined($self->{info}->{$name})) + { + $self->{info}->{$name} = $self->{items}->Build($self); + } + + return $self->{info}->{$name}; +} + 1; diff --git a/source4/build/smb_build/main.pl b/source4/build/smb_build/main.pl index 35e29ecb0e..85e48e6ed9 100644 --- a/source4/build/smb_build/main.pl +++ b/source4/build/smb_build/main.pl @@ -38,7 +38,26 @@ if (defined($ENV{"LIBRARY_OUTPUT_TYPE"})) { my $DEPEND = smb_build::input::check($INPUT, \%config::enabled); my $OUTPUT = output::create_output($DEPEND); -my $mkenv = new smb_build::makefile(\%config::config, $OUTPUT, $mkfile); +my $mkenv = new smb_build::makefile(\%config::config, $mkfile); + +foreach my $key (values %$OUTPUT) { + next unless defined $key->{OUTPUT_TYPE}; + + $mkenv->MergedObj($key) if $key->{OUTPUT_TYPE} eq "MERGEDOBJ"; + $mkenv->ObjList($key) if $key->{OUTPUT_TYPE} eq "OBJLIST"; + $mkenv->StaticLibrary($key) if $key->{OUTPUT_TYPE} eq "STATIC_LIBRARY"; + $mkenv->PkgConfig($key) if ($key->{OUTPUT_TYPE} eq "SHARED_LIBRARY") and + defined($key->{MAJOR_VERSION}); + $mkenv->SharedLibrary($key) if $key->{OUTPUT_TYPE} eq "SHARED_LIBRARY"; + $mkenv->Binary($key) if $key->{OUTPUT_TYPE} eq "BINARY"; + $mkenv->Manpage($key) if defined($key->{MANPAGE}); + $mkenv->Header($key) if defined($key->{PUBLIC_HEADERS}); +} + +# FIXME: These two lines are a hack +$mkenv->ProtoHeader($OUTPUT->{PROTO}); +$mkenv->ProtoHeader($OUTPUT->{ALL_OBJS}); + $mkenv->write("Makefile"); smb_build_h::create_smb_build_h($OUTPUT, "include/smb_build.h"); diff --git a/source4/build/smb_build/makefile.pm b/source4/build/smb_build/makefile.pm index c0b9e36e4f..be49a612c9 100644 --- a/source4/build/smb_build/makefile.pm +++ b/source4/build/smb_build/makefile.pm @@ -13,9 +13,9 @@ use strict; use base 'smb_build::env'; -sub new($$$$) +sub new($$$) { - my ($myname, $config, $CTX, $mkfile) = @_; + my ($myname, $config, $mkfile) = @_; my $self = new smb_build::env($config); bless($self, $myname); @@ -44,31 +44,6 @@ sub new($$$$) $self->_prepare_std_CC_rule("c","o",'$(PICFLAG)',"Compiling","Rule for std objectfiles"); $self->_prepare_std_CC_rule("h","h.gch",'$(PICFLAG)',"Precompiling","Rule for precompiled headerfiles"); - $self->_prepare_mk_files(); - - $self->_prepare_dummy_MAKEDIR($CTX); - - foreach my $key (values %$CTX) { - if (defined($key->{OBJ_LIST})) { - $self->_prepare_obj_list($key->{TYPE}, $key); - $self->_prepare_cflags($key->{TYPE}, $key); - } - } - - foreach my $key (values %$CTX) { - next unless defined $key->{OUTPUT_TYPE}; - - $self->MergedObj($key) if $key->{OUTPUT_TYPE} eq "MERGEDOBJ"; - $self->ObjList($key) if $key->{OUTPUT_TYPE} eq "OBJLIST"; - $self->StaticLibrary($key) if $key->{OUTPUT_TYPE} eq "STATIC_LIBRARY"; - $self->PkgConfig($key) if ($key->{OUTPUT_TYPE} eq "SHARED_LIBRARY") and - defined($key->{MAJOR_VERSION}); - $self->SharedLibrary($key) if $key->{OUTPUT_TYPE} eq "SHARED_LIBRARY"; - $self->Binary($key) if $key->{OUTPUT_TYPE} eq "BINARY"; - $self->Manpage($key) if defined($key->{MANPAGE}); - $self->Header($key) if defined($key->{PUBLIC_HEADERS}); - } - return $self; } @@ -169,9 +144,9 @@ sub _prepare_mk_files($) $self->output("MK_FILES = " . array2oneperline(\@tmp) . "\n"); } -sub _prepare_dummy_MAKEDIR($$) +sub _prepare_dummy_MAKEDIR($) { - my ($self,$ctx) = @_; + my ($self) = @_; $self->output(<< '__EOD__' dynconfig.o: dynconfig.c Makefile @@ -263,6 +238,9 @@ sub SharedLibrary($$) push (@{$self->{shared_libs}}, $ctx->{OUTPUT}); + $self->_prepare_obj_list($ctx->{TYPE}, $ctx); + $self->_prepare_cflags($ctx->{TYPE}, $ctx); + my $tmpdepend = array2oneperline($ctx->{DEPEND_LIST}); my $tmpshlink = array2oneperline($ctx->{LINK_LIST}); my $tmpshflag = array2oneperline($ctx->{LINK_FLAGS}); @@ -307,6 +285,8 @@ sub MergedObj($$) my $tmpdepend = array2oneperline($ctx->{DEPEND_LIST}); + $self->_prepare_obj_list($ctx->{TYPE}, $ctx); + $self->_prepare_cflags($ctx->{TYPE}, $ctx); $self->output("$ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST = $tmpdepend\n"); $self->output("$ctx->{TARGET}: \$($ctx->{TYPE}_$ctx->{NAME}_OBJS)\n"); @@ -323,6 +303,8 @@ sub ObjList($$) return unless $ctx->{TARGET}; + $self->_prepare_obj_list($ctx->{TYPE}, $ctx); + $self->_prepare_cflags($ctx->{TYPE}, $ctx); $self->output("$ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST = $tmpdepend\n"); $self->output("$ctx->{TARGET}: "); $self->output("\$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_OBJS)\n"); @@ -335,6 +317,9 @@ sub StaticLibrary($$) push (@{$self->{static_libs}}, $ctx->{OUTPUT}); + $self->_prepare_obj_list($ctx->{TYPE}, $ctx); + $self->_prepare_cflags($ctx->{TYPE}, $ctx); + my $tmpdepend = array2oneperline($ctx->{DEPEND_LIST}); my $tmpstlink = array2oneperline($ctx->{LINK_LIST}); my $tmpstflag = array2oneperline($ctx->{LINK_FLAGS}); @@ -375,6 +360,8 @@ sub Binary($$) push (@{$self->{bin_progs}}, $ctx->{TARGET}); } + $self->_prepare_obj_list($ctx->{TYPE}, $ctx); + $self->_prepare_cflags($ctx->{TYPE}, $ctx); my $tmpdepend = array2oneperline($ctx->{DEPEND_LIST}); my $tmplink = array2oneperline($ctx->{LINK_LIST}); my $tmpflag = array2oneperline($ctx->{LINK_FLAGS}); @@ -419,6 +406,13 @@ sub PkgConfig($$) smb_build::env::PkgConfig($self,$path,$ctx->{NAME},"FIXME",join(' ', @{$ctx->{CFLAGS}}), "$ctx->{MAJOR_VERSION}.$ctx->{MINOR_VERSION}.$ctx->{RELEASE_VERSION}"); } +sub ProtoHeader($$) +{ + my ($self,$ctx) = @_; + + $self->_prepare_obj_list($ctx->{TYPE}, $ctx); +} + sub write($$) { my ($self,$file) = @_; @@ -431,6 +425,9 @@ sub write($$) $self->output("PUBLIC_HEADERS = " . array2oneperline($self->{headers}) . "\n"); $self->output("PC_FILES = " . array2oneperline($self->{pc_files}) . "\n"); + + $self->_prepare_mk_files(); + if ($self->{developer}) { $self->output(<<__EOD__ #-include \$(_ALL_OBJS_OBJS:.o=.d) @@ -442,6 +439,8 @@ __EOD__ ); } + $self->_prepare_dummy_MAKEDIR(); + $self->output($self->{mkfile}); open(MAKEFILE,">$file") || die ("Can't open $file\n"); |