summaryrefslogtreecommitdiff
path: root/source4/build/smb_build/makefile.pm
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-10-21 21:43:39 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:45:08 -0500
commitc396fec407a46357cc534ee2334f0306c51a7245 (patch)
tree0031b54361a2a16508dc171ddfd058b2fba9a002 /source4/build/smb_build/makefile.pm
parente0370ff3bc4df9812cae058101c44879b127f997 (diff)
downloadsamba-c396fec407a46357cc534ee2334f0306c51a7245.tar.gz
samba-c396fec407a46357cc534ee2334f0306c51a7245.tar.bz2
samba-c396fec407a46357cc534ee2334f0306c51a7245.zip
r11252: Make makefile.pm OO and descend from env
(This used to be commit c53b32e0932ef6c048f8aec23ec6df2fe66a7887)
Diffstat (limited to 'source4/build/smb_build/makefile.pm')
-rw-r--r--source4/build/smb_build/makefile.pm242
1 files changed, 121 insertions, 121 deletions
diff --git a/source4/build/smb_build/makefile.pm b/source4/build/smb_build/makefile.pm
index 6f0cf6e189..1b8fcb7c6b 100644
--- a/source4/build/smb_build/makefile.pm
+++ b/source4/build/smb_build/makefile.pm
@@ -7,37 +7,88 @@
### Released under the GNU GPL ###
###########################################################
-package makefile;
+package smb_build::makefile;
+use smb_build::env;
use strict;
+use base 'smb_build::env';
+
+sub new($$$$)
+{
+ my ($myname, $config, $CTX, $mkfile) = @_;
+ my $self = new smb_build::env($config);
+
+ 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->_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);
+
+ if ($self->{config}->{developer} eq "yes") {
+ $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;
+
+ return $self;
+}
+
sub _prepare_path_vars($)
{
- my ($env) = @_;
+ my ($self) = @_;
my $output;
$output = << "__EOD__";
-prefix = $env->{config}->{prefix}
-exec_prefix = $env->{config}->{exec_prefix}
-selftest_prefix = $env->{config}->{selftest_prefix}
-VPATH = $env->{config}->{srcdir}
-srcdir = $env->{config}->{srcdir}
-builddir = $env->{config}->{builddir}
-
-BASEDIR = $env->{config}->{prefix}
-BINDIR = $env->{config}->{bindir}
-SBINDIR = $env->{config}->{sbindir}
-datadir = $env->{config}->{datadir}
-LIBDIR = $env->{config}->{libdir}
-CONFIGDIR = $env->{config}->{configdir}
-localstatedir = $env->{config}->{localstatedir}
-SWATDIR = $env->{config}->{swatdir}
-VARDIR = $env->{config}->{localstatedir}
-LOGFILEBASE = $env->{config}->{logfilebase}
-NCALRPCDIR = $env->{config}->{localstatedir}/ncalrpc
-LOCKDIR = $env->{config}->{lockdir}
-PIDDIR = $env->{config}->{piddir}
-MANDIR = $env->{config}->{mandir}
-PRIVATEDIR = $env->{config}->{privatedir}
+prefix = $self->{config}->{prefix}
+exec_prefix = $self->{config}->{exec_prefix}
+selftest_prefix = $self->{config}->{selftest_prefix}
+VPATH = $self->{config}->{srcdir}
+srcdir = $self->{config}->{srcdir}
+builddir = $self->{config}->{builddir}
+
+BASEDIR = $self->{config}->{prefix}
+BINDIR = $self->{config}->{bindir}
+SBINDIR = $self->{config}->{sbindir}
+datadir = $self->{config}->{datadir}
+LIBDIR = $self->{config}->{libdir}
+CONFIGDIR = $self->{config}->{configdir}
+localstatedir = $self->{config}->{localstatedir}
+SWATDIR = $self->{config}->{swatdir}
+VARDIR = $self->{config}->{localstatedir}
+LOGFILEBASE = $self->{config}->{logfilebase}
+NCALRPCDIR = $self->{config}->{localstatedir}/ncalrpc
+LOCKDIR = $self->{config}->{lockdir}
+PIDDIR = $self->{config}->{piddir}
+MANDIR = $self->{config}->{mandir}
+PRIVATEDIR = $self->{config}->{privatedir}
__EOD__
@@ -65,42 +116,42 @@ __EOD__
sub _prepare_compiler_linker($)
{
- my ($env) = @_;
+ my ($self) = @_;
return << "__EOD__";
-SHELL=$env->{config}->{SHELL}
+SHELL=$self->{config}->{SHELL}
-PERL=$env->{config}->{PERL}
+PERL=$self->{config}->{PERL}
-CC=$env->{config}->{CC}
-CFLAGS=-I\$(srcdir)/include -I\$(srcdir) -I\$(srcdir)/lib -D_SAMBA_BUILD_ -DHAVE_CONFIG_H $env->{config}->{CFLAGS} $env->{config}->{CPPFLAGS}
-PICFLAG=$env->{config}->{PICFLAG}
-HOSTCC=$env->{config}->{HOSTCC}
+CC=$self->{config}->{CC}
+CFLAGS=-I\$(srcdir)/include -I\$(srcdir) -I\$(srcdir)/lib -D_SAMBA_BUILD_ -DHAVE_CONFIG_H $self->{config}->{CFLAGS} $self->{config}->{CPPFLAGS}
+PICFLAG=$self->{config}->{PICFLAG}
+HOSTCC=$self->{config}->{HOSTCC}
-CPP=$env->{config}->{CPP}
-CPPFLAGS=$env->{config}->{CPPFLAGS}
+CPP=$self->{config}->{CPP}
+CPPFLAGS=$self->{config}->{CPPFLAGS}
-LD=$env->{config}->{LD}
-LD_FLAGS=$env->{config}->{LDFLAGS}
+LD=$self->{config}->{LD}
+LD_FLAGS=$self->{config}->{LDFLAGS}
-STLD=$env->{config}->{AR}
+STLD=$self->{config}->{AR}
STLD_FLAGS=-rc
-SHLD=$env->{config}->{CC}
-SHLD_FLAGS=$env->{config}->{LDSHFLAGS}
-SONAMEFLAG=$env->{config}->{SONAMEFLAG}
-SHLIBEXT=$env->{config}->{SHLIBEXT}
+SHLD=$self->{config}->{CC}
+SHLD_FLAGS=$self->{config}->{LDSHFLAGS}
+SONAMEFLAG=$self->{config}->{SONAMEFLAG}
+SHLIBEXT=$self->{config}->{SHLIBEXT}
-XSLTPROC=$env->{config}->{XSLTPROC}
+XSLTPROC=$self->{config}->{XSLTPROC}
-LEX=$env->{config}->{LEX}
-YACC=$env->{config}->{YACC}
-YAPP=$env->{config}->{YAPP}
-PIDL_ARGS=$env->{config}->{PIDL_ARGS}
+LEX=$self->{config}->{LEX}
+YACC=$self->{config}->{YACC}
+YAPP=$self->{config}->{YAPP}
+PIDL_ARGS=$self->{config}->{PIDL_ARGS}
-GCOV=$env->{config}->{GCOV}
+GCOV=$self->{config}->{GCOV}
-DEFAULT_TEST_TARGET=$env->{config}->{DEFAULT_TEST_TARGET}
+DEFAULT_TEST_TARGET=$self->{config}->{DEFAULT_TEST_TARGET}
__EOD__
}
@@ -121,9 +172,9 @@ sub _prepare_SUFFIXES()
__EOD__
}
-sub _prepare_man_rule($)
+sub _prepare_man_rule($$)
{
- my $suffix = shift;
+ my ($self, $suffix) = @_;
return << "__EOD__";
.$suffix.xml.$suffix:
@@ -132,8 +183,9 @@ sub _prepare_man_rule($)
__EOD__
}
-sub _prepare_config_status()
+sub _prepare_config_status($)
{
+ my $self = shift;
my @parsed_files = @smb_build::config_mk::parsed_files;
my $deps = "";
@@ -150,9 +202,9 @@ Makefile: config.status $deps
";
}
-sub _prepare_binaries($)
+sub _prepare_binaries($$)
{
- my $ctx = shift;
+ my ($self, $ctx) = @_;
my @bbn_list = ();
my @sbn_list = ();
@@ -175,9 +227,9 @@ SBIN_PROGS = $sbn
__EOD__
}
-sub _prepare_manpages($)
+sub _prepare_manpages($$)
{
- my $ctx = shift;
+ my ($self, $ctx) = @_;
my @mp_list = ();
@@ -197,7 +249,7 @@ __EOD__
sub _prepare_dummy_MAKEDIR($$)
{
- my ($env,$ctx) = @_;
+ my ($self,$ctx) = @_;
my $ret = << '__EOD__';
bin/.dummy:
@@ -207,7 +259,7 @@ dynconfig.o: dynconfig.c Makefile
@echo Compiling $*.c
@$(CC) $(CFLAGS) $(PICFLAG) $(PATH_FLAGS) -c $< -o $@
__EOD__
- if ($env->{config}->{BROKEN_CC} eq "yes") {
+ if ($self->{config}->{BROKEN_CC} eq "yes") {
$ret .= ' -mv `echo $@ | sed \'s%^.*/%%g\'` $@
';
}
@@ -243,7 +295,7 @@ __EOD__
# $output - the resulting output buffer
sub _prepare_std_CC_rule($$$$$$)
{
- my ($env,$src,$dst,$flags,$message,$comment) = @_;
+ my ($self,$src,$dst,$flags,$message,$comment) = @_;
my $ret = << "__EOD__";
# $comment
@@ -251,7 +303,7 @@ sub _prepare_std_CC_rule($$$$$$)
\@echo $message \$\*.$src
\@\$(CC) `script/cflags.sh \$\@` \$(CFLAGS) $flags -c \$< -o \$\@
__EOD__
- if ($env->{config}->{BROKEN_CC} eq "yes") {
+ if ($self->{config}->{BROKEN_CC} eq "yes") {
$ret.= ' -mv `echo $@ | sed \'s%^.*/%%g\'` $@
';
}
@@ -260,14 +312,14 @@ __EOD__
sub _prepare_hostcc_rule($)
{
- my ($env) = @_;
+ my ($self) = @_;
my $ret = << "__EOD__";
.c.ho:
\@echo Compiling \$\*.c with host compiler
\@\$(HOSTCC) `script/cflags.sh \$\@` \$(CFLAGS) -c \$< -o \$\@
__EOD__
- if ($env->{config}->{BROKEN_CC} eq "yes") {
+ if ($self->{config}->{BROKEN_CC} eq "yes") {
$ret .= ' -mv `echo $@ | sed \'s%^.*/%%g\' -e \'s%\.ho$$%.o%\'` $@
';
}
@@ -525,7 +577,7 @@ bin/.TARGET_$ctx->{NAME}:
sub _prepare_clean_rules($)
{
- my ($env) = @_;
+ my ($self) = @_;
my $output = << '__EOD__';
clean: heimdal_clean
@echo Removing headers
@@ -551,7 +603,7 @@ distclean: clean
-rm -f lib/registry/winregistry.pc
__EOD__
- if ($env->{config}->{developer} eq "yes") {
+ if ($self->{config}->{developer} eq "yes") {
$output .= "\t\@-rm -f \$(_ALL_OBJS_OBJS:.o=.d)\n";
}
@@ -583,9 +635,9 @@ $ctx->{TARGET}: basics $tmpdepend
__EOD__
}
-sub _prepare_target_settings($)
+sub _prepare_target_settings($$)
{
- my $CTX = shift;
+ my ($self, $CTX) = @_;
my $output = "";
foreach my $key (values %$CTX) {
@@ -600,7 +652,7 @@ sub _prepare_target_settings($)
sub _prepare_rule_lists($$)
{
- my ($env,$depend) = @_;
+ my ($self,$depend) = @_;
my $output = "";
foreach my $key (values %{$depend}) {
@@ -614,59 +666,7 @@ sub _prepare_rule_lists($$)
($output .= _prepare_custom_rule($key) ) if $key->{TYPE} eq "TARGET";
}
- $output .= _prepare_clean_rules($env);
-
- return $output;
-}
-
-###########################################################
-# This function prepares the output for Makefile
-#
-# $output = _prepare_makefile($OUTPUT)
-#
-# $OUTPUT - the global OUTPUT context
-#
-# $output - the resulting output buffer
-sub _prepare_makefile($$)
-{
- my ($env,$CTX) = @_;
- my $output;
-
- $output = "############################################\n";
- $output .= "# Autogenerated by build/smb_build/main.pl #\n";
- $output .= "############################################\n";
- $output .= "\n";
-
- $output .= _prepare_path_vars($env);
- $output .= _prepare_compiler_linker($env);
- $output .= _prepare_default_rule();
- $output .= _prepare_SUFFIXES();
- $output .= _prepare_dummy_MAKEDIR($env, $CTX);
- $output .= _prepare_hostcc_rule($env);
- $output .= _prepare_std_CC_rule($env, "c","o",'$(PICFLAG)',"Compiling","Rule for std objectfiles");
- $output .= _prepare_std_CC_rule($env, "h","h.gch",'$(PICFLAG)',"Precompiling","Rule for precompiled headerfiles");
-
- $output .= _prepare_depend_CC_rule();
-
- $output .= _prepare_man_rule("1");
- $output .= _prepare_man_rule("3");
- $output .= _prepare_man_rule("5");
- $output .= _prepare_man_rule("7");
- $output .= _prepare_manpages($CTX);
- $output .= _prepare_binaries($CTX);
- $output .= _prepare_target_settings($CTX);
- $output .= _prepare_rule_lists($env, $CTX);
- $output .= _prepare_config_status();
-
- if ($env->{config}->{developer} eq "yes") {
- $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__
- }
+ $output .= _prepare_clean_rules($self);
return $output;
}
@@ -680,12 +680,12 @@ __EOD__
# $OUTPUT - the global OUTPUT context
#
# $output - the resulting output buffer
-sub create_makefile($$$$)
+sub write($$)
{
- my ($CTX, $env, $mk, $file) = @_;
+ my ($self,$file) = @_;
open(MAKEFILE,">$file") || die ("Can't open $file\n");
- print MAKEFILE _prepare_makefile($env, $CTX) . $mk;
+ print MAKEFILE $self->{output};
close(MAKEFILE);
print "build/smb_build/main.pl: creating $file\n";