diff options
Diffstat (limited to 'source4/build')
-rw-r--r-- | source4/build/m4/check_make.m4 | 29 | ||||
-rw-r--r-- | source4/build/smb_build/README.txt | 7 | ||||
-rwxr-xr-x | source4/build/smb_build/cflags.pm | 69 | ||||
-rw-r--r-- | source4/build/smb_build/config_mk.pm | 12 | ||||
-rw-r--r-- | source4/build/smb_build/env.pm | 57 | ||||
-rw-r--r-- | source4/build/smb_build/input.pm | 8 | ||||
-rw-r--r-- | source4/build/smb_build/main.pl | 20 | ||||
-rw-r--r-- | source4/build/smb_build/makefile.pm | 249 | ||||
-rw-r--r-- | source4/build/smb_build/output.pm | 7 |
9 files changed, 110 insertions, 348 deletions
diff --git a/source4/build/m4/check_make.m4 b/source4/build/m4/check_make.m4 index d7799649a7..f497684453 100644 --- a/source4/build/m4/check_make.m4 +++ b/source4/build/m4/check_make.m4 @@ -6,35 +6,26 @@ dnl Released under the GNU GPL dnl ------------------------------------------------------- dnl -AC_PATH_PROG(MAKE,make) +AC_PATH_PROGS(MAKE,gmake make) AC_CACHE_CHECK([whether we have GNU make], samba_cv_gnu_make, [ -if $ac_cv_path_MAKE --version | head -1 | grep GNU 2>/dev/null >/dev/null +if ! $ac_cv_path_MAKE --version | head -1 | grep GNU 2>/dev/null >/dev/null then - samba_cv_gnu_make=yes -else - samba_cv_gnu_make=no + AC_MSG_ERROR([Unable to find GNU make]) fi ]) -GNU_MAKE=$samba_cv_gnu_make -AC_SUBST(GNU_MAKE) - -if test "x$GNU_MAKE" = x"yes"; then - AC_CACHE_CHECK([GNU make version], samba_cv_gnu_make_version,[ +AC_CACHE_CHECK([GNU make version], samba_cv_gnu_make_version,[ samba_cv_gnu_make_version=`$ac_cv_path_MAKE --version | head -1 | cut -d " " -f 3 2>/dev/null` ]) GNU_MAKE_VERSION=$samba_cv_gnu_make_version AC_SUBST(GNU_MAKE_VERSION) -fi new_make=no AC_MSG_CHECKING([for GNU make >= 3.81]) -if test x$GNU_MAKE = x"yes"; then - if $PERL -e " \$_ = '$GNU_MAKE_VERSION'; s/@<:@^\d\.@:>@.*//g; exit (\$_ < 3.81);"; then - new_make=yes - fi +if $PERL -e " \$_ = '$GNU_MAKE_VERSION'; s/@<:@^\d\.@:>@.*//g; exit (\$_ < 3.81);"; then + new_make=yes fi AC_MSG_RESULT($new_make) automatic_dependencies=no @@ -46,11 +37,3 @@ AC_ARG_ENABLE(automatic-dependencies, [ automatic_dependencies=no ]) AC_MSG_RESULT($automatic_dependencies) AC_SUBST(automatic_dependencies) - -FIRST_PREREQ="\$*.c" -AC_SUBST(FIRST_PREREQ) - -if test x$GNU_MAKE = xyes; then - FIRST_PREREQ="\$<" -fi - diff --git a/source4/build/smb_build/README.txt b/source4/build/smb_build/README.txt index a5e4db99e0..eac3905cce 100644 --- a/source4/build/smb_build/README.txt +++ b/source4/build/smb_build/README.txt @@ -1,6 +1,5 @@ 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
@@ -29,7 +28,7 @@ EXT_LIB: BINARY:
a BINARY means a executable binary file.
(e.g. 'smbtorture' or 'ldbedit')
- a BINARY typicly has only commandline handling and basic
+ a BINARY typically has only commandline handling and basic
functionality code in it and depends on the functions of
SUBSYSTEM's (REQUIRED_SUBSYSTEMS).
@@ -50,8 +49,6 @@ 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
-------
diff --git a/source4/build/smb_build/cflags.pm b/source4/build/smb_build/cflags.pm deleted file mode 100755 index a4ab90a8cd..0000000000 --- a/source4/build/smb_build/cflags.pm +++ /dev/null @@ -1,69 +0,0 @@ -# SMB Build System -# -# Copyright (C) Jelmer Vernooij 2006 -# Released under the GNU GPL - -package cflags; -use strict; - -my $sort_available = eval "use sort 'stable'; return 1;"; -$sort_available = 0 unless defined($sort_available); - -sub by_path { - return 1 if($a =~ m#^\-I/#); - return -1 if($b =~ m#^\-I/#); - return 0; -} - -sub create_cflags($$$$) { - my $CTX = shift; - my $srcdir = shift; - my $builddir = shift; - my $file = shift; - - open(CFLAGS_TXT,">$file") || die ("Can't open `$file'\n"); - - print CFLAGS_TXT "include mkconfig.mk\n"; - - my $src_ne_build = ($srcdir ne $builddir) ? 1 : 0; - - foreach my $key (values %{$CTX}) { - next unless defined ($key->{OBJ_LIST}); - next unless defined ($key->{FINAL_CFLAGS}); - next unless (@{$key->{FINAL_CFLAGS}} > 0); - - my @sorted_cflags = @{$key->{FINAL_CFLAGS}}; - if ($sort_available) { - @sorted_cflags = sort by_path @{$key->{FINAL_CFLAGS}}; - } - - # Rewrite CFLAGS so that both the source and the build - # directories are in the path. - my @cflags = (); - foreach my $flag (@sorted_cflags) { - if($src_ne_build) { - if($flag =~ m#^-I([^/].*$)#) { - my $dir = $1; - $dir =~ s#^\$\((?:src|build)dir\)/?##; - push(@cflags, "-I$builddir/$dir", "-I$srcdir/$dir"); - next; - } - } - push(@cflags, $flag); - } - - my $cflags = join(' ', @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; diff --git a/source4/build/smb_build/config_mk.pm b/source4/build/smb_build/config_mk.pm index 4d8db8a04e..d8ec646910 100644 --- a/source4/build/smb_build/config_mk.pm +++ b/source4/build/smb_build/config_mk.pm @@ -36,13 +36,8 @@ my $section_types = { "ENABLE" => "bool", - "MANPAGE" => "string", - - "PUBLIC_PROTO_HEADER" => "string", "PRIVATE_PROTO_HEADER" => "string", - "PUBLIC_HEADERS" => "list", - "CFLAGS" => "list", "LDFLAGS" => "list", "STANDARD_VISIBILITY" => "string", @@ -62,7 +57,6 @@ my $section_types = { "OUTPUT_TYPE" => "list", - "MANPAGE" => "string", "PRIVATE_PROTO_HEADER" => "string", "CFLAGS" => "list" @@ -74,7 +68,6 @@ my $section_types = { "ENABLE" => "bool", - "MANPAGE" => "string", "INSTALLDIR" => "string", "PRIVATE_PROTO_HEADER" => "string", @@ -102,11 +95,6 @@ my $section_types = { "ENABLE" => "bool", - "MANPAGE" => "string", - - "PUBLIC_HEADERS" => "list", - - "PUBLIC_PROTO_HEADER" => "string", "PRIVATE_PROTO_HEADER" => "string", "CFLAGS" => "list", diff --git a/source4/build/smb_build/env.pm b/source4/build/smb_build/env.pm deleted file mode 100644 index 76cd8d1a26..0000000000 --- a/source4/build/smb_build/env.pm +++ /dev/null @@ -1,57 +0,0 @@ -# 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->{gnu_make} = ($self->{config}->{GNU_MAKE} eq "yes"); - $self->{automatic_deps} = ($self->{config}->{automatic_dependencies} eq "yes"); -} - -1; diff --git a/source4/build/smb_build/input.pm b/source4/build/smb_build/input.pm index 8c9a6efacc..948f2657b4 100644 --- a/source4/build/smb_build/input.pm +++ b/source4/build/smb_build/input.pm @@ -233,14 +233,6 @@ sub check($$$$$) my ($INPUT, $enabled, $subsys_ot, $lib_ot, $module_ot) = @_; foreach my $part (values %$INPUT) { - 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; diff --git a/source4/build/smb_build/main.pl b/source4/build/smb_build/main.pl index 3ed0327d6d..c3dc46461b 100644 --- a/source4/build/smb_build/main.pl +++ b/source4/build/smb_build/main.pl @@ -10,8 +10,6 @@ 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; @@ -56,7 +54,7 @@ foreach my $key (values %$OUTPUT) { $mkenv->MergedObj($key) if grep(/MERGED_OBJ/, @{$key->{OUTPUT_TYPE}}); $mkenv->StaticLibrary($key) if grep(/STATIC_LIBRARY/, @{$key->{OUTPUT_TYPE}}); if (defined($key->{PC_FILE})) { - push(@{$mkenv->{pc_files}}, "$key->{BASEDIR}/$key->{PC_FILE}"); + $mkenv->output("PC_FILES += $key->{BASEDIR}/$key->{PC_FILE}\n"); } $mkenv->SharedLibraryPrimitives($key) if ($key->{TYPE} eq "LIBRARY") and grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}}); @@ -68,10 +66,8 @@ foreach my $key (values %$OUTPUT) { $key->{TYPE} eq "PYTHON") and grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}}); $mkenv->PythonFiles($key) if defined($key->{PYTHON_FILES}); - $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->ProtoHeader($key) if defined($key->{PRIVATE_PROTO_HEADER}); + $mkenv->CFlags($key); } foreach my $key (values %$OUTPUT) { @@ -88,16 +84,6 @@ foreach my $key (values %$OUTPUT) { $mkenv->write("data.mk"); header::create_smb_build_h($OUTPUT, "include/build.h"); -cflags::create_cflags($OUTPUT, $config::config{srcdir}, - $config::config{builddir}, "extra_cflags.txt"); - summary::show($OUTPUT, \%config::config); -if ($shared_libs_used) { - print <<EOF; -To run binaries without installing, set the following environment variable: - $config::config{LIB_PATH_VAR}=$config::config{builddir}/bin/shared -EOF -} - 1; diff --git a/source4/build/smb_build/makefile.pm b/source4/build/smb_build/makefile.pm index 17474db00e..f2bff1a029 100644 --- a/source4/build/smb_build/makefile.pm +++ b/source4/build/smb_build/makefile.pm @@ -6,32 +6,21 @@ # Released under the GNU GPL package smb_build::makefile; -use smb_build::env; use smb_build::output; use File::Basename; use strict; -use base 'smb_build::env'; use Cwd 'abs_path'; sub new($$$) { my ($myname, $config, $mkfile) = @_; - my $self = new smb_build::env($config); - + my $self = {}; + bless($self, $myname); - $self->{manpages} = []; - $self->{sbin_progs} = []; - $self->{bin_progs} = []; - $self->{static_libs} = []; - $self->{python_dsos} = []; - $self->{python_pys} = []; - $self->{shared_libs} = []; - $self->{headers} = []; - $self->{plugins} = []; - $self->{pc_files} = []; - $self->{proto_headers} = []; + $self->_set_config($config); + $self->{output} = ""; $self->{mkfile} = $mkfile; @@ -41,12 +30,30 @@ sub new($$$) $self->output("################################################\n"); $self->output("\n"); - if (!$self->{automatic_deps}) { - $self->output("ALL_PREDEP = proto\n"); - $self->output(".NOTPARALLEL:\n"); + return $self; +} + +sub _set_config($$) +{ + my ($self, $config) = @_; + + $self->{config} = $config; + + if (not defined($self->{config}->{srcdir})) { + $self->{config}->{srcdir} = '.'; } - return $self; + 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}; + } } sub output($$) @@ -66,23 +73,17 @@ sub _prepare_mk_files($) push (@tmp, $_); } - if ($self->{gnu_make}) { - $self->output(" + $self->output(" ifneq (\$(MAKECMDGOALS),clean) ifneq (\$(MAKECMDGOALS),distclean) ifneq (\$(MAKECMDGOALS),realdistclean) "); - } - $self->output("MK_FILES = " . array2oneperline(\@tmp) . "\n"); - - if ($self->{gnu_make}) { - $self->output(" + $self->output(" endif endif endif "); - } } sub array2oneperline($) @@ -129,10 +130,9 @@ sub SharedModule($$) $sane_subsystem =~ s/^lib//; if ($ctx->{TYPE} eq "PYTHON") { - push (@{$self->{python_dsos}}, - "$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}"); + $self->output("PYTHON_DSOS += $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}\n"); } else { - push (@{$self->{plugins}}, "$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}"); + $self->output("PLUGINS += $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}\n"); $self->output("installplugins:: $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}\n"); $self->output("\t\@echo Installing $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME} as \$(DESTDIR)\$(modulesdir)/$sane_subsystem/$ctx->{LIBRARY_REALNAME}\n"); $self->output("\t\@mkdir -p \$(DESTDIR)\$(modulesdir)/$sane_subsystem/\n"); @@ -220,36 +220,27 @@ sub SharedLibrary($$) { my ($self,$ctx) = @_; - push (@{$self->{shared_libs}}, $ctx->{RESULT_SHARED_LIBRARY}) if (defined($ctx->{SO_VERSION})); + $self->output("SHARED_LIBS += $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}\n") if (defined($ctx->{SO_VERSION})); $self->_prepare_list($ctx, "DEPEND_LIST"); $self->_prepare_list($ctx, "LINK_FLAGS"); - 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\@test \$($ctx->{NAME}_VERSION) = \$($ctx->{NAME}_SOVERSION) || ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$ctx->{LIBRARY_SONAME}"; - } - } - - if (defined($ctx->{LIBRARY_SONAME})) { - $lns .= "\n\t\@ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$ctx->{LIBRARY_DEBUGNAME}"; - } - $self->output(<< "__EOD__" -# $ctx->{RESULT_SHARED_LIBRARY}: \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST) \@echo Linking \$\@ - \@mkdir -p $ctx->{SHAREDDIR} + \@mkdir -p \$(\@D) \@\$(SHLD) \$(LDFLAGS) \$(SHLD_FLAGS) \$(INTERN_LDFLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\ \$($ctx->{NAME}\_FULL_OBJ_LIST) \\ \$($ctx->{NAME}_LINK_FLAGS) \\ - $soarg$lns + \$(if \$(SONAMEFLAG), \$(SONAMEFLAG)$ctx->{LIBRARY_SONAME}) __EOD__ ); - $self->output("\n"); + if ($ctx->{LIBRARY_REALNAME} ne $ctx->{LIBRARY_SONAME}) { + $self->output("\t\@test \$($ctx->{NAME}_VERSION) = \$($ctx->{NAME}_SOVERSION) || ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$ctx->{LIBRARY_SONAME}\n"); + } + $self->output("ifdef $ctx->{NAME}_SOVERSION\n"); + $self->output("\t\@ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$ctx->{LIBRARY_DEBUGNAME}\n"); + $self->output("endif\n"); } sub MergedObj($$) @@ -263,7 +254,7 @@ sub MergedObj($$) # $ctx->{RESULT_MERGED_OBJ}: \$($ctx->{NAME}_OBJ_LIST) \@echo Partially linking \$@ - \@mkdir -p bin/mergedobj + \@mkdir -p \$(\@D) \$(PARTLINK) -o \$@ \$($ctx->{NAME}_OBJ_LIST) __EOD__ @@ -276,43 +267,23 @@ sub StaticLibrary($$) return unless (defined($ctx->{OBJ_FILES})); - push (@{$self->{static_libs}}, $ctx->{RESULT_STATIC_LIBRARY}) if ($ctx->{TYPE} eq "LIBRARY"); + $self->output("STATIC_LIBS += $ctx->{TARGET_STATIC_LIBRARY}\n") if ($ctx->{TYPE} eq "LIBRARY"); $self->output("$ctx->{NAME}_OUTPUT = $ctx->{OUTPUT}\n"); $self->_prepare_list($ctx, "FULL_OBJ_LIST"); - $self->output(<< "__EOD__" -# -$ctx->{RESULT_STATIC_LIBRARY}: \$($ctx->{NAME}_FULL_OBJ_LIST) - \@echo Linking \$@ - \@rm -f \$@ - \@mkdir -p $ctx->{STATICDIR} - \@\$(STLD) \$(STLD_FLAGS) \$@ \$($ctx->{NAME}_FULL_OBJ_LIST) - -__EOD__ -); -} - -sub Header($$) -{ - my ($self,$ctx) = @_; - - foreach (@{$ctx->{PUBLIC_HEADERS}}) { - push (@{$self->{headers}}, output::add_dir_str($ctx->{BASEDIR}, $_)); - } + $self->output("$ctx->{RESULT_STATIC_LIBRARY}: \$($ctx->{NAME}_FULL_OBJ_LIST)\n"); } sub Binary($$) { my ($self,$ctx) = @_; - my $extradir = ""; - unless (defined($ctx->{INSTALLDIR})) { } elsif ($ctx->{INSTALLDIR} eq "SBINDIR") { - push (@{$self->{sbin_progs}}, $ctx->{RESULT_BINARY}); + $self->output("SBIN_PROGS += bin/$ctx->{BINARY}\n"); } elsif ($ctx->{INSTALLDIR} eq "BINDIR") { - push (@{$self->{bin_progs}}, $ctx->{RESULT_BINARY}); + $self->output("BIN_PROGS += bin/$ctx->{BINARY}\n"); } $self->output("binaries:: $ctx->{TARGET_BINARY}\n"); @@ -350,103 +321,34 @@ sub PythonFiles($$) foreach (@{$ctx->{PYTHON_FILES}}) { my $target = "bin/python/".basename($_); my $source = output::add_dir_str($ctx->{BASEDIR}, $_); - $self->output("$target: $source\n" . - "\tmkdir -p \$(builddir)/bin/python\n" . - "\tcp $source \$@\n\n"); - push (@{$self->{python_pys}}, $target); + $self->output("$target: $source\n\n"); + $self->output("PYTHON_PYS += $target\n"); } } -sub Manpage($$) -{ - my ($self,$ctx) = @_; - - my $path = output::add_dir_str($ctx->{BASEDIR}, $ctx->{MANPAGE}); - push (@{$self->{manpages}}, $path); -} - sub ProtoHeader($$) { my ($self,$ctx) = @_; - my $target = ""; - my $comment = "Creating "; - - my $priv = undef; - my $pub = undef; + my $priv = output::add_dir_str($ctx->{BASEDIR}, $ctx->{PRIVATE_PROTO_HEADER}); + $self->output("PROTO_HEADERS += $priv\n"); - if (defined($ctx->{PRIVATE_PROTO_HEADER})) { - $priv = output::add_dir_str($ctx->{BASEDIR}, $ctx->{PRIVATE_PROTO_HEADER}); - $target .= $priv; - $comment .= $priv; - if (defined($ctx->{PUBLIC_PROTO_HEADER})) { - $comment .= " and "; - $target.= " "; - } - push (@{$self->{proto_headers}}, $priv); - } else { - $ctx->{PRIVATE_PROTO_HEADER} = $ctx->{PUBLIC_PROTO_HEADER}; - $priv = output::add_dir_str($ctx->{BASEDIR}, $ctx->{PRIVATE_PROTO_HEADER}); - } - - if (defined($ctx->{PUBLIC_PROTO_HEADER})) { - $pub = output::add_dir_str($ctx->{BASEDIR}, $ctx->{PUBLIC_PROTO_HEADER}); - $comment .= $pub; - $target .= $pub; - push (@{$self->{proto_headers}}, $pub); - } else { - $ctx->{PUBLIC_PROTO_HEADER} = $ctx->{PRIVATE_PROTO_HEADER}; - $pub = output::add_dir_str($ctx->{BASEDIR}, $ctx->{PUBLIC_PROTO_HEADER}); - } - - $self->output("$pub: $ctx->{MK_FILE} \$($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=$priv --public=$pub \$($ctx->{NAME}_OBJ_LIST)\n\n"); + $self->output("$priv: $ctx->{MK_FILE} \$($ctx->{NAME}_OBJ_LIST:.o=.c) \$(srcdir)/script/mkproto.pl\n"); + $self->output("\t\@echo \"Creating \$@\"\n"); + $self->output("\t\@mkdir -p \$(\@D)\n"); + $self->output("\t\@\$(PERL) \$(srcdir)/script/mkproto.pl --srcdir=\$(srcdir) --builddir=\$(builddir) --all=\$@ \$($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("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("PYTHON_PYS = " . array2oneperline($self->{python_pys}) . "\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("PLUGINS = " . array2oneperline($self->{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) -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 \$(srcdir)/static_deps.mk\n"); - } - open(MAKEFILE,">$file") || die ("Can't open $file\n"); print MAKEFILE $self->{output}; close(MAKEFILE); @@ -454,4 +356,51 @@ endif print __FILE__.": creating $file\n"; } +my $sort_available = eval "use sort 'stable'; return 1;"; +$sort_available = 0 unless defined($sort_available); + +sub by_path { + return 1 if($a =~ m#^\-I/#); + return -1 if($b =~ m#^\-I/#); + return 0; +} + +sub CFlags($$) +{ + my ($self, $key) = @_; + + my $srcdir = $self->{config}->{srcdir}; + my $builddir = $self->{config}->{builddir}; + + my $src_ne_build = ($srcdir ne $builddir) ? 1 : 0; + + return unless defined ($key->{OBJ_LIST}); + return unless defined ($key->{FINAL_CFLAGS}); + return unless (@{$key->{FINAL_CFLAGS}} > 0); + + my @sorted_cflags = @{$key->{FINAL_CFLAGS}}; + if ($sort_available) { + @sorted_cflags = sort by_path @{$key->{FINAL_CFLAGS}}; + } + + # Rewrite CFLAGS so that both the source and the build + # directories are in the path. + my @cflags = (); + foreach my $flag (@sorted_cflags) { + if($src_ne_build) { + if($flag =~ m#^-I([^/].*$)#) { + my $dir = $1; + $dir =~ s#^\$\((?:src|build)dir\)/?##; + push(@cflags, "-I$builddir/$dir", "-I$srcdir/$dir"); + next; + } + } + push(@cflags, $flag); + } + + my $cflags = join(' ', @cflags); + + $self->output("\$(patsubst %.ho,%.d,\$(key->{NAME}_OBJ_LIST:.o=.d)) \$($key->{NAME}_OBJ_LIST): CFLAGS+= $cflags\n"); +} + 1; diff --git a/source4/build/smb_build/output.pm b/source4/build/smb_build/output.pm index ff9afe8e8c..4ae4a62cf4 100644 --- a/source4/build/smb_build/output.pm +++ b/source4/build/smb_build/output.pm @@ -101,9 +101,6 @@ sub generate_merged_obj($) $lib->{MERGED_OBJNAME} = lc($link_name).".o"; $lib->{RESULT_MERGED_OBJ} = $lib->{OUTPUT_MERGED_OBJ} = "bin/mergedobj/$lib->{MERGED_OBJNAME}"; $lib->{TARGET_MERGED_OBJ} = $lib->{RESULT_MERGED_OBJ}; - } else { - $lib->{TARGET_MERGED_OBJ} = ""; - $lib->{RESULT_MERGED_OBJ} = ""; } } @@ -124,10 +121,6 @@ sub generate_static_library($) $lib->{TARGET_STATIC_LIBRARY} = $lib->{RESULT_STATIC_LIBRARY}; $lib->{STATICDIR} = 'bin/static'; $lib->{OUTPUT_STATIC_LIBRARY} = "-l".lc($link_name); - } else { - $lib->{RESULT_STATIC_LIBRARY} = ""; - $lib->{TARGET_STATIC_LIBRARY} = ""; - $lib->{OUTPUT_STATIC_LIBRARY} = ""; } } |