wmi-1.3.16 from opsview.com

This commit is contained in:
Are Casilla
2019-02-16 00:16:52 +01:00
parent 163fdd3d1b
commit 17b3af2911
2146 changed files with 678824 additions and 0 deletions
+86
View File
@@ -0,0 +1,86 @@
The Samba Build System
----------------------
----------------------
The build system basically has two main parts: the autoconf-generated
shell scripts which check for availability of functions and libraries
which is stored in the .m4 files and the information about the various
subsystems which is stored in the .mk files.
Object Types
------------
the build system knows about the following object types
SUBSYSTEM:
a SUBSYSTEM is basicly a collection of functions, which provide an
an generic API for a specific problem (e.g. libldb provides an api
for gneric ldb databases. libldb_plugin provides a generic api
for calling ldb plugins, so 'libldb' and 'libldb_plugin' are subsystems)
MODULE:
a MODULE is a specify implementation of a API provided by a SUBSYSTEM.
(e.g. 'libldb_tdb' and 'libldb_ldap' are implementations of the subsystem 'libldb' API,
and 'libldb_plugin_timestamp' is a module of the 'libldb_plugin' subsystem)
EXT_LIB:
an EXT_LIB is an external library which is needed by a SUBSYSTEM, MODULE, BINARY or LIBRARY.
(e.g. 'gtk' or 'KRB5')
BINARY:
a BINARY means a executable binary file.
(e.g. 'smbtorture' or 'ldbedit')
a BINARY typicly has only commandline handling and basic
functionality code in it and depends on the functions of
SUBSYSTEM's (REQUIRED_SUBSYSTEMS).
LIBRARY:
a LIBRARY means a static and/or shared library,
which depends on the used OS.
(e.g. for libldb 'libldb.so', 'libldb.so.0' 'libldb.so.0.0.1'
and libldb.a are created on linux)
a LIBRARY typicly has only glue code in it and depends on
SUBSYSTEM's (REQUIRED_SUBSYSTEMS).
File summary:
-------------
public.m4 - public M4 macros of the build system
config_mk.pm - Support for reading .mk files
dot.pm - Support for generating .dot files for analysis of dependencies
input.pm - Input validation
main.pm - Main
makefile.pm - Makefile generation
output.pm - Dependency calculation
header.pm - build.h generation
cflags.pm - Generates cflags.txt for file-specific cflags
Layout
-------
Toplevel file: configure.in
- included by autogen.sh: aclocal.m4
which includes the SMB_YXZ*() macros
- default tests of the build system
are in build/smb_build/check_*.m4
(mostly compiler and basic C type and function
checks)
- subsystem specific stuff should be included by 'SMB_INCLUDE_M4()'
Generating the configure file
-------------------------
you need to rerun ./autogen.sh when 'configure.in' or any
'.m4' file was modified, then you need to rerun configure.
Generating config.status
-----------------------------
you need to run ./config.status (or 'configure') after a '.mk'
file was changed.
Examples
--------
for now please take a look at the .m4 and .mk files
you find in the source tree, they should be a good reference to start.
+25
View File
@@ -0,0 +1,25 @@
- use pkg-config files in the buildsystem?
- let the build system implement some make functions($(patsubst),$(wildcard),...) and use our own implementations where `make' does not support them
- include extra_flags.txt using Makefile construction if
supported by current make
- fix shared module loading for selftest during builds without install
- remove recursive dependency between LIBSOCKET, LIBCLI_NBT and LIBCLI_RESOLVE
- clearer distinction between dcerpc and ndr. seperate interface tables? Maybe get rid of
NDR's table altogether and use dlopen/dlsym ?
- saner names for:
libcli.so.0.0.1 (rename to libsmb?)
libcli_cldap.so.0.0.1 (rename to libcldap?)
libcli_nbt.so.0.0.1 (rename to libnbt?)
libcli_wrepl.so.0.0.1 (rename to libwrepl?)
- generate headermap.txt
set of test scripts that check the code:
- configure_check_unused.pl
- find_unused_macros.pl
- find_unused_makefilevars.pl
- find_unused_options.sh
- findstatic.pl
- minimal_includes.pl
- check dependencies based on #include lines ?
- check whether private headers are not used outside their own subsystem
- undocumented (no manpage) installed binaries
+35
View File
@@ -0,0 +1,35 @@
# SMB Build System
#
# Copyright (C) Jelmer Vernooij 2006
# Released under the GNU GPL
package cflags;
use strict;
sub create_cflags($$)
{
my ($CTX, $file) = @_;
open(CFLAGS_TXT,">$file") || die ("Can't open `$file'\n");
foreach my $key (values %{$CTX}) {
next unless defined ($key->{OBJ_LIST});
next unless defined ($key->{FINAL_CFLAGS});
next unless ($#{$key->{FINAL_CFLAGS}} >= 0);
my $cflags = join(' ', @{$key->{FINAL_CFLAGS}});
foreach (@{$key->{OBJ_LIST}}) {
my $ofile = $_;
my $dfile = $_;
$dfile =~ s/\.o$/.d/;
$dfile =~ s/\.ho$/.d/;
print CFLAGS_TXT "$ofile $dfile: CFLAGS+= $cflags\n";
}
}
close(CFLAGS_TXT);
print __FILE__.": creating $file\n";
}
1;
+263
View File
@@ -0,0 +1,263 @@
# Samba Build System
# - config.mk parsing functions
#
# Copyright (C) Stefan (metze) Metzmacher 2004
# Copyright (C) Jelmer Vernooij 2005
# Released under the GNU GPL
#
package smb_build::config_mk;
use smb_build::input;
use File::Basename;
use strict;
my $section_types = {
"EXT_LIB" => {
"LIBS" => "list",
"CFLAGS" => "list",
"CPPFLAGS" => "list",
"LDFLAGS" => "list",
},
"SUBSYSTEM" => {
"OBJ_FILES" => "list",
"PRIVATE_DEPENDENCIES" => "list",
"PUBLIC_DEPENDENCIES" => "list",
"ENABLE" => "bool",
"MANPAGE" => "string",
"PUBLIC_PROTO_HEADER" => "string",
"PRIVATE_PROTO_HEADER" => "string",
"PUBLIC_HEADERS" => "list",
"CFLAGS" => "list",
"LDFLAGS" => "list",
"STANDARD_VISIBILITY" => "string"
},
"MODULE" => {
"SUBSYSTEM" => "string",
"INIT_FUNCTION" => "string",
"OBJ_FILES" => "list",
"PUBLIC_DEPENDENCIES" => "list",
"PRIVATE_DEPENDENCIES" => "list",
"ALIASES" => "list",
"ENABLE" => "bool",
"OUTPUT_TYPE" => "list",
"MANPAGE" => "string",
"PRIVATE_PROTO_HEADER" => "string",
"PUBLIC_PROTO_HEADER" => "string",
"PUBLIC_HEADERS" => "list",
"CFLAGS" => "list"
},
"BINARY" => {
"OBJ_FILES" => "list",
"PRIVATE_DEPENDENCIES" => "list",
"ENABLE" => "bool",
"MANPAGE" => "string",
"INSTALLDIR" => "string",
"PRIVATE_PROTO_HEADER" => "string",
"PUBLIC_PROTO_HEADER" => "string",
"PUBLIC_HEADERS" => "list",
"CFLAGS" => "list",
"LDFLAGS" => "list",
"STANDARD_VISIBILITY" => "string",
"USE_HOSTCC" => "bool"
},
"LIBRARY" => {
"VERSION" => "string",
"SO_VERSION" => "string",
"LIBRARY_REALNAME" => "string",
"INIT_FUNCTION_TYPE" => "string",
"OBJ_FILES" => "list",
"DESCRIPTION" => "string",
"PRIVATE_DEPENDENCIES" => "list",
"PUBLIC_DEPENDENCIES" => "list",
"ENABLE" => "bool",
"MANPAGE" => "string",
"PUBLIC_HEADERS" => "list",
"PUBLIC_PROTO_HEADER" => "string",
"PRIVATE_PROTO_HEADER" => "string",
"CFLAGS" => "list",
"LDFLAGS" => "list",
"STANDARD_VISIBILITY" => "string"
}
};
use vars qw(@parsed_files);
@parsed_files = ();
###########################################################
# The parsing function which parses the file
#
# $result = _parse_config_mk($filename)
#
# $filename - the path of the config.mk file
# which should be parsed
sub run_config_mk($$$$)
{
sub run_config_mk($$$$);
my ($input, $srcdir, $builddir, $filename) = @_;
my $result;
my $linenum = -1;
my $infragment = 0;
my $section = "GLOBAL";
my $makefile = "";
my $parsing_file = $filename;
my $retry_parsing_file = undef;
$ENV{samba_builddir} = $builddir;
$ENV{samba_srcdir} = $srcdir;
if (($srcdir ne ".") or ($builddir ne ".")) {
$parsing_file = $builddir."/".$filename;
$retry_parsing_file = $srcdir."/".$filename;
}
if (open(CONFIG_MK, $parsing_file)) {
$retry_parsing_file = undef;
} else {
die("Can't open $parsing_file") unless defined($retry_parsing_file);
}
if (defined($retry_parsing_file)) {
if (open(CONFIG_MK, $parsing_file)) {
$parsing_file = $retry_parsing_file;
$retry_parsing_file = undef;
} else {
die("Can't open neither '$parsing_file' nor '$retry_parsing_file'\n");
}
}
push (@parsed_files, $parsing_file);
my @lines = <CONFIG_MK>;
close(CONFIG_MK);
my $line = "";
my $prev = "";
foreach (@lines) {
$linenum++;
# lines beginning with '#' are ignored
next if (/^\#.*$/);
if (/^(.*)\\$/) {
$prev .= $1;
next;
} else {
$line = "$prev$_";
$prev = "";
}
if ($line =~ /^\[([-a-zA-Z0-9_:]+)\][\t ]*$/)
{
$section = $1;
$infragment = 0;
next;
}
# include
if ($line =~ /^include (.*)$/) {
my $subfile= $1;
my $subdir = dirname($filename);
$subdir =~ s/^\.$//g;
$subdir =~ s/^\.\///g;
$subdir .= "/" if ($subdir ne "");
$makefile .= run_config_mk($input, $srcdir, $builddir, $subdir.$subfile);
next;
}
# empty line
if ($line =~ /^[ \t]*$/) {
$section = "GLOBAL";
if ($infragment) { $makefile.="\n"; }
next;
}
# global stuff is considered part of the makefile
if ($section eq "GLOBAL") {
if (!$infragment) { $makefile.="\n"; }
$makefile .= $line;
$infragment = 1;
next;
}
# Assignment
if ($line =~ /^([a-zA-Z0-9_]+)[\t ]*=(.*)$/) {
$result->{$section}{$1}{VAL} = $2;
$result->{$section}{$1}{KEY} = $1;
next;
}
die("$parsing_file:$linenum: Bad line while parsing $parsing_file");
}
foreach my $section (keys %{$result}) {
my ($type, $name) = split(/::/, $section, 2);
my $sectype = $section_types->{$type};
if (not defined($sectype)) {
die($parsing_file.":[".$section."] unknown section type \"".$type."\"!");
}
$input->{$name}{NAME} = $name;
$input->{$name}{TYPE} = $type;
$input->{$name}{MK_FILE} = $parsing_file;
$input->{$name}{BASEDIR} = dirname($filename);
foreach my $key (values %{$result->{$section}}) {
$key->{VAL} = smb_build::input::strtrim($key->{VAL});
my $vartype = $sectype->{$key->{KEY}};
if (not defined($vartype)) {
die($parsing_file.":[".$section."]: unknown attribute type \"$key->{KEY}\"!");
}
if ($vartype eq "string") {
$input->{$name}{$key->{KEY}} = $key->{VAL};
} elsif ($vartype eq "list") {
$input->{$name}{$key->{KEY}} = [smb_build::input::str2array($key->{VAL})];
} elsif ($vartype eq "bool") {
if (($key->{VAL} ne "YES") and ($key->{VAL} ne "NO")) {
die("Invalid value for bool attribute $key->{KEY}: $key->{VAL} in section $section");
}
$input->{$name}{$key->{KEY}} = $key->{VAL};
}
}
}
return $makefile;
}
1;
+61
View File
@@ -0,0 +1,61 @@
#!/usr/bin/perl
# Samba4 Dependency Graph Generator
# (C) 2004-2005 Jelmer Vernooij <jelmer@samba.org>
# Published under the GNU GPL
use strict;
use lib 'build';
use smb_build::config_mk;
my $subsys = shift @ARGV;
sub contains($$)
{
my ($haystack,$needle) = @_;
foreach (@$haystack) {
return 1 if ($_ eq $needle);
}
return 0;
}
sub generate($$$)
{
my ($depend,$only,$name) = @_;
my $res = "digraph $name {\n";
foreach my $part (values %{$depend}) {
next if (defined($only) and not contains($only,$part->{NAME}));
foreach my $elem (@{$part->{PUBLIC_DEPENDENCIES}},
@{$part->{PRIVATE_DEPENDENCIES}}) {
$res .= "\t\"$part->{NAME}\" -> \"$elem\";\n";
}
}
return $res . "}\n";
}
my $INPUT = {};
smb_build::config_mk::run_config_mk($INPUT, '.', '.', "main.mk");
my $name = "samba4";
my $only;
if (defined($subsys)) {
my $DEPEND = smb_build::input::check($INPUT, \%config::enabled,
"STATIC_LIBRARY", "SHARED_LIBRARY", "SHARED_LIBRARY");
die("No such subsystem $subsys") unless (defined($DEPEND->{$subsys}));
$only = $DEPEND->{$subsys}->{UNIQUE_DEPENDENCIES_ALL};
push (@$only, "$subsys");
$name = $subsys;
}
my $fname = "$name-deps.dot";
print __FILE__.": creating $fname\n";
open DOTTY, ">$fname";
print DOTTY generate($INPUT, $only, $name);
close DOTTY;
1;
+116
View File
@@ -0,0 +1,116 @@
# Environment class
#
# Samba Build Environment
#
# (C) 2005 Jelmer Vernooij <jelmer@samba.org>
#
# Published under the GNU GPL
package smb_build::env;
use smb_build::input;
use File::Path;
use File::Basename;
use strict;
sub new($$)
{
my ($name, $config) = @_;
my $self = { };
bless $self, $name;
$self->{items} = {};
$self->{info} = {};
$self->_set_config($config);
return $self;
}
sub _set_config($$)
{
my ($self, $config) = @_;
$self->{config} = $config;
if (not defined($self->{config}->{srcdir})) {
$self->{config}->{srcdir} = '.';
}
if (not defined($self->{config}->{builddir})) {
$self->{config}->{builddir} = '.';
}
if ($self->{config}->{prefix} eq "NONE") {
$self->{config}->{prefix} = $self->{config}->{ac_default_prefix};
}
if ($self->{config}->{exec_prefix} eq "NONE") {
$self->{config}->{exec_prefix} = $self->{config}->{prefix};
}
$self->{developer} = ($self->{config}->{developer} eq "yes");
$self->{automatic_deps} = ($self->{config}->{automatic_dependencies} eq "yes");
}
sub PkgConfig($$$$$$$$$$$$)
{
my ($self,$path,$name,$libs,$privlibs,$cflags,$version,$desc,$hasmodules,$pubdep,$privdep,$dirs) = @_;
print __FILE__.": creating $path\n";
if ($self->{config}->{libreplace_cv_immediate_structures} eq "yes") {
$cflags .= " -DHAVE_IMMEDIATE_STRUCTURES=1";
}
mkpath(dirname($path),0,0755);
open(OUT, ">$path") or die("Can't open $path: $!");
foreach (@$dirs) {
print OUT "$_\n";
}
if ($hasmodules) {
print OUT "modulesdir=$self->{config}->{modulesdir}/$name\n" ;
}
print OUT "\n";
print OUT "Name: $name\n";
if (defined($desc)) {
print OUT "Description: $desc\n";
}
print OUT "Requires: $pubdep\n" if defined($pubdep);
print OUT "Requires.private: $privdep\n" if defined($privdep);
print OUT "Version: $version\n";
print OUT "Libs: $libs\n";
print OUT "Libs.private: $privlibs\n" if (defined($privlibs));
print OUT "Cflags: -I\${includedir} $cflags\n";
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;
+84
View File
@@ -0,0 +1,84 @@
# SMB Build System
# - create output for build.h
#
# Copyright (C) Stefan (metze) Metzmacher 2004
# Copyright (C) Jelmer Vernooij 2005
# Released under the GNU GPL
package header;
use strict;
sub _add_define_section($)
{
my $DEFINE = shift;
my $output = "";
$output .= "
/* $DEFINE->{COMMENT} */
#define $DEFINE->{KEY} $DEFINE->{VAL}
";
return $output;
}
sub _prepare_build_h($)
{
my $depend = shift;
my @defines = ();
my $output = "";
foreach my $key (values %$depend) {
my $DEFINE = ();
next if ($key->{TYPE} ne "LIBRARY" and
$key->{TYPE} ne "MODULE" and
$key->{TYPE} ne "SUBSYSTEM" and
$key->{TYPE} ne "BINARY");
next unless defined($key->{INIT_FUNCTIONS});
my $name = $key->{NAME};
$name =~ s/-/_/g;
$DEFINE->{COMMENT} = "$key->{TYPE} $key->{NAME} INIT";
$DEFINE->{KEY} = "STATIC_$name\_MODULES";
$DEFINE->{VAL} = "{ \\\n";
foreach (@{$key->{INIT_FUNCTIONS}}) {
$DEFINE->{VAL} .= "\t$_, \\\n";
my $fn = $key->{INIT_FUNCTION_TYPE};
unless(defined($fn)) { $fn = "NTSTATUS (*) (void)"; }
$fn =~ s/\(\*\)/$_/;
$output .= "$fn;\n";
}
$DEFINE->{VAL} .= "\tNULL \\\n }";
push(@defines,$DEFINE);
}
#
# loop over all BUILD_H define sections
#
foreach (@defines) { $output .= _add_define_section($_); }
return $output;
}
###########################################################
# This function creates include/build.h from the SMB_BUILD
# context
#
# create_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, $file) = @_;
open(BUILD_H,">$file") || die ("Can't open `$file'\n");
print BUILD_H "/* autogenerated by build/smb_build/main.pl */\n";
print BUILD_H _prepare_build_h($CTX);
close(BUILD_H);
print __FILE__.": creating $file\n";
}
1;
+259
View File
@@ -0,0 +1,259 @@
# Samba Build System
# - the input checking functions
#
# Copyright (C) Stefan (metze) Metzmacher 2004
# Copyright (C) Jelmer Vernooij 2004
# Released under the GNU GPL
use smb_build::config;
use strict;
package smb_build::input;
my $srcdir = $config::config{srcdir};
sub strtrim($)
{
$_ = shift;
s/^[\t\n ]*//g;
s/[\t\n ]*$//g;
return $_;
}
sub str2array($)
{
$_ = shift;
s/^[\t\n ]*//g;
s/[\t\n ]*$//g;
s/([\t\n ]+)/ /g;
return () if (length($_)==0);
return split /[ \t\n]/;
}
sub add_libreplace($)
{
my ($part) = @_;
return if ($part->{NAME} eq "LIBREPLACE");
return if ($part->{NAME} eq "LIBREPLACE_HOSTCC");
return if ($part->{NAME} eq "REPLACE_READDIR");
foreach my $n (@{$part->{PRIVATE_DEPENDENCIES}}) {
return if ($n eq "LIBREPLACE");
return if ($n eq "LIBREPLACE_HOSTCC");
}
foreach my $n (@{$part->{PUBLIC_DEPENDENCIES}}) {
return if ($n eq "LIBREPLACE");
return if ($n eq "LIBREPLACE_HOSTCC");
}
if (defined($part->{USE_HOSTCC}) && $part->{USE_HOSTCC} eq "YES") {
unshift (@{$part->{PRIVATE_DEPENDENCIES}}, "LIBREPLACE_HOSTCC");
} else {
unshift (@{$part->{PRIVATE_DEPENDENCIES}}, "LIBREPLACE");
}
}
sub check_subsystem($$$)
{
my ($INPUT, $subsys, $default_ot) = @_;
return if ($subsys->{ENABLE} ne "YES");
unless(defined($subsys->{OUTPUT_TYPE})) {
$subsys->{OUTPUT_TYPE} = $default_ot;
}
add_libreplace($subsys);
}
sub check_module($$$)
{
my ($INPUT, $mod, $default_ot) = @_;
die("Module $mod->{NAME} does not have a SUBSYSTEM set") if not defined($mod->{SUBSYSTEM});
my $use_default = 0;
if (not exists($INPUT->{$mod->{SUBSYSTEM}}{INIT_FUNCTIONS})) {
$INPUT->{$mod->{SUBSYSTEM}}{INIT_FUNCTIONS} = [];
}
if (!(defined($INPUT->{$mod->{SUBSYSTEM}}))) {
$mod->{ENABLE} = "NO";
return;
}
return if ($mod->{ENABLE} ne "YES");
if (exists($INPUT->{$mod->{SUBSYSTEM}}{INIT_FUNCTION_TYPE})) {
$mod->{INIT_FUNCTION_TYPE} = $INPUT->{$mod->{SUBSYSTEM}}{INIT_FUNCTION_TYPE};
} else {
$mod->{INIT_FUNCTION_TYPE} = "NTSTATUS (*) (void)";
}
if (not defined($mod->{OUTPUT_TYPE})) {
$mod->{OUTPUT_TYPE} = $default_ot;
}
if (grep(/SHARED_LIBRARY/, @{$mod->{OUTPUT_TYPE}})) {
$mod->{INSTALLDIR} = "MODULESDIR/$mod->{SUBSYSTEM}";
push (@{$mod->{PRIVATE_DEPENDENCIES}}, $mod->{SUBSYSTEM});
}
if (grep(/INTEGRATED/, @{$mod->{OUTPUT_TYPE}})) {
push (@{$INPUT->{$mod->{SUBSYSTEM}}{INIT_FUNCTIONS}}, $mod->{INIT_FUNCTION}) if defined($mod->{INIT_FUNCTION});
}
add_libreplace($mod);
}
sub check_library($$$)
{
my ($INPUT, $lib, $default_ot) = @_;
return if ($lib->{ENABLE} ne "YES");
$lib->{OUTPUT_TYPE} = $default_ot;
if (defined($lib->{VERSION}) and not defined($lib->{SO_VERSION})) {
print "$lib->{NAME}: Please specify SO_VERSION when specifying VERSION\n";
return;
}
if (defined($lib->{SO_VERSION}) and not defined($lib->{VERSION})) {
print "$lib->{NAME}: Please specify VERSION when specifying SO_VERSION\n";
return;
}
unless (defined($lib->{INIT_FUNCTION_TYPE})) {
$lib->{INIT_FUNCTION_TYPE} = "NTSTATUS (*) (void)";
}
$lib->{INSTALLDIR} = "LIBDIR";
add_libreplace($lib);
}
sub check_binary($$)
{
my ($INPUT, $bin) = @_;
return if ($bin->{ENABLE} ne "YES");
($bin->{BINARY} = (lc $bin->{NAME})) if not defined($bin->{BINARY});
$bin->{OUTPUT_TYPE} = ["BINARY"];
add_libreplace($bin);
}
sub import_integrated($$)
{
my ($lib, $depend) = @_;
foreach my $mod (values %$depend) {
next if(not defined($mod->{OUTPUT_TYPE}));
next if(not grep(/INTEGRATED/, @{$mod->{OUTPUT_TYPE}}));
next if(not defined($mod->{SUBSYSTEM}));
next if($mod->{SUBSYSTEM} ne $lib->{NAME});
next if($mod->{ENABLE} ne "YES");
push (@{$lib->{FULL_OBJ_LIST}}, "\$($mod->{TYPE}_$mod->{NAME}_FULL_OBJ_LIST)");
push (@{$lib->{LINK_FLAGS}}, "\$($mod->{TYPE}_$mod->{NAME}_LINK_FLAGS)");
push (@{$lib->{PRIVATE_DEPENDENCIES}}, @{$mod->{PUBLIC_DEPENDENCIES}}) if defined($mod->{PUBLIC_DEPENDENCIES});
push (@{$lib->{PRIVATE_DEPENDENCIES}}, @{$mod->{PRIVATE_DEPENDENCIES}}) if defined($mod->{PRIVATE_DEPENDENCIES});
$mod->{ENABLE} = "NO";
}
}
sub calc_unique_deps($$$$$$)
{
sub calc_unique_deps($$$$$$);
my ($name, $INPUT, $deps, $udeps, $withlibs, $busy) = @_;
foreach my $n (@$deps) {
die("Dependency unknown: $n") unless (defined($INPUT->{$n}));
die("Recursive dependency: $n, list: " . join(',', @$busy)) if (grep (/^$n$/, @$busy));
next if (grep /^$n$/, @$udeps);
my $dep = $INPUT->{$n};
if (defined ($dep->{OUTPUT_TYPE}) &&
($withlibs or
(@{$dep->{OUTPUT_TYPE}}[0] eq "INTEGRATED") or
(@{$dep->{OUTPUT_TYPE}}[0] eq "STATIC_LIBRARY"))) {
push (@$busy, $dep->{NAME});
calc_unique_deps($dep->{NAME}, $INPUT, $dep->{PUBLIC_DEPENDENCIES}, $udeps, $withlibs, $busy);
calc_unique_deps($dep->{NAME}, $INPUT, $dep->{PRIVATE_DEPENDENCIES}, $udeps, $withlibs, $busy);
pop (@$busy);
}
unshift (@{$udeps}, $dep->{NAME});
}
}
sub check($$$$$)
{
my ($INPUT, $enabled, $subsys_ot, $lib_ot, $module_ot) = @_;
foreach my $part (values %$INPUT) {
unless (defined($part->{STANDARD_VISIBILITY})) {
if ($part->{TYPE} eq "MODULE" or $part->{TYPE} eq "BINARY") {
$part->{STANDARD_VISIBILITY} = "hidden";
} else {
$part->{STANDARD_VISIBILITY} = "default";
}
}
unless (defined($part->{PUBLIC_HEADERS})) {
$part->{PUBLIC_HEADERS} = [];
}
if (defined($part->{PUBLIC_PROTO_HEADER})) {
push (@{$part->{PUBLIC_HEADERS}}, $part->{PUBLIC_PROTO_HEADER});
}
if (defined($enabled->{$part->{NAME}})) {
$part->{ENABLE} = $enabled->{$part->{NAME}};
next;
}
unless(defined($part->{ENABLE})) {
if ($part->{TYPE} eq "EXT_LIB") {
$part->{ENABLE} = "NO";
} else {
$part->{ENABLE} = "YES";
}
}
}
foreach my $k (keys %$INPUT) {
my $part = $INPUT->{$k};
$part->{LINK_FLAGS} = [];
$part->{FULL_OBJ_LIST} = ["\$($part->{TYPE}_$part->{NAME}_OBJ_LIST)"];
check_subsystem($INPUT, $part, $subsys_ot) if ($part->{TYPE} eq "SUBSYSTEM");
check_module($INPUT, $part, $module_ot) if ($part->{TYPE} eq "MODULE");
check_library($INPUT, $part, $lib_ot) if ($part->{TYPE} eq "LIBRARY");
check_binary($INPUT, $part) if ($part->{TYPE} eq "BINARY");
}
foreach my $part (values %$INPUT) {
if (defined($part->{INIT_FUNCTIONS})) {
push (@{$part->{LINK_FLAGS}}, "\$(DYNEXP)");
}
import_integrated($part, $INPUT);
}
foreach my $part (values %$INPUT) {
$part->{UNIQUE_DEPENDENCIES} = [];
calc_unique_deps($part->{NAME}, $INPUT, $part->{PUBLIC_DEPENDENCIES}, $part->{UNIQUE_DEPENDENCIES}, 0, []);
calc_unique_deps($part->{NAME}, $INPUT, $part->{PRIVATE_DEPENDENCIES}, $part->{UNIQUE_DEPENDENCIES}, 0, []);
}
foreach my $part (values %$INPUT) {
$part->{UNIQUE_DEPENDENCIES_ALL} = [];
calc_unique_deps($part->{NAME}, $INPUT, $part->{PUBLIC_DEPENDENCIES}, $part->{UNIQUE_DEPENDENCIES_ALL}, 1, []);
calc_unique_deps($part->{NAME}, $INPUT, $part->{PRIVATE_DEPENDENCIES}, $part->{UNIQUE_DEPENDENCIES_ALL}, 1, []);
}
return $INPUT;
}
1;
+73
View File
@@ -0,0 +1,73 @@
# Samba Build System
# - the main program
#
# Copyright (C) Stefan (metze) Metzmacher 2004
# Copyright (C) Jelmer Vernooij 2005
# Released under the GNU GPL
use smb_build::makefile;
use smb_build::header;
use smb_build::input;
use smb_build::config_mk;
use smb_build::output;
use smb_build::env;
use smb_build::cflags;
use smb_build::summary;
use smb_build::config;
use strict;
my $INPUT = {};
my $mkfile = smb_build::config_mk::run_config_mk($INPUT, $config::config{srcdir}, $config::config{builddir}, "main.mk");
my $library_output_type;
if ($config::config{USESHARED} eq "true") {
$library_output_type = ["SHARED_LIBRARY", "STATIC_LIBRARY"];
} else {
$library_output_type = ["STATIC_LIBRARY"];
push (@$library_output_type, "SHARED_LIBRARY") if
($config::config{BLDSHARED} eq "true")
}
my $module_output_type;
if ($config::config{USESHARED} eq "true") {
$module_output_type = ["SHARED_LIBRARY"];
} else {
$module_output_type = ["INTEGRATED"];
}
my $DEPEND = smb_build::input::check($INPUT, \%config::enabled,
["STATIC_LIBRARY"], $library_output_type, $module_output_type);
my $OUTPUT = output::create_output($DEPEND, \%config::config);
$config::config{SUBSYSTEM_OUTPUT_TYPE} = ["STATIC_LIBRARY"];
$config::config{LIBRARY_OUTPUT_TYPE} = $library_output_type;
$config::config{MODULE_OUTPUT_TYPE} = $module_output_type;
my $mkenv = new smb_build::makefile(\%config::config, $mkfile);
foreach my $key (values %$OUTPUT) {
next unless defined $key->{OUTPUT_TYPE};
$mkenv->Integrated($key) if grep(/INTEGRATED/, @{$key->{OUTPUT_TYPE}});
}
foreach my $key (values %$OUTPUT) {
next unless defined $key->{OUTPUT_TYPE};
$mkenv->StaticLibrary($key) if grep(/STATIC_LIBRARY/, @{$key->{OUTPUT_TYPE}});
$mkenv->PkgConfig($key, $OUTPUT) if $key->{TYPE} eq "LIBRARY"
and defined($key->{VERSION});
$mkenv->SharedLibrary($key) if grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
$mkenv->Binary($key) if grep(/BINARY/, @{$key->{OUTPUT_TYPE}});
$mkenv->Manpage($key) if defined($key->{MANPAGE});
$mkenv->Header($key) if defined($key->{PUBLIC_HEADERS});
$mkenv->ProtoHeader($key) if defined($key->{PRIVATE_PROTO_HEADER}) or
defined($key->{PUBLIC_PROTO_HEADER});
}
$mkenv->write("Makefile");
header::create_smb_build_h($OUTPUT, "include/build.h");
cflags::create_cflags($OUTPUT, "extra_cflags.txt");
summary::show($OUTPUT, \%config::config);
1;
+570
View File
@@ -0,0 +1,570 @@
# Samba Build System
# - create output for Makefile
#
# Copyright (C) Stefan (metze) Metzmacher 2004
# Copyright (C) Jelmer Vernooij 2005
# Released under the GNU GPL
package smb_build::makefile;
use smb_build::env;
use strict;
use base 'smb_build::env';
use Cwd 'abs_path';
sub new($$$)
{
my ($myname, $config, $mkfile) = @_;
my $self = new smb_build::env($config);
bless($self, $myname);
$self->{manpages} = [];
$self->{sbin_progs} = [];
$self->{bin_progs} = [];
$self->{torture_progs} = [];
$self->{static_libs} = [];
$self->{shared_libs} = [];
$self->{installable_shared_libs} = [];
$self->{headers} = [];
$self->{shared_modules} = [];
$self->{plugins} = [];
$self->{install_plugins} = "";
$self->{uninstall_plugins} = "";
$self->{pc_files} = [];
$self->{proto_headers} = [];
$self->{output} = "";
$self->{mkfile} = $mkfile;
$self->output("#!gmake\n");
$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();
if (!$self->{automatic_deps}) {
$self->output("ALL_PREDEP = proto\n");
$self->output(".NOTPARALLEL:\n");
}
return $self;
}
sub output($$)
{
my ($self, $text) = @_;
$self->{output} .= $text;
}
sub _prepare_path_vars($)
{
my ($self) = @_;
$self->output(<< "__EOD__"
prefix = $self->{config}->{prefix}
exec_prefix = $self->{config}->{exec_prefix}
selftest_prefix = $self->{config}->{selftest_prefix}
VPATH = $self->{config}->{srcdir}:heimdal_build:heimdal/lib/asn1:heimdal/lib/krb5:heimdal/lib/gssapi:heimdal/lib/hdb:heimdal/lib/roken:heimdal/lib/des
srcdir = $self->{config}->{srcdir}
builddir = $self->{config}->{builddir}
datarootdir = $self->{config}->{datarootdir}
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
SERVICESDIR = $self->{config}->{datadir}/services
JSDIR = $self->{config}->{datadir}/js
SETUPDIR = $self->{config}->{datadir}/setup
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}
WINBINDD_SOCKET_DIR = $self->{config}->{winbindd_socket_dir}
__EOD__
);
}
sub _prepare_compiler_linker($)
{
my ($self) = @_;
my $builddir_headers = "";
my $libdir;
my $extra_link_flags = "";
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}
CPP=$self->{config}->{CPP}
CPPFLAGS=$builddir_headers-I\$(srcdir)/include -I\$(srcdir) -I\$(srcdir)/lib -I\$(srcdir)/lib/replace -D_SAMBA_BUILD_=4 -DHAVE_CONFIG_H $self->{config}->{CPPFLAGS}
CC=$self->{config}->{CC}
CFLAGS=$self->{config}->{CFLAGS} \$(CPPFLAGS)
PICFLAG=$self->{config}->{PICFLAG}
HOSTCC=$self->{config}->{HOSTCC}
HOSTCC_CFLAGS=-D_SAMBA_HOSTCC_ $self->{config}->{CFLAGS} \$(CPPFLAGS)
INSTALL_LINK_FLAGS=$extra_link_flags
LD=$self->{config}->{LD}
LDFLAGS=$self->{config}->{LDFLAGS} -L$libdir
STLD=$self->{config}->{STLD}
STLD_FLAGS=$self->{config}->{STLD_FLAGS}
SHLD=$self->{config}->{SHLD}
SHLD_FLAGS=$self->{config}->{SHLD_FLAGS} -L\$(builddir)/bin/shared
SHLD_UNDEF_FLAGS=$self->{config}->{SHLD_UNDEF_FLAGS}
SHLIBEXT=$self->{config}->{SHLIBEXT}
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}
__EOD__
);
}
sub _prepare_mk_files($)
{
my $self = shift;
my @tmp = ();
foreach (@smb_build::config_mk::parsed_files) {
s/ .*$//g;
push (@tmp, $_);
}
$self->output("MK_FILES = " . array2oneperline(\@tmp) . "\n");
}
sub array2oneperline($)
{
my $array = shift;
my $output = "";
foreach (@$array) {
next unless defined($_);
$output .= " \\\n\t\t$_";
}
return $output;
}
sub _prepare_list($$$)
{
my ($self,$ctx,$var) = @_;
my $tmplist = array2oneperline($ctx->{$var});
return if ($tmplist eq "");
$self->output("$ctx->{TYPE}\_$ctx->{NAME}_$var =$tmplist\n");
}
sub Integrated($$)
{
my ($self,$ctx) = @_;
$self->_prepare_list($ctx, "OBJ_LIST");
$self->_prepare_list($ctx, "FULL_OBJ_LIST");
$self->_prepare_list($ctx, "LINK_FLAGS");
}
sub SharedLibrary($$)
{
my ($self,$ctx) = @_;
my $init_obj = "";
if ($ctx->{TYPE} eq "LIBRARY") {
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}));
} elsif ($ctx->{TYPE} eq "MODULE") {
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)/$ctx->{SUBSYSTEM}/$ctx->{LIBRARY_REALNAME}\n";
$self->{install_plugins} .= "\t\@mkdir -p \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/\n";
$self->{install_plugins} .= "\t\@cp $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME} \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/$ctx->{LIBRARY_REALNAME}\n";
$self->{uninstall_plugins} .= "\t\@echo Uninstalling \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/$ctx->{LIBRARY_REALNAME}\n";
$self->{uninstall_plugins} .= "\t\@-rm \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/$ctx->{LIBRARY_REALNAME}\n";
if (defined($ctx->{ALIASES})) {
foreach (@{$ctx->{ALIASES}}) {
$self->{install_plugins} .= "\t\@ln -fs $ctx->{LIBRARY_REALNAME} \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/$_.\$(SHLIBEXT)\n";
$self->{uninstall_plugins} .= "\t\@-rm \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/$_.\$(SHLIBEXT)\n";
}
}
}
$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");
push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)");
my $extraflags = "";
if ($ctx->{TYPE} eq "MODULE" and defined($ctx->{INIT_FUNCTION})) {
my $init_fn = $ctx->{INIT_FUNCTION_TYPE};
$init_fn =~ s/\(\*\)/init_module/;
my $proto_fn = $ctx->{INIT_FUNCTION_TYPE};
$proto_fn =~ s/\(\*\)/$ctx->{INIT_FUNCTION}/;
$extraflags = "\$(SHLD_UNDEF_FLAGS)";
$self->output(<< "__EOD__"
bin/$ctx->{NAME}_init_module.c:
\@echo Creating \$\@
\@echo \"#include \\\"includes.h\\\"\" > \$\@
\@echo \"$proto_fn;\" >> \$\@
\@echo -e \"_PUBLIC_ $init_fn \\n{\\n\\treturn $ctx->{INIT_FUNCTION}();\\n}\\n\" >> \$\@
__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 = "\n\t\@ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$ctx->{LIBRARY_SONAME}";
}
}
my $singlesoarg = "";
if ($self->{config}->{SONAMEFLAG} ne "" and
defined($ctx->{LIBRARY_SONAME}) and
$ctx->{LIBRARY_REALNAME} ne $ctx->{LIBRARY_SONAME}) {
$singlesoarg = "\n\t\@ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$ctx->{LIBRARY_SONAME}";
}
$self->output(<< "__EOD__"
#
$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST) $init_obj
\@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) $extraflags \\
$soarg \\
$init_obj $singlesoarg$soargdebug
__EOD__
);
if (defined($ctx->{ALIASES})) {
foreach (@{$ctx->{ALIASES}}) {
$self->output("\t\@ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$_.\$(SHLIBEXT)\n");
}
}
$self->output("\n");
}
sub StaticLibrary($$)
{
my ($self,$ctx) = @_;
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, "FULL_OBJ_LIST");
push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)");
$self->output(<< "__EOD__"
#
$ctx->{TARGET_STATIC_LIBRARY}: \$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)
\@echo Linking \$@
\@rm -f \$@
\@\$(STLD) \$(STLD_FLAGS) \$@ \$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)
__EOD__
);
}
sub Header($$)
{
my ($self,$ctx) = @_;
my $dir = $ctx->{BASEDIR};
$dir =~ s/^\.\///g;
foreach (@{$ctx->{PUBLIC_HEADERS}}) {
push (@{$self->{headers}}, "$dir/$_");
}
}
sub Binary($$)
{
my ($self,$ctx) = @_;
my $installdir;
my $extradir = "";
if (defined($ctx->{INSTALLDIR}) && $ctx->{INSTALLDIR} =~ /^TORTUREDIR/) {
$extradir = "/torture" . substr($ctx->{INSTALLDIR}, length("TORTUREDIR"));
}
my $localdir = "bin$extradir";
$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}}, "$localdir/$ctx->{BINARY}");
$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->output(<< "__EOD__"
$installdir/$ctx->{BINARY}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)
\@echo Linking \$\@
\@\$(LD) \$(LDFLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\
\$\($ctx->{TYPE}_$ctx->{NAME}_LINK_FLAGS)
__EOD__
);
}
sub Manpage($$)
{
my ($self,$ctx) = @_;
my $dir = $ctx->{BASEDIR};
$dir =~ s/^\.\///g;
push (@{$self->{manpages}}, "$dir/$ctx->{MANPAGE}");
}
sub PkgConfig($$$)
{
my ($self,$ctx,$other) = @_;
my $link_name = $ctx->{NAME};
$link_name =~ s/^LIB//g;
$link_name = lc($link_name);
return if (not defined($ctx->{DESCRIPTION}));
my $path = "$ctx->{BASEDIR}/$link_name.pc";
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\${libdir} -l$link_name",
$privlibs,
"",
"$ctx->{VERSION}",
$ctx->{DESCRIPTION},
defined($ctx->{INIT_FUNCTIONS}),
$pubs,
$privs,
[
"prefix=$self->{config}->{prefix}",
"exec_prefix=$self->{config}->{exec_prefix}",
"libdir=$self->{config}->{libdir}",
"includedir=$self->{config}->{includedir}"
]
);
smb_build::env::PkgConfig($self,
"bin/pkgconfig/$link_name-uninstalled.pc",
$link_name,
"-Lbin/shared -Lbin/static -l$link_name",
$privlibs,
"-I. -Iinclude -Ilib -Ilib/replace",
"$ctx->{VERSION}",
$ctx->{DESCRIPTION},
defined($ctx->{INIT_FUNCTIONS}),
$pubs,
$privs,
[
"prefix=bin/",
"includedir=$ctx->{BASEDIR}"
]
);
}
sub ProtoHeader($$)
{
my ($self,$ctx) = @_;
my $dir = $ctx->{BASEDIR};
$dir =~ s/^\.\///g;
my $target = "";
my $comment = "Creating ";
if (defined($ctx->{PRIVATE_PROTO_HEADER})) {
$target.= "$dir/$ctx->{PRIVATE_PROTO_HEADER}";
$comment.= "$dir/$ctx->{PRIVATE_PROTO_HEADER}";
if (defined($ctx->{PUBLIC_PROTO_HEADER})) {
$comment .= " and ";
$target.= " ";
}
push (@{$self->{proto_headers}}, "$dir/$ctx->{PRIVATE_PROTO_HEADER}");
} else {
$ctx->{PRIVATE_PROTO_HEADER} = $ctx->{PUBLIC_PROTO_HEADER};
}
if (defined($ctx->{PUBLIC_PROTO_HEADER})) {
$comment.= "$dir/$ctx->{PUBLIC_PROTO_HEADER}";
$target .= "$dir/$ctx->{PUBLIC_PROTO_HEADER}";
push (@{$self->{proto_headers}}, "$dir/$ctx->{PUBLIC_PROTO_HEADER}");
} else {
$ctx->{PUBLIC_PROTO_HEADER} = $ctx->{PRIVATE_PROTO_HEADER};
}
$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 --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($$)
{
my ($self,$file) = @_;
$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("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("ALL_OBJS = " . array2oneperline($self->{all_objs}) . "\n");
$self->output("PROTO_HEADERS = " . array2oneperline($self->{proto_headers}) . "\n");
$self->output("SHARED_MODULES = " . array2oneperline($self->{shared_modules}) . "\n");
$self->output("PLUGINS = " . array2oneperline($self->{plugins}) . "\n");
$self->output("\ninstallplugins: \$(PLUGINS)\n".$self->{install_plugins}."\n");
$self->output("\nuninstallplugins:\n".$self->{uninstall_plugins}."\n");
$self->_prepare_mk_files();
$self->output($self->{mkfile});
if ($self->{automatic_deps}) {
$self->output("
ifneq (\$(MAKECMDGOALS),clean)
ifneq (\$(MAKECMDGOALS),distclean)
ifneq (\$(MAKECMDGOALS),realdistclean)
-include \$(DEP_FILES)
endif
endif
endif
");
} else {
$self->output("include \$(srcdir)/static_deps.mk\n");
}
open(MAKEFILE,">$file") || die ("Can't open $file\n");
print MAKEFILE $self->{output};
close(MAKEFILE);
print __FILE__.": creating $file\n";
}
1;
+178
View File
@@ -0,0 +1,178 @@
# SMB Build System
# - the output generating functions
#
# Copyright (C) Stefan (metze) Metzmacher 2004
# Copyright (C) Jelmer Vernooij 2004
# Released under the GNU GPL
package output;
use strict;
sub add_dir($$)
{
my ($dir,$files) = @_;
my @ret = ();
my $dirsep = "/";
$dir =~ s/^\.$//g;
$dir =~ s/^\.\///g;
$dirsep = "" if ($dir eq "");
foreach (@$files) {
if (substr($_, 0, 1) ne "\$") {
$_ = "$dir$dirsep$_";
s/([^\/\.]+)\/\.\.\///g;
s/([^\/\.]+)\/\.\.\///g;
}
push (@ret, $_);
}
return @ret;
}
sub generate_shared_library($)
{
my $lib = shift;
my $link_name;
my $lib_name;
$lib->{DEPEND_LIST} = [];
$link_name = lc($lib->{NAME});
$lib_name = $link_name;
if ($lib->{TYPE} eq "LIBRARY") {
$link_name = $lib->{NAME};
$link_name =~ s/^LIB//;
$link_name = lc($link_name);
$lib_name = "lib$link_name";
}
if (defined($lib->{LIBRARY_REALNAME})) {
$lib->{BASEDIR} =~ s/^\.\///g;
$lib->{LIBRARY_REALNAME} = "$lib->{LIBRARY_REALNAME}";
$lib->{SHAREDDIR} = $lib->{BASEDIR};
} else {
if ($lib->{TYPE} eq "MODULE") {
$lib->{SHAREDDIR} = "bin/modules/$lib->{SUBSYSTEM}";
$lib->{LIBRARY_REALNAME} = $link_name;
$lib->{LIBRARY_REALNAME} =~ s/^$lib->{SUBSYSTEM}_//g;
$lib->{LIBRARY_REALNAME}.= ".\$(SHLIBEXT)";
} else {
$lib->{SHAREDDIR} = "bin/shared";
$lib->{LIBRARY_REALNAME} = "$lib_name.\$(SHLIBEXT)";
}
}
if (defined($lib->{VERSION})) {
$lib->{LIBRARY_SONAME} = "$lib->{LIBRARY_REALNAME}.$lib->{SO_VERSION}";
$lib->{LIBRARY_REALNAME} = "$lib->{LIBRARY_REALNAME}.$lib->{VERSION}";
}
$lib->{TARGET_SHARED_LIBRARY} = "$lib->{SHAREDDIR}/$lib->{LIBRARY_REALNAME}";
$lib->{OUTPUT_SHARED_LIBRARY} = $lib->{TARGET_SHARED_LIBRARY};
}
sub generate_static_library($)
{
my $lib = shift;
my $link_name;
$lib->{DEPEND_LIST} = [];
$link_name = $lib->{NAME};
$link_name =~ s/^LIB//;
$lib->{LIBRARY_NAME} = "lib".lc($link_name).".a";
if (defined($lib->{OBJ_FILES})) {
$lib->{TARGET_STATIC_LIBRARY} = "bin/static/$lib->{LIBRARY_NAME}";
} else {
$lib->{TARGET_STATIC_LIBRARY} = "";
}
$lib->{OUTPUT_STATIC_LIBRARY} = $lib->{TARGET_STATIC_LIBRARY};
}
sub generate_binary($)
{
my $bin = shift;
$bin->{DEPEND_LIST} = [];
push(@{$bin->{LINK_FLAGS}}, "\$($bin->{TYPE}_$bin->{NAME}\_OBJ_LIST)");
$bin->{DEBUGDIR} = "bin/";
$bin->{TARGET_BINARY} = $bin->{OUTPUT_BINARY} = "$bin->{DEBUGDIR}/$bin->{NAME}";
$bin->{BINARY} = $bin->{NAME};
}
sub merge_array($$)
{
# $dest is a reference to an array
# $src is an array
my ($dest, $src) = @_;
return unless defined($src);
return unless ($#{$src} >= 0);
foreach my $line (@{$src}) {
next if (grep /^$line$/, @{$$dest});
push(@{$$dest}, $line);
}
}
sub create_output($$)
{
my ($depend, $config) = @_;
my $part;
foreach $part (values %{$depend}) {
next unless(defined($part->{OUTPUT_TYPE}));
# Combine object lists
push(@{$part->{OBJ_LIST}}, add_dir($part->{BASEDIR}, $part->{OBJ_FILES})) if defined($part->{OBJ_FILES});
generate_binary($part) if grep(/BINARY/, @{$part->{OUTPUT_TYPE}});
generate_shared_library($part) if grep(/SHARED_LIBRARY/, @{$part->{OUTPUT_TYPE}});
generate_static_library($part) if grep(/STATIC_LIBRARY/, @{$part->{OUTPUT_TYPE}});
$part->{OUTPUT} = $part->{"OUTPUT_" . @{$part->{OUTPUT_TYPE}}[0]};
$part->{TARGET} = $part->{"TARGET_" . @{$part->{OUTPUT_TYPE}}[0]};
}
foreach $part (values %{$depend}) {
next if not defined($part->{OUTPUT_TYPE});
merge_array(\$part->{FINAL_CFLAGS}, $part->{CPPFLAGS});
merge_array(\$part->{FINAL_CFLAGS}, $part->{CFLAGS});
foreach (reverse @{$part->{UNIQUE_DEPENDENCIES_ALL}}) {
my $elem = $depend->{$_};
next if $elem == $part;
merge_array(\$part->{FINAL_CFLAGS}, $elem->{CPPFLAGS});
merge_array(\$part->{FINAL_CFLAGS}, $elem->{CFLAGS});
}
# Always import the link options of the unique dependencies
foreach (@{$part->{UNIQUE_DEPENDENCIES}}) {
my $elem = $depend->{$_};
next if $elem == $part;
push(@{$part->{LINK_FLAGS}}, $elem->{OUTPUT}) if defined($elem->{OUTPUT});
push(@{$part->{LINK_FLAGS}}, @{$elem->{LIBS}}) if defined($elem->{LIBS});
push(@{$part->{LINK_FLAGS}},@{$elem->{LDFLAGS}}) if defined($elem->{LDFLAGS});
push(@{$part->{DEPEND_LIST}}, $elem->{TARGET}) if defined($elem->{TARGET});
}
}
foreach $part (values %{$depend}) {
if (($part->{STANDARD_VISIBILITY} ne "default") and
($config->{visibility_attribute} eq "yes")) {
push(@{$part->{FINAL_CFLAGS}}, "-fvisibility=$part->{STANDARD_VISIBILITY}");
}
}
return $depend;
}
1;
+71
View File
@@ -0,0 +1,71 @@
# Samba Build System
# - write out summary
#
# Copyright (C) Jelmer Vernooij 2006
# Released under the GNU GPL
package summary;
use strict;
sub enabled($)
{
my ($val) = @_;
return (defined($val) && $val =~ m/yes|true/i);
}
sub showitem($$$)
{
my ($output,$desc,$items) = @_;
my @need = ();
foreach (@$items) {
if (!enabled($output->{$_}->{ENABLE})) {
push (@need, $_);
}
}
print "Support for $desc: ";
if ($#need >= 0) {
print "no (install " . join(',',@need) . ")\n";
} else {
print "yes\n";
}
}
sub show($$)
{
my ($output,$config) = @_;
print "Summary:\n\n";
showitem($output, "GTK+ frontends", ["gtk","gconf"]);
showitem($output, "SSL in SWAT and LDAP", ["GNUTLS"]);
showitem($output, "threads in smbd (see --with-pthread)", ["PTHREAD"]);
showitem($output, "intelligent command line editing", ["READLINE"]);
showitem($output, "changing process titles (see --with-setproctitle)", ["SETPROCTITLE"]);
showitem($output, "using extended attributes", ["XATTR"]);
showitem($output, "using libblkid", ["BLKID"]);
showitem($output, "using iconv", ["ICONV"]);
showitem($output, "using pam", ["PAM"]);
print "Using external popt: ".
(($output->{LIBPOPT}->{TYPE} eq "EXT_LIB")?"yes":"no")."\n";
print "Developer mode: ".(enabled($config->{developer})?"yes":"no")."\n";
print "Automatic dependencies: ".
(enabled($config->{automatic_dependencies})
? "yes" : "no (install GNU make >= 3.81 and see --enable-automatic-dependencies)") .
"\n";
print "Building shared libraries: " .
(enabled($config->{BLDSHARED})
? "yes" : "no (not supported on this system)") .
"\n";
print "Using shared libraries internally: " .
(enabled($config->{USESHARED})
? "yes" : "no (specify --enable-dso)") .
"\n";
print "\n";
}
1;