package smb_build::makefile;
use smb_build::env;
+use File::Basename;
use strict;
use base 'smb_build::env';
+use Cwd 'abs_path';
sub new($$$)
{
$self->{manpages} = [];
$self->{sbin_progs} = [];
$self->{bin_progs} = [];
+ $self->{torture_progs} = [];
$self->{static_libs} = [];
+ $self->{python_dsos} = [];
$self->{shared_libs} = [];
$self->{installable_shared_libs} = [];
$self->{headers} = [];
$self->output("################################################\n");
$self->output("\n");
- if (!$self->{automatic_deps}) {
- $self->output("ALL_PREDEP = proto\n");
- }
-
$self->output("default: all\n\n");
$self->_prepare_path_vars();
+ $self->_prepare_suffix_rules();
$self->_prepare_compiler_linker();
+ if (!$self->{automatic_deps}) {
+ $self->output("ALL_PREDEP = proto\n");
+ $self->output(".NOTPARALLEL:\n");
+ }
+
return $self;
}
prefix = $self->{config}->{prefix}
exec_prefix = $self->{config}->{exec_prefix}
selftest_prefix = $self->{config}->{selftest_prefix}
-VPATH = $self->{config}->{srcdir}:heimdal/lib/asn1:heimdal/lib/krb5:heimdal/lib/gssapi:heimdal/lib/hdb
-srcdir = $self->{config}->{srcdir}
+
builddir = $self->{config}->{builddir}
+srcdir = $self->{config}->{srcdir}
+datarootdir = $self->{config}->{datarootdir}
+
+VPATH = \$(builddir):\$(srcdir):heimdal_build:heimdal/lib/asn1:heimdal/lib/krb5:heimdal/lib/gssapi:heimdal/lib/hdb:heimdal/lib/roken:heimdal/lib/des
BASEDIR = $self->{config}->{prefix}
BINDIR = $self->{config}->{bindir}
SBINDIR = $self->{config}->{sbindir}
LIBDIR = $self->{config}->{libdir}
+TORTUREDIR = $self->{config}->{libdir}/torture
MODULESDIR = $self->{config}->{modulesdir}
INCLUDEDIR = $self->{config}->{includedir}
CONFIGDIR = $self->{config}->{sysconfdir}
DATADIR = $self->{config}->{datadir}
-SWATDIR = $self->{config}->{datadir}/swat
-JSDIR = $self->{config}->{datadir}/js
-SETUPDIR = $self->{config}->{datadir}/setup
+SWATDIR = \$(DATADIR)/swat
+JSDIR = \$(DATADIR)/js
+SETUPDIR = \$(DATADIR)/setup
VARDIR = $self->{config}->{localstatedir}
LOGFILEBASE = $self->{config}->{logfilebase}
NCALRPCDIR = $self->{config}->{localstatedir}/ncalrpc
);
}
+sub _prepare_suffix_rules($)
+{
+ my ($self) = @_;
+ my $first_prereq = '$*.c';
+
+ if ($self->{config}->{GNU_MAKE} eq 'yes') {
+ $first_prereq = '$<';
+ }
+
+ $self->output(<< "__EOD__"
+FIRST_PREREQ = $first_prereq
+
+# Dependencies command
+DEPENDS = \$(CC) -M -MG -MP -MT \$(<:.c=.o) -MT \$@ \\
+ `\$(PERL) \$(srcdir)/script/cflags.pl \$@` \\
+ \$(CFLAGS) \$(FIRST_PREREQ) -o \$@
+# Dependencies for host objects
+HDEPENDS = \$(CC) -M -MG -MP -MT \$(<:.c=.ho) -MT \$@ \\
+ `\$(PERL) \$(srcdir)/script/cflags.pl \$@` \\
+ \$(HOSTCC_FLAGS) \$(FIRST_PREREQ) -o \$@
+# Dependencies for precompiled headers
+PCHDEPENDS = \$(CC) -M -MG -MT include/includes.h.gch -MT \$@ \\
+ \$(CFLAGS) \$(FIRST_PREREQ) -o \$@
+
+# \$< is broken in older BSD versions:
+# when \$@ is foo/bar.o, \$< could be torture/foo/bar.c
+# if it also exists. So better use \$* which is foo/bar
+# and append .c manually to get foo/bar.c
+#
+# If we have GNU Make, it is safe to use \$<, which also lets
+# building with \$srcdir != \$builddir work.
+
+# Run a static analysis checker
+CHECK = \$(CC_CHECKER) `\$(PERL) \$(srcdir)/script/cflags.pl \$@` \\
+ \$(CFLAGS) \$(PICFLAG) -c \$(FIRST_PREREQ) -o \$@
+
+# Run the configured compiler
+COMPILE = \$(CC) `\$(PERL) \$(srcdir)/script/cflags.pl \$@` \\
+ \$(CFLAGS) \$(PICFLAG) -c \$(FIRST_PREREQ) -o \$@
+
+# Run the compiler for the build host
+HCOMPILE = \$(HOSTCC) `\$(PERL) \$(srcdir)/script/cflags.pl \$@` \\
+ \$(HOSTCC_FLAGS) -c \$(FIRST_PREREQ) -o \$@
+
+# Precompile headers
+PCHCOMPILE = @\$(CC) -Ilib/replace \\
+ `\$(PERL) \$(srcdir)/script/cflags.pl \$@` \\
+ \$(CFLAGS) \$(PICFLAG) -c \$(FIRST_PREREQ) -o \$@
+
+__EOD__
+);
+}
+
sub _prepare_compiler_linker($)
{
my ($self) = @_;
- my $devld_local = "";
- my $devld_install = "";
+ my $builddir_headers = "";
+ my $libdir;
+ my $extra_link_flags = "";
- $self->{duplicate_build} = 0;
- if ($self->{config}->{LIBRARY_OUTPUT_TYPE} eq "SHARED_LIBRARY") {
- if ($self->{developer}) {
- $self->{duplicate_build} = 1;
- $devld_local = " -Wl,-rpath,\$(builddir)/bin";
- }
- $devld_install = " -Wl,-rpath-link,\$(builddir)/bin";
+ if ($self->{config}->{USESHARED} eq "true") {
+ $libdir = "\$(builddir)/bin/shared";
+ $extra_link_flags = "-Wl,-rpath-link,\$(builddir)/bin/shared";
+ } else {
+ $libdir = "\$(builddir)/bin/static";
+ }
+
+ if (!(abs_path($self->{config}->{srcdir}) eq abs_path($self->{config}->{builddir}))) {
+ $builddir_headers= "-I\$(builddir)/include -I\$(builddir) -I\$(builddir)/lib ";
}
$self->output(<< "__EOD__"
SHELL=$self->{config}->{SHELL}
PERL=$self->{config}->{PERL}
+PYTHON=$self->{config}->{PYTHON}
+SWIG=$self->{config}->{SWIG}
CPP=$self->{config}->{CPP}
-CPPFLAGS=$self->{config}->{CPPFLAGS}
+CPPFLAGS=$builddir_headers-I\$(srcdir)/include -I\$(srcdir) -I\$(srcdir)/lib -I\$(srcdir)/lib/replace -I\$(srcdir)/lib/talloc -D_SAMBA_BUILD_=4 -DHAVE_CONFIG_H $self->{config}->{CPPFLAGS}
CC=$self->{config}->{CC}
-CFLAGS=-I\$(srcdir)/include -I\$(srcdir) -I\$(srcdir)/lib -D_SAMBA_BUILD_ -DHAVE_CONFIG_H $self->{config}->{CFLAGS} \$(CPPFLAGS)
+CFLAGS=$self->{config}->{CFLAGS} \$(CPPFLAGS)
PICFLAG=$self->{config}->{PICFLAG}
-HOSTCC=$self->{config}->{HOSTCC}
-LOCAL_LINK_FLAGS=$devld_local
-INSTALL_LINK_FLAGS=$devld_install
+INSTALL_LINK_FLAGS=$extra_link_flags
-LD=$self->{config}->{LD}
-LDFLAGS=$self->{config}->{LDFLAGS} -L\$(builddir)/bin
+BNLD=$self->{config}->{LD}
+BNLD_FLAGS=$self->{config}->{LDFLAGS} -L$libdir
-STLD=$self->{config}->{AR}
-STLD_FLAGS=-rc -L\$(builddir)/bin
+STLD=$self->{config}->{STLD}
+STLD_FLAGS=$self->{config}->{STLD_FLAGS}
+
+SHLD=$self->{config}->{SHLD}
+SHLD_FLAGS=$self->{config}->{SHLD_FLAGS} -L\$(builddir)/bin/shared
+
+MDLD=$self->{config}->{MDLD}
+MDLD_FLAGS=$self->{config}->{MDLD_FLAGS} -L\$(builddir)/bin/shared
-SHLD=$self->{config}->{CC}
-SHLD_FLAGS=$self->{config}->{LDSHFLAGS} -L\$(builddir)/bin
SHLIBEXT=$self->{config}->{SHLIBEXT}
+HOSTCC=$self->{config}->{HOSTCC}
+HOSTCC_FLAGS=-D_SAMBA_HOSTCC_ $self->{config}->{CFLAGS} \$(CPPFLAGS)
+
+HOSTLD=$self->{config}->{HOSTLD}
+HOSTLD_FLAGS=$self->{config}->{LDFLAGS}
+
XSLTPROC=$self->{config}->{XSLTPROC}
LEX=$self->{config}->{LEX}
YACC=$self->{config}->{YACC}
YAPP=$self->{config}->{YAPP}
-PIDL_ARGS=$self->{config}->{PIDL_ARGS}
GCOV=$self->{config}->{GCOV}
-DEFAULT_TEST_TARGET=$self->{config}->{DEFAULT_TEST_TARGET}
+DEFAULT_TEST_OPTIONS=$self->{config}->{DEFAULT_TEST_OPTIONS}
__EOD__
);
my $self = shift;
my @tmp = ();
-
foreach (@smb_build::config_mk::parsed_files) {
s/ .*$//g;
push (@tmp, $_);
}
+ if ($self->{gnu_make}) {
+ $self->output("
+ifneq (\$(MAKECMDGOALS),clean)
+ifneq (\$(MAKECMDGOALS),distclean)
+ifneq (\$(MAKECMDGOALS),realdistclean)
+");
+ }
+
$self->output("MK_FILES = " . array2oneperline(\@tmp) . "\n");
+
+ if ($self->{gnu_make}) {
+ $self->output("
+endif
+endif
+endif
+");
+ }
}
sub array2oneperline($)
return $output;
}
-sub _prepare_list($$$)
+sub _prepare_list_ex($$$$$)
{
- my ($self,$ctx,$var) = @_;
+ my ($self,$ctx,$var,$pre,$post) = @_;
+ my @tmparr = ();
- my $tmplist = array2oneperline($ctx->{$var});
+ push(@tmparr, $pre) if defined($pre);
+ push(@tmparr, @{$ctx->{$var}}) if defined($ctx->{$var});
+ push(@tmparr, $post) if defined($post);
+
+ my $tmplist = array2oneperline(\@tmparr);
return if ($tmplist eq "");
$self->output("$ctx->{TYPE}\_$ctx->{NAME}_$var =$tmplist\n");
}
-sub SharedLibrary($$)
+sub _prepare_list($$$)
+{
+ my ($self,$ctx,$var) = @_;
+
+ $self->_prepare_list_ex($ctx, $var, undef, undef);
+}
+
+sub Integrated($$)
{
my ($self,$ctx) = @_;
- my $installdir;
- my $init_obj = "";
-
- if ($self->{duplicate_build}) {
- $installdir = $ctx->{RELEASEDIR};
- } else {
- $installdir = $ctx->{DEBUGDIR};
- }
+ $self->_prepare_list($ctx, "OBJ_LIST");
+ $self->_prepare_list($ctx, "FULL_OBJ_LIST");
+ $self->_prepare_list($ctx, "LINK_FLAGS");
+}
- if ($ctx->{TYPE} eq "LIBRARY") {
- push (@{$self->{shared_libs}}, "$ctx->{DEBUGDIR}/$ctx->{LIBRARY_REALNAME}");
- push (@{$self->{installable_shared_libs}}, "$installdir/$ctx->{LIBRARY_REALNAME}") if (defined($ctx->{SO_VERSION}));
- } elsif ($ctx->{TYPE} eq "MODULE") {
- push (@{$self->{shared_modules}}, "$ctx->{DEBUGDIR}/$ctx->{LIBRARY_REALNAME}");
- push (@{$self->{plugins}}, "$installdir/$ctx->{LIBRARY_REALNAME}");
+sub SharedModule($$)
+{
+ my ($self,$ctx) = @_;
- my $fixedname = $ctx->{NAME};
+ my $init_obj = "";
- $fixedname =~ s/^$ctx->{SUBSYSTEM}_//g;
+ my $sane_subsystem = lc($ctx->{SUBSYSTEM});
+ $sane_subsystem =~ s/^lib//;
+
+ if ($ctx->{TYPE} eq "PYTHON") {
+ push (@{$self->{python_dsos}},
+ "$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}");
+ }
- $self->{install_plugins} .= "\t\@echo Installing $installdir/$ctx->{LIBRARY_REALNAME} as \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/$fixedname.\$(SHLIBEXT)\n";
- $self->{install_plugins} .= "\t\@mkdir -p \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/\n";
- $self->{install_plugins} .= "\t\@cp $installdir/$ctx->{LIBRARY_REALNAME} \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/$fixedname.\$(SHLIBEXT)\n";
- $self->{uninstall_plugins} .= "\t\@echo Uninstalling \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/$fixedname.\$(SHLIBEXT)\n";
- $self->{uninstall_plugins} .= "\t\@-rm \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/$fixedname.\$(SHLIBEXT)\n";
+ push (@{$self->{shared_modules}}, "$ctx->{TARGET_SHARED_LIBRARY}");
+ push (@{$self->{plugins}}, "$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}");
+
+ $self->{install_plugins} .= "\t\@echo Installing $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME} as \$(DESTDIR)\$(MODULESDIR)/$sane_subsystem/$ctx->{LIBRARY_REALNAME}\n";
+ $self->{install_plugins} .= "\t\@mkdir -p \$(DESTDIR)\$(MODULESDIR)/$sane_subsystem/\n";
+ $self->{install_plugins} .= "\t\@cp $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME} \$(DESTDIR)\$(MODULESDIR)/$sane_subsystem/$ctx->{LIBRARY_REALNAME}\n";
+ $self->{uninstall_plugins} .= "\t\@echo Uninstalling \$(DESTDIR)\$(MODULESDIR)/$sane_subsystem/$ctx->{LIBRARY_REALNAME}\n";
+ $self->{uninstall_plugins} .= "\t\@-rm \$(DESTDIR)\$(MODULESDIR)/$sane_subsystem/$ctx->{LIBRARY_REALNAME}\n";
+ if (defined($ctx->{ALIASES})) {
+ foreach (@{$ctx->{ALIASES}}) {
+ $self->{install_plugins} .= "\t\@rm -f \$(DESTDIR)\$(MODULESDIR)/$sane_subsystem/$_.\$(SHLIBEXT)\n";
+ $self->{install_plugins} .= "\t\@ln -fs $ctx->{LIBRARY_REALNAME} \$(DESTDIR)\$(MODULESDIR)/$sane_subsystem/$_.\$(SHLIBEXT)\n";
+ $self->{uninstall_plugins} .= "\t\@-rm \$(DESTDIR)\$(MODULESDIR)/$sane_subsystem/$_.\$(SHLIBEXT)\n";
+ }
}
+ $self->output("$ctx->{TYPE}_$ctx->{NAME}_OUTPUT = $ctx->{OUTPUT}\n");
$self->_prepare_list($ctx, "OBJ_LIST");
- $self->_prepare_list($ctx, "CFLAGS");
+ $self->_prepare_list($ctx, "FULL_OBJ_LIST");
$self->_prepare_list($ctx, "DEPEND_LIST");
- $self->_prepare_list($ctx, "LINK_LIST");
$self->_prepare_list($ctx, "LINK_FLAGS");
- push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)");
+ push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)");
- if ($ctx->{TYPE} eq "MODULE" and defined($ctx->{INIT_FUNCTION})) {
+ if (defined($ctx->{INIT_FUNCTION})) {
my $init_fn = $ctx->{INIT_FUNCTION_TYPE};
$init_fn =~ s/\(\*\)/init_module/;
my $proto_fn = $ctx->{INIT_FUNCTION_TYPE};
\@echo Creating \$\@
\@echo \"#include \\\"includes.h\\\"\" > \$\@
\@echo \"$proto_fn;\" >> \$\@
- \@echo -e \"_PUBLIC_ $init_fn \\n{\\n\\treturn $ctx->{INIT_FUNCTION}();\\n}\\n\" >> \$\@
+ \@echo \"_PUBLIC_ $init_fn\" >> \$\@
+ \@echo \"{\" >> \$\@
+ \@echo \" return $ctx->{INIT_FUNCTION}();\" >> \$\@
+ \@echo \"}\" >> \$\@
+ \@echo \"\" >> \$\@
__EOD__
);
$init_obj = "bin/$ctx->{NAME}_init_module.o";
}
- my $soarg = "";
- my $soargdebug = "";
- if ($self->{config}->{SONAMEFLAG} ne "" and
- defined($ctx->{LIBRARY_SONAME})) {
- $soarg = "$self->{config}->{SONAMEFLAG}$ctx->{LIBRARY_SONAME} ";
- if ($ctx->{LIBRARY_REALNAME} ne $ctx->{LIBRARY_SONAME}) {
- $soargdebug = "\t\@ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{DEBUGDIR}/$ctx->{LIBRARY_SONAME}\n";
- }
- }
-
- if ($self->{duplicate_build}) {
- $self->output(<< "__EOD__"
-#
-
-$ctx->{TARGET}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST) $init_obj
- \@echo Linking \$\@
- \@mkdir -p $ctx->{DEBUGDIR}
- \@\$(SHLD) \$(SHLD_FLAGS) -o \$\@ \$(LOCAL_LINK_FLAGS) \\
- \$($ctx->{TYPE}_$ctx->{NAME}_LINK_FLAGS) $soarg \\
- $init_obj \$($ctx->{TYPE}_$ctx->{NAME}_LINK_LIST)
-$soargdebug
-__EOD__
-);
- }
-
$self->output(<< "__EOD__"
#
-$installdir/$ctx->{LIBRARY_REALNAME}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST) $init_obj
+$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST) $init_obj
\@echo Linking \$\@
- \@\$(SHLD) \$(SHLD_FLAGS) -o \$\@ \\
- \$($ctx->{TYPE}_$ctx->{NAME}_LINK_FLAGS) $soarg \\
- $init_obj \$($ctx->{TYPE}_$ctx->{NAME}_LINK_LIST)
-
+ \@mkdir -p $ctx->{SHAREDDIR}
+ \@\$(MDLD) \$(MDLD_FLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\
+ \$($ctx->{TYPE}_$ctx->{NAME}\_FULL_OBJ_LIST) $init_obj \\
+ \$($ctx->{TYPE}_$ctx->{NAME}_LINK_FLAGS)
__EOD__
);
+
+ if (defined($ctx->{ALIASES})) {
+ foreach (@{$ctx->{ALIASES}}) {
+ $self->output("\t\@rm -f $ctx->{SHAREDDIR}/$_.\$(SHLIBEXT)\n");
+ $self->output("\t\@ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$_.\$(SHLIBEXT)\n");
+ }
+ }
+ $self->output("\n");
}
-sub MergedObj($$)
+sub SharedLibrary($$)
{
my ($self,$ctx) = @_;
- return unless $ctx->{TARGET};
+ my $has_static_lib = 0;
- $self->_prepare_list($ctx, "OBJ_LIST");
- $self->_prepare_list($ctx, "CFLAGS");
+ push (@{$self->{shared_libs}}, "$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}") if (defined($ctx->{SO_VERSION}));
+ push (@{$self->{installable_shared_libs}}, "$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}") if (defined($ctx->{SO_VERSION}));
+
+ $has_static_lib = 1 if grep(/STATIC_LIBRARY/, @{$ctx->{OUTPUT_TYPE}});
+
+ if (not $has_static_lib) {
+ $self->output("$ctx->{TYPE}_$ctx->{NAME}_OUTPUT = $ctx->{OUTPUT}\n");
+ $self->_prepare_list($ctx, "OBJ_LIST");
+ $self->_prepare_list($ctx, "FULL_OBJ_LIST");
+ }
$self->_prepare_list($ctx, "DEPEND_LIST");
+ $self->_prepare_list($ctx, "LINK_FLAGS");
+# $self->_prepare_list_ex($ctx, "LINK_FLAGS", "-Wl,--whole-archive", "-Wl,--no-whole-archive");
- push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)");
-
- $self->output("$ctx->{TARGET}: \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)\n");
+ push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)");
- $self->output("\t\@echo \"Pre-Linking $ctx->{TYPE} $ctx->{NAME}\"\n");
- $self->output("\t@\$(LD) -r \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST) -o $ctx->{TARGET}\n");
- $self->output("\n");
-}
+ my $soarg = "";
+ my $lns = "";
+ if ($self->{config}->{SONAMEFLAG} ne "#" and defined($ctx->{LIBRARY_SONAME})) {
+ $soarg = "$self->{config}->{SONAMEFLAG}$ctx->{LIBRARY_SONAME}";
+ if ($ctx->{LIBRARY_REALNAME} ne $ctx->{LIBRARY_SONAME}) {
+ $lns .= "\n\t\@rm -f $ctx->{SHAREDDIR}/$ctx->{LIBRARY_SONAME}";
+ $lns .= "\n\t\@ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$ctx->{LIBRARY_SONAME}";
+ }
+ }
-sub ObjList($$)
-{
- my ($self,$ctx) = @_;
+ if (defined($ctx->{LIBRARY_SONAME})) {
+ $lns .= "\n\t\@rm -f $ctx->{SHAREDDIR}/$ctx->{LIBRARY_DEBUGNAME}";
+ $lns .= "\n\t\@ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$ctx->{LIBRARY_DEBUGNAME}";
+ }
- return unless $ctx->{TARGET};
+ $self->output(<< "__EOD__"
+#
- push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)");
-
- $self->_prepare_list($ctx, "OBJ_LIST");
- $self->_prepare_list($ctx, "CFLAGS");
- $self->_prepare_list($ctx, "DEPEND_LIST");
- $self->output("$ctx->{TARGET}: ");
- $self->output("\$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)\n");
- $self->output("\t\@touch $ctx->{TARGET}\n");
+$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)
+ \@echo Linking \$\@
+ \@mkdir -p $ctx->{SHAREDDIR}
+ \@\$(SHLD) \$(SHLD_FLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\
+ \$($ctx->{TYPE}_$ctx->{NAME}\_FULL_OBJ_LIST) \\
+ \$($ctx->{TYPE}_$ctx->{NAME}_LINK_FLAGS) \\
+ $soarg$lns
+__EOD__
+);
+ $self->output("\n");
}
sub StaticLibrary($$)
{
my ($self,$ctx) = @_;
- push (@{$self->{static_libs}}, $ctx->{OUTPUT});
+ return unless (defined($ctx->{OBJ_FILES}));
+ push (@{$self->{static_libs}}, $ctx->{TARGET_STATIC_LIBRARY}) if ($ctx->{TYPE} eq "LIBRARY");
+
+ $self->output("$ctx->{TYPE}_$ctx->{NAME}_OUTPUT = $ctx->{OUTPUT}\n");
$self->_prepare_list($ctx, "OBJ_LIST");
- $self->_prepare_list($ctx, "CFLAGS");
+ $self->_prepare_list($ctx, "FULL_OBJ_LIST");
- $self->_prepare_list($ctx, "DEPEND_LIST");
- $self->_prepare_list($ctx, "LINK_LIST");
- $self->_prepare_list($ctx, "LINK_FLAGS");
+ push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)");
- push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)");
-
$self->output(<< "__EOD__"
#
-$ctx->{TARGET}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)
+$ctx->{TARGET_STATIC_LIBRARY}: \$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)
\@echo Linking \$@
- \@\$(STLD) \$(STLD_FLAGS) \$@ \\
- \$($ctx->{TYPE}_$ctx->{NAME}_LINK_LIST)
+ \@rm -f \$@
+ \@mkdir -p $ctx->{STATICDIR}
+ \@\$(STLD) \$(STLD_FLAGS) \$@ \$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)
__EOD__
);
{
my ($self,$ctx) = @_;
+ my $dir = $ctx->{BASEDIR};
+
+ $dir =~ s/^\.\///g;
+
foreach (@{$ctx->{PUBLIC_HEADERS}}) {
- push (@{$self->{headers}}, "$ctx->{BASEDIR}/$_");
+ push (@{$self->{headers}}, "$dir/$_");
}
}
my ($self,$ctx) = @_;
my $installdir;
-
- if ($self->{duplicate_build}) {
- $installdir = "bin/install";
- } else {
- $installdir = "bin";
+ my $extradir = "";
+
+ if (defined($ctx->{INSTALLDIR}) && $ctx->{INSTALLDIR} =~ /^TORTUREDIR/) {
+ $extradir = "/torture" . substr($ctx->{INSTALLDIR}, length("TORTUREDIR"));
}
+ my $localdir = "bin$extradir";
- push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)");
+ $installdir = "bin$extradir";
+
+ push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)");
unless (defined($ctx->{INSTALLDIR})) {
} elsif ($ctx->{INSTALLDIR} eq "SBINDIR") {
push (@{$self->{sbin_progs}}, "$installdir/$ctx->{BINARY}");
} elsif ($ctx->{INSTALLDIR} eq "BINDIR") {
push (@{$self->{bin_progs}}, "$installdir/$ctx->{BINARY}");
+ } elsif ($ctx->{INSTALLDIR} =~ /^TORTUREDIR/) {
+ push (@{$self->{torture_progs}}, "$installdir/$ctx->{BINARY}");
}
- push (@{$self->{binaries}}, "bin/$ctx->{BINARY}");
+
+ push (@{$self->{binaries}}, "$localdir/$ctx->{BINARY}");
$self->_prepare_list($ctx, "OBJ_LIST");
- $self->_prepare_list($ctx, "CFLAGS");
+ $self->_prepare_list($ctx, "FULL_OBJ_LIST");
$self->_prepare_list($ctx, "DEPEND_LIST");
- $self->_prepare_list($ctx, "LINK_LIST");
$self->_prepare_list($ctx, "LINK_FLAGS");
- if ($self->{duplicate_build}) {
- $self->output(<< "__EOD__"
-#
-bin/$ctx->{BINARY}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)
+$self->output(<< "__EOD__"
+$installdir/$ctx->{BINARY}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)
\@echo Linking \$\@
- \@\$(CC) \$(LDFLAGS) -o \$\@ \$(LOCAL_LINK_FLAGS) \$(INSTALL_LINK_FLAGS) \\
- \$\($ctx->{TYPE}_$ctx->{NAME}_LINK_LIST) \\
+__EOD__
+ );
+
+ if (defined($ctx->{USE_HOSTCC}) && $ctx->{USE_HOSTCC} eq "YES") {
+ $self->output(<< "__EOD__"
+ \@\$(HOSTLD) \$(HOSTLD_FLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\
+ \$\($ctx->{TYPE}_$ctx->{NAME}_LINK_FLAGS)
+__EOD__
+ );
+ } else {
+ $self->output(<< "__EOD__"
+ \@\$(BNLD) \$(BNLD_FLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\
\$\($ctx->{TYPE}_$ctx->{NAME}_LINK_FLAGS)
__EOD__
-);
+ );
}
+}
-$self->output(<< "__EOD__"
-$installdir/$ctx->{BINARY}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)
- \@echo Linking \$\@
- \@\$(CC) \$(LDFLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\
- \$\($ctx->{TYPE}_$ctx->{NAME}_LINK_LIST) \\
- \$\($ctx->{TYPE}_$ctx->{NAME}_LINK_FLAGS)
+sub PythonFiles($$)
+{
+ my ($self,$ctx) = @_;
-__EOD__
-);
+ foreach (@{$ctx->{PYTHON_FILES}}) {
+ my $target = "bin/python/".basename($_);
+ $self->output("$target: $ctx->{BASEDIR}/$_\n" .
+ "\tcp $ctx->{BASEDIR}/$_ \$@\n\n");
+ push (@{$self->{python_dsos}}, $target);
+ }
}
sub Manpage($$)
push (@{$self->{manpages}}, "$dir/$ctx->{MANPAGE}");
}
-sub PkgConfig($$)
+sub PkgConfig($$$)
{
- my ($self,$ctx) = @_;
+ my ($self,$ctx,$other) = @_;
my $link_name = $ctx->{NAME};
push (@{$self->{pc_files}}, $path);
+ my $pubs;
+ my $privs;
+ my $privlibs;
+
+ if (defined($ctx->{PUBLIC_DEPENDENCIES})) {
+ foreach (@{$ctx->{PUBLIC_DEPENDENCIES}}) {
+ next if ($other->{$_}->{ENABLE} eq "NO");
+ if ($other->{$_}->{TYPE} eq "LIBRARY") {
+ s/^LIB//g;
+ $_ = lc($_);
+
+ $pubs .= "$_ ";
+ } else {
+ s/^LIB//g;
+ $_ = lc($_);
+
+ $privlibs .= "-l$_ ";
+ }
+ }
+ }
+
+ if (defined($ctx->{PRIVATE_DEPENDENCIES})) {
+ foreach (@{$ctx->{PRIVATE_DEPENDENCIES}}) {
+ next if ($other->{$_}->{ENABLE} eq "NO");
+ if ($other->{$_}->{TYPE} eq "LIBRARY") {
+ s/^LIB//g;
+ $_ = lc($_);
+
+ $privs .= "$_ ";
+ } else {
+ s/^LIB//g;
+ $_ = lc($_);
+
+ $privlibs .= "-l$_ ";
+ }
+ }
+ }
+
smb_build::env::PkgConfig($self,
$path,
$link_name,
- "-l$link_name",
+ "-L\${libdir} -l$link_name",
+ $privlibs,
"",
"$ctx->{VERSION}",
$ctx->{DESCRIPTION},
- defined($ctx->{INIT_FUNCTIONS})
+ defined($ctx->{INIT_FUNCTIONS}),
+ $pubs,
+ "",
+ [
+ "prefix=$self->{config}->{prefix}",
+ "exec_prefix=$self->{config}->{exec_prefix}",
+ "libdir=$self->{config}->{libdir}",
+ "includedir=$self->{config}->{includedir}"
+ ]
+ );
+ my $abs_srcdir = abs_path($self->{config}->{srcdir});
+ smb_build::env::PkgConfig($self,
+ "bin/pkgconfig/$link_name-uninstalled.pc",
+ $link_name,
+ "-Lbin/shared -Lbin/static -l$link_name",
+ $privlibs,
+ join(' ',
+ "-I$abs_srcdir",
+ "-I$abs_srcdir/include",
+ "-I$abs_srcdir/lib",
+ "-I$abs_srcdir/lib/replace"),
+ "$ctx->{VERSION}",
+ $ctx->{DESCRIPTION},
+ defined($ctx->{INIT_FUNCTIONS}),
+ $pubs,
+ $privs,
+ [
+ "prefix=bin/",
+ "includedir=$ctx->{BASEDIR}"
+ ]
);
}
$ctx->{PUBLIC_PROTO_HEADER} = $ctx->{PRIVATE_PROTO_HEADER};
}
- $self->output("$dir/$ctx->{PUBLIC_PROTO_HEADER}: \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST:.o=.c)\n");
+ $self->output("$dir/$ctx->{PUBLIC_PROTO_HEADER}: $ctx->{MK_FILE} \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST:.o=.c) \$(srcdir)/script/mkproto.pl\n");
$self->output("\t\@echo \"$comment\"\n");
- $self->output("\t\@\$(PERL) \$(srcdir)/script/mkproto.pl --private=$dir/$ctx->{PRIVATE_PROTO_HEADER} --public=$dir/$ctx->{PUBLIC_PROTO_HEADER} \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)\n\n");
+ $self->output("\t\@\$(PERL) \$(srcdir)/script/mkproto.pl --srcdir=\$(srcdir) --builddir=\$(builddir) --private=$dir/$ctx->{PRIVATE_PROTO_HEADER} --public=$dir/$ctx->{PUBLIC_PROTO_HEADER} \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)\n\n");
}
sub write($$)
$self->output("MANPAGES = ".array2oneperline($self->{manpages})."\n");
$self->output("BIN_PROGS = " . array2oneperline($self->{bin_progs}) . "\n");
$self->output("SBIN_PROGS = " . array2oneperline($self->{sbin_progs}) . "\n");
+ $self->output("TORTURE_PROGS = " . array2oneperline($self->{torture_progs}) . "\n");
$self->output("BINARIES = " . array2oneperline($self->{binaries}) . "\n");
$self->output("STATIC_LIBS = " . array2oneperline($self->{static_libs}) . "\n");
$self->output("SHARED_LIBS = " . array2oneperline($self->{shared_libs}) . "\n");
+ $self->output("PYTHON_DSOS = " . array2oneperline($self->{python_dsos}) . "\n");
$self->output("INSTALLABLE_SHARED_LIBS = " . array2oneperline($self->{installable_shared_libs}) . "\n");
$self->output("PUBLIC_HEADERS = " . array2oneperline($self->{headers}) . "\n");
$self->output("PC_FILES = " . array2oneperline($self->{pc_files}) . "\n");
$self->output("\ninstallplugins: \$(PLUGINS)\n".$self->{install_plugins}."\n");
$self->output("\nuninstallplugins:\n".$self->{uninstall_plugins}."\n");
- # nasty hack to allow running locally
- if ($self->{duplicate_build}) {
- $self->output("bin/libdynconfig.\$(SHLIBEXT).0.0.1: dynconfig-devel.o\n");
- $self->output("bin/libdynconfig.\$(SHLIBEXT).0.0.1: LIBRARY_DYNCONFIG_OBJ_LIST=dynconfig-devel.o\n");
- }
-
$self->_prepare_mk_files();
$self->output($self->{mkfile});
ifneq (\$(MAKECMDGOALS),clean)
ifneq (\$(MAKECMDGOALS),distclean)
ifneq (\$(MAKECMDGOALS),realdistclean)
+ifneq (\$(SKIP_DEP_FILES),yes)
-include \$(DEP_FILES)
endif
endif
endif
+endif
+
+ifneq (\$(SKIP_DEP_FILES),yes)
+clean::
+ \@echo Removing dependency files
+ \@find . -name '*.d' -o -name '*.hd' | xargs rm -f
+endif
");
} else {
- $self->output("include static_deps.mk\n");
+ $self->output("include \$(srcdir)/static_deps.mk\n");
}
open(MAKEFILE,">$file") || die ("Can't open $file\n");