summaryrefslogtreecommitdiff
path: root/source4/build
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-10-21 22:49:23 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:45:09 -0500
commitd316c68cf3fe86480ff05bd7bee18b0f7c6a8c5f (patch)
tree7f74c300c1dc91c32ecf1cd4a2ca3bd59b1f599c /source4/build
parentda63ed00157f392547aaeee7fd946bffc352225c (diff)
downloadsamba-d316c68cf3fe86480ff05bd7bee18b0f7c6a8c5f.tar.gz
r11257: Add and use output function
(This used to be commit 734da63a4e7ff44d9417066300383bbf7cd08d8f)
Diffstat (limited to 'source4/build')
-rw-r--r--source4/build/smb_build/env.pm6
-rw-r--r--source4/build/smb_build/makefile.pm263
2 files changed, 126 insertions, 143 deletions
diff --git a/source4/build/smb_build/env.pm b/source4/build/smb_build/env.pm
index 62569efab3f..86632bdb891 100644
--- a/source4/build/smb_build/env.pm
+++ b/source4/build/smb_build/env.pm
@@ -37,6 +37,12 @@ sub set_config($$)
if ($self->{config}->{exec_prefix} eq "NONE") {
$self->{config}->{exec_prefix} = $self->{config}->{prefix};
}
+
+ if ($self->{config}->{developer} eq "yes") {
+ $self->{developer} = 1;
+ } else {
+ $self->{developer} = 0;
+ }
}
diff --git a/source4/build/smb_build/makefile.pm b/source4/build/smb_build/makefile.pm
index 7827c4124ff..8db8a3c2cf6 100644
--- a/source4/build/smb_build/makefile.pm
+++ b/source4/build/smb_build/makefile.pm
@@ -20,53 +20,65 @@ sub new($$$$)
bless($self, $myname);
- $self->{output} = "############################################\n";
- $self->{output} .= "# Autogenerated by build/smb_build/main.pl #\n";
- $self->{output} .= "############################################\n";
- $self->{output} .= "\n";
-
- $self->{output} .= $self->_prepare_path_vars();
- $self->{output} .= $self->_prepare_compiler_linker();
- $self->{output} .= $self->_prepare_default_rule();
- $self->{output} .= $self->_prepare_SUFFIXES();
- $self->{output} .= $self->_prepare_hostcc_rule();
- $self->{output} .= $self->_prepare_depend_CC_rule();
- $self->{output} .= $self->_prepare_std_CC_rule("c","o",'$(PICFLAG)',"Compiling","Rule for std objectfiles");
- $self->{output} .= $self->_prepare_std_CC_rule("h","h.gch",'$(PICFLAG)',"Precompiling","Rule for precompiled headerfiles");
- $self->{output} .= $self->_prepare_man_rule("1");
- $self->{output} .= $self->_prepare_man_rule("3");
- $self->{output} .= $self->_prepare_man_rule("5");
- $self->{output} .= $self->_prepare_man_rule("7");
+ $self->{output} = "";
+
+ $self->output("################################################\n");
+ $self->output("# Autogenerated by build/smb_build/makefile.pm #\n");
+ $self->output("################################################\n");
+ $self->output("\n");
+
+ $self->output("default: all\n\n");
+
+ $self->_prepare_path_vars();
+ $self->_prepare_compiler_linker();
+ $self->_prepare_SUFFIXES();
+ $self->_prepare_hostcc_rule();
+ $self->_prepare_depend_CC_rule();
+ $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_man_rule("1");
+ $self->_prepare_man_rule("3");
+ $self->_prepare_man_rule("5");
+ $self->_prepare_man_rule("7");
- $self->{output} .= $self->_prepare_config_status();
+ $self->_prepare_config_status();
- $self->{output} .= $self->_prepare_dummy_MAKEDIR($CTX);
- $self->{output} .= $self->_prepare_manpages($CTX);
- $self->{output} .= $self->_prepare_binaries($CTX);
- $self->{output} .= $self->_prepare_target_settings($CTX);
- $self->{output} .= $self->_prepare_rule_lists($CTX);
+ $self->_prepare_dummy_MAKEDIR($CTX);
+ $self->_prepare_manpages($CTX);
+ $self->_prepare_binaries($CTX);
+ $self->_prepare_target_settings($CTX);
+ $self->_prepare_rule_lists($CTX);
+ $self->_prepare_clean_rules();
- if ($self->{config}->{developer} eq "yes") {
- $self->{output} .= <<__EOD__
+ if ($self->{developer}) {
+ $self->output(<<__EOD__
#-include \$(_ALL_OBJS_OBJS:.o=.d)
IDL_FILES = \$(wildcard librpc/idl/*.idl)
\$(patsubst librpc/idl/%.idl,librpc/gen_ndr/ndr_%.c,\$(IDL_FILES)) \\
\$(patsubst librpc/idl/%.idl,librpc/gen_ndr/ndr_\%_c.c,\$(IDL_FILES)) \\
\$(patsubst librpc/idl/%.idl,librpc/gen_ndr/ndr_%.h,\$(IDL_FILES)): idl
__EOD__
+);
}
- $self->{output} .= $mkfile;
+ $self->output($mkfile);
return $self;
}
+sub output($$)
+{
+ my ($self, $text) = @_;
+
+ $self->{output} .= $text;
+}
+
sub _prepare_path_vars($)
{
my ($self) = @_;
- my $output;
- $output = << "__EOD__";
+ $self->output(<< "__EOD__"
prefix = $self->{config}->{prefix}
exec_prefix = $self->{config}->{exec_prefix}
selftest_prefix = $self->{config}->{selftest_prefix}
@@ -91,8 +103,8 @@ MANDIR = $self->{config}->{mandir}
PRIVATEDIR = $self->{config}->{privatedir}
__EOD__
-
- $output.= << '__EOD__';
+);
+ $self->output(<< '__EOD__'
# The permissions to give the executables
INSTALLPERMS = 0755
@@ -110,15 +122,14 @@ PATH_FLAGS = -DCONFIGFILE=\"$(CONFIGFILE)\" -DSBINDIR=\"$(SBINDIR)\" \
-DCONFIGDIR=\"$(CONFIGDIR)\" -DNCALRPCDIR=\"$(NCALRPCDIR)\" \
-DSWATDIR=\"$(SWATDIR)\" -DPRIVATE_DIR=\"$(PRIVATEDIR)\"
__EOD__
-
- return $output;
+);
}
sub _prepare_compiler_linker($)
{
my ($self) = @_;
- return << "__EOD__";
+ $self->output(<< "__EOD__"
SHELL=$self->{config}->{SHELL}
PERL=$self->{config}->{PERL}
@@ -154,33 +165,29 @@ GCOV=$self->{config}->{GCOV}
DEFAULT_TEST_TARGET=$self->{config}->{DEFAULT_TEST_TARGET}
__EOD__
+);
}
-sub _prepare_default_rule()
+sub _prepare_SUFFIXES($)
{
- return << '__EOD__';
-default: all
-
-__EOD__
-}
-
-sub _prepare_SUFFIXES()
-{
- return << '__EOD__';
+ my $self = shift;
+ $self->output(<< '__EOD__'
.SUFFIXES: .x .c .et .y .l .d .o .h .h.gch .a .so .1 .1.xml .3 .3.xml .5 .5.xml .7 .7.xml .ho
__EOD__
+);
}
sub _prepare_man_rule($$)
{
my ($self, $suffix) = @_;
- return << "__EOD__";
+ $self->output(<< "__EOD__"
.$suffix.xml.$suffix:
\$(XSLTPROC) -o \$@ http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl \$<
__EOD__
+);
}
sub _prepare_config_status($)
@@ -194,12 +201,12 @@ sub _prepare_config_status($)
$deps.= " $1";
}
- return "
+ $self->output("
Makefile: config.status $deps
./config.status
-";
+");
}
sub _prepare_binaries($$)
@@ -219,12 +226,8 @@ sub _prepare_binaries($$)
push(@bbn_list, $_->{OUTPUT}) if ($_->{INSTALLDIR} eq "BINDIR");
}
- my $bbn = array2oneperline(\@bbn_list);
- my $sbn = array2oneperline(\@sbn_list);
- return << "__EOD__";
-BIN_PROGS = $bbn
-SBIN_PROGS = $sbn
-__EOD__
+ $self->output("BIN_PROGS = " . array2oneperline(\@bbn_list) . "\n");
+ $self->output("SBIN_PROGS = " . array2oneperline(\@sbn_list) . "\n");
}
sub _prepare_manpages($$)
@@ -241,17 +244,14 @@ sub _prepare_manpages($$)
}
my $mp = array2oneperline(\@mp_list);
- return << "__EOD__";
-MANPAGES = $mp
-
-__EOD__
+ $self->output("MANPAGES = $mp\n");
}
sub _prepare_dummy_MAKEDIR($$)
{
my ($self,$ctx) = @_;
- my $ret = << '__EOD__';
+ $self->output(<< '__EOD__'
bin/.dummy:
@: >> $@ || : > $@
@@ -259,22 +259,25 @@ dynconfig.o: dynconfig.c Makefile
@echo Compiling $*.c
@$(CC) $(CFLAGS) $(PICFLAG) $(PATH_FLAGS) -c $< -o $@
__EOD__
+);
if ($self->{config}->{BROKEN_CC} eq "yes") {
- $ret .= ' -mv `echo $@ | sed \'s%^.*/%%g\'` $@
-';
+ $self->output(' -mv `echo $@ | sed \'s%^.*/%%g\'` $@
+');
}
- return $ret."\n";
+ $self->output("\n");
}
-sub _prepare_depend_CC_rule()
+sub _prepare_depend_CC_rule($)
{
- return << '__EOD__';
+ my $self = shift;
+ $self->output(<< '__EOD__'
.c.d:
@echo "Generating dependencies for $<"
@$(CC) -MM -MG -MT $(<:.c=.o) -MF $@ $(CFLAGS) $<
__EOD__
+);
}
###########################################################
@@ -297,34 +300,37 @@ sub _prepare_std_CC_rule($$$$$$)
{
my ($self,$src,$dst,$flags,$message,$comment) = @_;
- my $ret = << "__EOD__";
+ $self->output(<< "__EOD__"
# $comment
.$src.$dst:
\@echo $message \$\*.$src
\@\$(CC) `script/cflags.sh \$\@` \$(CFLAGS) $flags -c \$< -o \$\@
__EOD__
+);
if ($self->{config}->{BROKEN_CC} eq "yes") {
- $ret.= ' -mv `echo $@ | sed \'s%^.*/%%g\'` $@
-';
+ $self->output(' -mv `echo $@ | sed \'s%^.*/%%g\'` $@
+');
}
- return $ret."\n";
+
+ $self->output("\n");
}
sub _prepare_hostcc_rule($)
{
my ($self) = @_;
- my $ret = << "__EOD__";
+ $self->output(<< "__EOD__"
.c.ho:
\@echo Compiling \$\*.c with host compiler
\@\$(HOSTCC) `script/cflags.sh \$\@` \$(CFLAGS) -c \$< -o \$\@
__EOD__
+);
if ($self->{config}->{BROKEN_CC} eq "yes") {
- $ret .= ' -mv `echo $@ | sed \'s%^.*/%%g\' -e \'s%\.ho$$%.o%\'` $@
-';
+ $self->output(' -mv `echo $@ | sed \'s%^.*/%%g\' -e \'s%\.ho$$%.o%\'` $@
+');
}
- return $ret."\n";
+ $self->output("\n");
}
@@ -361,9 +367,7 @@ sub _prepare_obj_list($$)
my $tmplist = array2oneperline($ctx->{OBJ_LIST});
return "" if ($tmplist eq "");
- return << "__EOD__";
-$var\_$ctx->{NAME}_OBJS =$tmplist
-__EOD__
+ return "$var\_$ctx->{NAME}_OBJS =$tmplist\n";
}
sub _prepare_cflags($$)
@@ -373,10 +377,7 @@ sub _prepare_cflags($$)
my $tmplist = array2oneperline($ctx->{CFLAGS});
return "" if ($tmplist eq "");
- return << "__EOD__";
-$var\_$ctx->{NAME}_CFLAGS =$tmplist
-
-__EOD__
+ return "$var\_$ctx->{NAME}_CFLAGS =$tmplist\n";
}
###########################################################
@@ -398,16 +399,15 @@ __EOD__
# $library_ctx->{LINK_FLAGS} - linker flags used by this shared library
#
# $output - the resulting output buffer
-sub _prepare_shared_library_rule($)
+sub _prepare_shared_library_rule($$)
{
- my $ctx = shift;
- my $output;
+ my ($self,$ctx) = @_;
my $tmpdepend = array2oneperline($ctx->{DEPEND_LIST});
my $tmpshlink = array2oneperline($ctx->{LINK_LIST});
my $tmpshflag = array2oneperline($ctx->{LINK_FLAGS});
- $output = << "__EOD__";
+ $self->output(<< "__EOD__"
LIBRARY_$ctx->{NAME}_DEPEND_LIST =$tmpdepend
LIBRARY_$ctx->{NAME}_SHARED_LINK_LIST =$tmpshlink
LIBRARY_$ctx->{NAME}_SHARED_LINK_FLAGS =$tmpshflag
@@ -420,9 +420,9 @@ $ctx->{TARGET}: \$(LIBRARY_$ctx->{NAME}_DEPEND_LIST) \$(LIBRARY_$ctx->{NAME}_OBJ
\$(LIBRARY_$ctx->{NAME}_SHARED_LINK_LIST)
__EOD__
-
+);
if (defined($ctx->{LIBRARY_SONAME})) {
- $output .= << "__EOD__";
+ $self->output(<< "__EOD__"
# Symlink $ctx->{LIBRARY_SONAME}
bin/$ctx->{LIBRARY_SONAME}: bin/$ctx->{LIBRARY_REALNAME} bin/.dummy
\@echo Symlink \$\@
@@ -433,48 +433,40 @@ bin/$ctx->{LIBRARY_NAME}: bin/$ctx->{LIBRARY_SONAME} bin/.dummy
\@ln -sf $ctx->{LIBRARY_SONAME} \$\@
__EOD__
+);
}
-$output .= << "__EOD__";
-library_$ctx->{NAME}: basics bin/lib$ctx->{LIBRARY_NAME}
-
-__EOD__
-
- return $output;
+ $self->output("library_$ctx->{NAME}: basics bin/lib$ctx->{LIBRARY_NAME}\n");
}
-sub _prepare_mergedobj_rule($)
+sub _prepare_mergedobj_rule($$)
{
- my $ctx = shift;
+ my ($self,$ctx) = @_;
return "" unless $ctx->{TARGET};
my $tmpdepend = array2oneperline($ctx->{DEPEND_LIST});
- my $output = "$ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST = $tmpdepend\n";
+ $self->output("$ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST = $tmpdepend\n");
- $output .= "$ctx->{TARGET}: \$($ctx->{TYPE}_$ctx->{NAME}_OBJS)\n";
+ $self->output("$ctx->{TARGET}: \$($ctx->{TYPE}_$ctx->{NAME}_OBJS)\n");
- $output .= "\t\@echo \"Pre-Linking $ctx->{TYPE} $ctx->{NAME}\"\n";
- $output .= "\t@\$(LD) -r \$($ctx->{TYPE}_$ctx->{NAME}_OBJS) -o $ctx->{TARGET}\n";
- $output .= "\n";
-
- return $output;
+ $self->output("\t\@echo \"Pre-Linking $ctx->{TYPE} $ctx->{NAME}\"\n");
+ $self->output("\t@\$(LD) -r \$($ctx->{TYPE}_$ctx->{NAME}_OBJS) -o $ctx->{TARGET}\n");
+ $self->output("\n");
}
-sub _prepare_objlist_rule($)
+sub _prepare_objlist_rule($$)
{
- my $ctx = shift;
+ my ($self,$ctx) = @_;
my $tmpdepend = array2oneperline($ctx->{DEPEND_LIST});
return "" unless $ctx->{TARGET};
- my $output = "$ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST = $tmpdepend\n";
- $output .= "$ctx->{TARGET}: ";
- $output .= "\$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_OBJS)\n";
- $output .= "\t\@touch $ctx->{TARGET}\n";
-
- return $output;
+ $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");
+ $self->output("\t\@touch $ctx->{TARGET}\n");
}
###########################################################
@@ -494,16 +486,15 @@ sub _prepare_objlist_rule($)
# $library_ctx->{LINK_FLAGS} - linker flags used by this static library
#
# $output - the resulting output buffer
-sub _prepare_static_library_rule($)
+sub _prepare_static_library_rule($$)
{
- my $ctx = shift;
- my $output;
+ my ($self,$ctx) = @_;
my $tmpdepend = array2oneperline($ctx->{DEPEND_LIST});
my $tmpstlink = array2oneperline($ctx->{LINK_LIST});
my $tmpstflag = array2oneperline($ctx->{LINK_FLAGS});
- $output = << "__EOD__";
+ $self->output(<< "__EOD__"
LIBRARY_$ctx->{NAME}_DEPEND_LIST =$tmpdepend
#
LIBRARY_$ctx->{NAME}_STATIC_LINK_LIST =$tmpstlink
@@ -516,8 +507,7 @@ $ctx->{TARGET}: \$(LIBRARY_$ctx->{NAME}_DEPEND_LIST) \$(LIBRARY_$ctx->{NAME}_OBJ
library_$ctx->{NAME}: basics $ctx->{TARGET}
__EOD__
-
- return $output;
+);
}
###########################################################
@@ -536,15 +526,15 @@ __EOD__
# $binary_ctx->{LINK_FLAGS} - linker flags used by this binary
#
# $output - the resulting output buffer
-sub _prepare_binary_rule($)
+sub _prepare_binary_rule($$)
{
- my $ctx = shift;
+ my ($self,$ctx) = @_;
my $tmpdepend = array2oneperline($ctx->{DEPEND_LIST});
my $tmplink = array2oneperline($ctx->{LINK_LIST});
my $tmpflag = array2oneperline($ctx->{LINK_FLAGS});
- my $output = << "__EOD__";
+ $self->output(<< "__EOD__"
#
BINARY_$ctx->{NAME}_DEPEND_LIST =$tmpdepend
BINARY_$ctx->{NAME}_LINK_LIST =$tmplink
@@ -559,14 +549,13 @@ bin/$ctx->{BINARY}: bin/.dummy \$(BINARY_$ctx->{NAME}_DEPEND_LIST) \$(BINARY_$ct
binary_$ctx->{BINARY}: basics bin/$ctx->{BINARY}
__EOD__
-
- return $output;
+);
}
sub _prepare_clean_rules($)
{
my ($self) = @_;
- my $output = << '__EOD__';
+ $self->output(<< '__EOD__'
clean: heimdal_clean
@echo Removing headers
@-rm -f include/proto.h
@@ -590,12 +579,12 @@ distclean: clean
-rm -f config.pm config.mk
-rm -f lib/registry/winregistry.pc
__EOD__
-
- if ($self->{config}->{developer} eq "yes") {
- $output .= "\t\@-rm -f \$(_ALL_OBJS_OBJS:.o=.d)\n";
+);
+ if ($self->{developer}) {
+ $self->output("\t\@-rm -f \$(_ALL_OBJS_OBJS:.o=.d)\n");
}
- $output .= << '__EOD__';
+ $self->output(<< '__EOD__'
removebackup:
-rm -f *.bak *~ */*.bak */*~ */*/*.bak */*/*~ */*/*/*.bak */*/*/*~
@@ -606,8 +595,7 @@ realdistclean: distclean removebackup
-rm -f configure
-rm -f $(MANPAGES)
__EOD__
-
- return $output;
+);
}
sub _prepare_make_target($)
@@ -617,45 +605,34 @@ sub _prepare_make_target($)
$tmpdepend = array2oneperline($ctx->{DEPEND_LIST});
- return << "__EOD__";
-$ctx->{TARGET}: basics $tmpdepend
-
-__EOD__
+ return "$ctx->{TARGET}: basics $tmpdepend\n";
}
sub _prepare_target_settings($$)
{
my ($self, $CTX) = @_;
- my $output = "";
foreach my $key (values %$CTX) {
if (defined($key->{OBJ_LIST})) {
- $output .= _prepare_obj_list($key->{TYPE}, $key);
- $output .= _prepare_cflags($key->{TYPE}, $key);
+ $self->output(_prepare_obj_list($key->{TYPE}, $key));
+ $self->output(_prepare_cflags($key->{TYPE}, $key));
}
}
-
- return $output;
}
sub _prepare_rule_lists($$)
{
my ($self,$depend) = @_;
- my $output = "";
foreach my $key (values %{$depend}) {
next unless defined $key->{OUTPUT_TYPE};
- ($output .= _prepare_mergedobj_rule($key)) if $key->{OUTPUT_TYPE} eq "MERGEDOBJ";
- ($output .= _prepare_objlist_rule($key)) if $key->{OUTPUT_TYPE} eq "OBJLIST";
- ($output .= _prepare_static_library_rule($key)) if $key->{OUTPUT_TYPE} eq "STATIC_LIBRARY";
- ($output .= _prepare_shared_library_rule($key)) if $key->{OUTPUT_TYPE} eq "SHARED_LIBRARY";
- ($output .= _prepare_binary_rule($key)) if $key->{OUTPUT_TYPE} eq "BINARY";
+ $self->_prepare_mergedobj_rule($key) if $key->{OUTPUT_TYPE} eq "MERGEDOBJ";
+ $self->_prepare_objlist_rule($key) if $key->{OUTPUT_TYPE} eq "OBJLIST";
+ $self->_prepare_static_library_rule($key) if $key->{OUTPUT_TYPE} eq "STATIC_LIBRARY";
+ $self->_prepare_shared_library_rule($key) if $key->{OUTPUT_TYPE} eq "SHARED_LIBRARY";
+ $self->_prepare_binary_rule($key) if $key->{OUTPUT_TYPE} eq "BINARY";
}
-
- $output .= _prepare_clean_rules($self);
-
- return $output;
}
###########################################################