summaryrefslogtreecommitdiff
path: root/source4/script
diff options
context:
space:
mode:
Diffstat (limited to 'source4/script')
-rwxr-xr-xsource4/script/build_smb_interfaces.pl161
-rwxr-xr-xsource4/script/buildtree.pl40
-rwxr-xr-xsource4/script/configure_check_unused.pl124
-rwxr-xr-xsource4/script/depfilter.py50
-rwxr-xr-xsource4/script/extract_allparms.sh2
-rwxr-xr-xsource4/script/find_unused_macros.pl38
-rwxr-xr-xsource4/script/find_unused_makefilevars.pl46
-rwxr-xr-xsource4/script/find_unused_options.sh37
-rwxr-xr-xsource4/script/findstatic.pl70
-rwxr-xr-xsource4/script/gdb_backtrace87
-rw-r--r--source4/script/gdb_backtrace_test.c42
-rwxr-xr-xsource4/script/gdb_run20
-rwxr-xr-xsource4/script/harness2subunit.pl32
-rwxr-xr-xsource4/script/installdat.sh23
-rwxr-xr-xsource4/script/installdirs.sh17
-rwxr-xr-xsource4/script/installheader.pl107
-rwxr-xr-xsource4/script/installlib.sh30
-rwxr-xr-xsource4/script/installman.sh30
-rwxr-xr-xsource4/script/installmisc.sh38
-rwxr-xr-xsource4/script/installmodules.sh33
-rwxr-xr-xsource4/script/installpc.sh16
-rwxr-xr-xsource4/script/installscripts.sh47
-rwxr-xr-xsource4/script/installswat.sh37
-rwxr-xr-xsource4/script/minimal_includes.pl150
-rwxr-xr-xsource4/script/mkinstalldirs38
-rwxr-xr-xsource4/script/mkproto.pl281
-rwxr-xr-xsource4/script/mkrelease.sh30
-rwxr-xr-xsource4/script/mkversion.sh133
-rwxr-xr-xsource4/script/pkg-config145
-rwxr-xr-xsource4/script/revert.sh18
-rwxr-xr-xsource4/script/uninstallheader.sh35
-rwxr-xr-xsource4/script/uninstalllib.sh35
-rwxr-xr-xsource4/script/uninstallman.sh27
-rwxr-xr-xsource4/script/uninstallmodules.sh37
-rwxr-xr-xsource4/script/uninstallscripts.sh36
-rwxr-xr-xsource4/script/update-proto.pl242
-rwxr-xr-xsource4/script/valgrind_run9
37 files changed, 2343 insertions, 0 deletions
diff --git a/source4/script/build_smb_interfaces.pl b/source4/script/build_smb_interfaces.pl
new file mode 100755
index 0000000000..5fac94ca6e
--- /dev/null
+++ b/source4/script/build_smb_interfaces.pl
@@ -0,0 +1,161 @@
+#!/usr/bin/perl
+#
+# Create ejs interfaces for structures in a C header file
+#
+
+use File::Basename;
+use Data::Dumper;
+
+#
+# Generate parse tree for header file
+#
+
+my $file = shift;
+require smb_interfaces;
+my $parser = new smb_interfaces;
+$header = $parser->parse($file);
+
+#
+# Make second pass over tree to make it easier to process.
+#
+
+sub flatten_structs($) {
+ my $obj = shift;
+ my $s = { %$obj };
+
+ # Map NAME, STRUCT_NAME and UNION_NAME elements into a more likeable
+ # property.
+
+ if (defined($obj->{STRUCT_NAME}) or defined($obj->{UNION_NAME})) {
+
+ $s->{TYPE_DEFINED} = defined($obj->{STRUCT_NAME}) ? $obj->{STRUCT_NAME}
+ : $obj->{UNION_NAME};
+
+ delete $s->{STRUCT_NAME};
+ delete $s->{UNION_NAME};
+ }
+
+ # Create a new list of structure fields with flattened names
+
+ foreach my $elt (@{$obj->{DATA}}) {
+ foreach my $name (@{$elt->{NAME}}) {
+ my $new_elt = { %$elt };
+ $new_elt->{NAME} = $name;
+# $new_elt->{PARENT} = $s;
+ push(@{$s->{FIELDS}}, flatten_structs($new_elt));
+ }
+ }
+
+ delete $s->{DATA};
+
+ return $s;
+}
+
+@newheader = map { flatten_structs($_) } @{$header};
+
+#
+# Generate implementation
+#
+
+my $basename = basename($file, ".h");
+stat "libcli/gen_raw" || mkdir("libcli/gen_raw") || die("mkdir");
+
+open(FILE, ">libcli/gen_raw/ejs_${basename}.c");
+
+print FILE "/* EJS wrapper functions auto-generated by build_smb_interfaces.pl */\n\n";
+
+print FILE "#include \"includes.h\"\n";
+print FILE "#include \"scripting/ejs/smbcalls.h\"\n";
+print FILE "#include \"lib/appweb/ejs/ejs.h\"\n";
+print FILE "#include \"scripting/ejs/ejsrpc.h\"\n"; # TODO: remove this
+print FILE "\n";
+
+sub transfer_element($$$) {
+ my $dir = shift;
+ my $prefix = shift;
+ my $elt = shift;
+
+ $type = $elt->{TYPE};
+ $type =~ s/_t$//;
+
+ print FILE "\tNDR_CHECK(ejs_${dir}_$type(ejs, v, \"$prefix.$elt->{NAME}\"));\n";
+}
+
+sub transfer_struct($$) {
+ my $dir = shift;
+ my $struct = shift;
+
+ foreach my $field (@{$struct->{FIELDS}}) {
+ next if $dir eq "pull" and $field->{NAME} eq "out";
+ next if $dir eq "push" and $field->{NAME} eq "in";
+
+ if ($field->{TYPE} eq "struct") {
+ foreach $subfield (@{$field->{FIELDS}}) {
+ transfer_element($dir, $field->{NAME}, $subfield);
+ }
+ } else {
+ transfer_element($dir, $struct->{NAME}, $field);
+ }
+ }
+}
+
+# Top level call functions
+
+foreach my $s (@newheader) {
+
+ if ($s->{TYPE} eq "struct") {
+
+ # Push/pull top level struct
+
+ print FILE "NTSTATUS ejs_pull_$s->{TYPE_DEFINED}(struct ejs_rpc *ejs, struct MprVar *v, struct $s->{TYPE_DEFINED} *r)\n";
+ print FILE "{\n";
+
+ transfer_struct("pull", $s);
+
+ print FILE "\n\treturn NT_STATUS_OK;\n";
+ print FILE "}\n\n";
+
+ print FILE "NTSTATUS ejs_push_$s->{TYPE_DEFINED}(struct ejs_rpc *ejs, struct MprVar *v, const struct $s->{TYPE_DEFINED} *r)\n";
+ print FILE "{\n";
+
+ transfer_struct("push", $s);
+
+ print FILE "\n\treturn NT_STATUS_OK;\n";
+ print FILE "}\n\n";
+
+ # Function call
+
+ print FILE "static int ejs_$s->{TYPE_DEFINED}(int eid, int argc, struct MprVar **argv)\n";
+ print FILE "{\n";
+ print FILE "\treturn ejs_raw_call(eid, argc, argv, (ejs_pull_function_t)ejs_pull_$s->{TYPE_DEFINED}, (ejs_push_function_t)ejs_push_$s->{TYPE_DEFINED});\n";
+ print FILE "}\n\n";
+
+ } else {
+
+ # Top level union
+
+ foreach my $arm (@{$s->{FIELDS}}) {
+
+ # Push/pull union arm
+
+ print FILE "NTSTATUS ejs_pull_$s->{TYPE_DEFINED}_$arm->{NAME}(struct ejs_rpc *ejs, struct MprVar *v, union $s->{TYPE_DEFINED} *r)\n";
+ print FILE "{\n";
+
+ transfer_struct("pull", $arm);
+
+ print FILE "\n\treturn NT_STATUS_OK;\n";
+ print FILE "}\n\n";
+
+ print FILE "NTSTATUS ejs_push_$s->{TYPE_DEFINED}_$arm->{NAME}(struct ejs_rpc *ejs, struct MprVar *v, const union $s->{TYPE_DEFINED} *r)\n";
+ print FILE "{\n";
+
+ transfer_struct("push", $arm);
+
+ print FILE "\n\treturn NT_STATUS_OK;\n";
+ print FILE "}\n\n";
+
+ }
+ }
+}
+
+close(FILE);
diff --git a/source4/script/buildtree.pl b/source4/script/buildtree.pl
new file mode 100755
index 0000000000..a40036aa55
--- /dev/null
+++ b/source4/script/buildtree.pl
@@ -0,0 +1,40 @@
+#! /usr/bin/env perl -w
+ eval 'exec /usr/bin/env perl -S $0 ${1+"$@"}'
+ if 0; #$running_under_some_shell
+
+use strict;
+use File::Find ();
+use File::Path qw(mkpath);
+use Cwd 'abs_path';
+
+# Set the variable $File::Find::dont_use_nlink if you're using AFS,
+# since AFS cheats.
+
+# for the convenience of &wanted calls, including -eval statements:
+use vars qw/*name *dir *prune/;
+*name = *File::Find::name;
+*dir = *File::Find::dir;
+*prune = *File::Find::prune;
+my $builddir = abs_path($ENV{builddir});
+my $srcdir = abs_path($ENV{srcdir});
+sub wanted;
+
+
+
+# Traverse desired filesystems
+File::Find::find({wanted => \&wanted, no_chdir => 1}, $srcdir);
+exit;
+
+
+sub wanted {
+ my ($dev,$ino,$mode,$nlink,$uid,$gid,$newdir);
+
+ if ((($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) &&
+ (-d _) && (($newdir = abs_path($_)) !~ /$builddir/))
+ {
+ $newdir =~ s!$srcdir!$builddir!;
+ mkpath($newdir);
+ print("Creating $newdir\n");
+ }
+}
+
diff --git a/source4/script/configure_check_unused.pl b/source4/script/configure_check_unused.pl
new file mode 100755
index 0000000000..52d8deeb27
--- /dev/null
+++ b/source4/script/configure_check_unused.pl
@@ -0,0 +1,124 @@
+#!/usr/bin/perl
+# Script that finds macros in a configure script that are not
+# used in a set of C files.
+# Copyright Jelmer Vernooij <jelmer@samba.org>, GPL
+#
+# Usage: ./$ARGV[0] configure.in [c-files...]
+
+use strict;
+
+sub autoconf_parse($$$$)
+{
+ my $in = shift;
+ my $defines = shift;
+ my $functions = shift;
+ my $headers = shift;
+
+ open(IN, $in) or die("Can't open $in");
+
+ my $ln = 0;
+
+ foreach(<IN>) {
+ $ln++;
+
+ if(/AC_DEFINE\(([^,]+),/) {
+ $defines->{$1} = "$in:$ln";
+ }
+
+ if(/AC_CHECK_FUNCS\(\[*(.[^],)]+)/) {
+ foreach(split / /, $1) {
+ $functions->{$_} = "$in:$ln";
+ }
+ }
+
+ if(/AC_CHECK_FUNC\(([^,)]+)/) {
+ $functions->{$1} = "$in:$ln";
+ }
+
+ if(/AC_CHECK_HEADERS\(\[*([^],)]+)/) {
+ foreach(split / /, $1) {
+ $headers->{$_} = "$in:$ln";
+ }
+ }
+
+ if(/AC_CHECK_HEADER\(([^,)]+)/) {
+ $headers->{$1} = "$in:$ln";
+ }
+
+ if(/sinclude\(([^,]+)\)/) {
+ autoconf_parse($1, $defines, $functions, $headers);
+ }
+ }
+
+ close IN;
+}
+
+# Return the symbols and headers used by a C file
+sub cfile_parse($$$)
+{
+ my $in = shift;
+ my $symbols = shift;
+ my $headers = shift;
+
+ open(FI, $in) or die("Can't open $in");
+ my $ln = 0;
+ my $line;
+ while($line = <FI>) {
+ $ln++;
+ $_ = $line;
+ if (/\#([ \t]*)include ["<]([^">]+)/) {
+ $headers->{$2} = "$in:$ln";
+ }
+
+ $_ = $line;
+ while(/([A-Za-z0-9_]+)/g) {
+ $symbols->{$1} = "$in:$ln";
+ }
+ }
+ close FI;
+}
+
+my %ac_defines = ();
+my %ac_func_checks = ();
+my %ac_headers = ();
+my %symbols = ();
+my %headers = ();
+
+if (scalar(@ARGV) <= 1) {
+ print("Usage: configure_find_unused.pl configure.in [CFILE...]\n");
+ exit 0;
+}
+
+autoconf_parse(shift(@ARGV), \%ac_defines, \%ac_func_checks, \%ac_headers);
+cfile_parse($_, \%symbols, \%headers) foreach(@ARGV);
+
+(keys %ac_defines) or warn("No defines found in configure.in file, parse error?");
+
+foreach (keys %ac_defines) {
+ if (not defined($symbols{$_})) {
+ print "$ac_defines{$_}: Autoconf-defined $_ is unused\n";
+ }
+}
+
+(keys %ac_func_checks) or warn("No function checks found in configure.in file, parse error?");
+
+foreach (keys %ac_func_checks) {
+ my $def = "HAVE_".uc($_);
+ if (not defined($symbols{$_})) {
+ print "$ac_func_checks{$_}: Autoconf-checked function `$_' is unused\n";
+ } elsif (not defined($symbols{$def})) {
+ print "$ac_func_checks{$_}: Autoconf-define `$def' for function `$_' is unused\n";
+ }
+}
+
+(keys %ac_headers) or warn("No headers found in configure.in file, parse error?");
+
+foreach (keys %ac_headers) {
+ my $def = "HAVE_".uc($_);
+ $def =~ s/[\/\.]/_/g;
+ if (not defined($headers{$_})) {
+ print "$ac_headers{$_}: Autoconf-checked header `$_' is unused\n";
+ } elsif (not defined($symbols{$def})) {
+ print "$ac_headers{$_}: Autoconf-define `$def' for header `$_' is unused\n";
+ }
+}
diff --git a/source4/script/depfilter.py b/source4/script/depfilter.py
new file mode 100755
index 0000000000..74d1d179c7
--- /dev/null
+++ b/source4/script/depfilter.py
@@ -0,0 +1,50 @@
+#!/usr/bin/python
+#
+# Filter out arcs in a dotty graph that are at or below a certain
+# node. This is useful for visualising parts of the dependency graph.
+#
+
+# Command line stuff
+
+import sys, sre
+
+if len(sys.argv) != 2:
+ print 'Usage: depfilter.py NODE'
+ sys.exit(1)
+
+top = sys.argv[1]
+
+# Read in dot file
+
+lines = sys.stdin.readlines()
+
+graph = {}
+
+for arc in lines[1:-1]:
+ match = sre.search('"(.*)" -> "(.*)"', arc)
+ n1, n2 = match.group(1), match.group(2)
+ if not graph.has_key(n1):
+ graph[n1] = []
+ graph[n1].append(n2)
+
+# Create subset of 'graph' rooted at 'top'
+
+subgraph = {}
+
+def add_deps(node):
+ if graph.has_key(node) and not subgraph.has_key(node):
+ subgraph[node] = graph[node]
+ for n in graph[node]:
+ add_deps(n)
+
+add_deps(top)
+
+# Generate output
+
+print lines[0],
+
+for key, value in subgraph.items():
+ for n in value:
+ print '\t"%s" -> "%s"' % (key, n)
+
+print lines[-1],
diff --git a/source4/script/extract_allparms.sh b/source4/script/extract_allparms.sh
new file mode 100755
index 0000000000..f16068b3fd
--- /dev/null
+++ b/source4/script/extract_allparms.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+grep '{".*P_[GL]' param/loadparm.c | sed -e 's/&.*$//g' -e 's/",.*P_LOCAL.*$/ S/' -e 's/",.*P_GLOBAL.*$/ G/' -e 's/^ .*{"//g' | sort -f
diff --git a/source4/script/find_unused_macros.pl b/source4/script/find_unused_macros.pl
new file mode 100755
index 0000000000..8886835fa3
--- /dev/null
+++ b/source4/script/find_unused_macros.pl
@@ -0,0 +1,38 @@
+#!/usr/bin/perl
+# Script that reads in C files and prints defines that are used nowhere in the
+# code
+
+# Arguments: C and H files
+# Copyright Jelmer Vernooij <jelmer@samba.org>, GPL
+
+use strict;
+
+my %defined;
+my %used;
+my %files;
+
+my $tmp;
+while($tmp = shift) {
+ $files{$tmp} = $tmp;
+ open(FI, $tmp);
+ my $ln = 0;
+ while(<FI>) {
+ $ln++;
+ my $line = $_;
+ my $cur = "";
+ if(/^#define ([A-Za-z0-9_]+)/) {
+ $defined{$1} = "$tmp:$ln";
+ $cur = $1;
+ }
+
+ $_ = $line;
+ while(/([A-Za-z0-9_]+)/sgm) {
+ if($cur ne $1) { $used{$1} = "$tmp:$ln"; }
+ }
+ }
+ close FI;
+}
+
+foreach(keys %defined) {
+ if(!$used{$_}) { print "$defined{$_}: Macro `$_' is unused\n"; }
+}
diff --git a/source4/script/find_unused_makefilevars.pl b/source4/script/find_unused_makefilevars.pl
new file mode 100755
index 0000000000..1bed1228ec
--- /dev/null
+++ b/source4/script/find_unused_makefilevars.pl
@@ -0,0 +1,46 @@
+#!/usr/bin/perl
+# Script that reads in Makefile.in and outputs the names of all
+# used but undefined vars and all defined but unused vars
+# Copyright Jelmer Vernooij <jelmer@samba.org>
+
+# Arguments:
+# 1: Makefile.in
+#
+
+my %references;
+my %defines;
+
+# First, make a list of defines in configure
+$in = shift;
+
+open(IN, $in);
+while(<IN>) {
+ my $line = $_;
+ while($line =~ /^\b([a-zA-Z0-9_][a-zA-Z0-9_]*)\b[ \t]*=.*/sgm) {
+ $defines{$1} = 1;
+ }
+ while($line =~ /\$\(([a-zA-Z0-9_][a-zA-Z0-9_]*)\)/sgm) {
+ $references{$1} = 1;
+ }
+}
+close IN;
+
+print "##### DEFINED BUT UNUSED: #####\n";
+foreach(%defines) {
+# print $_." defined\n";
+
+ if ($_ != 1) {
+ if ($references{$_} != 1) {
+ print $_."\n";
+ }
+ }
+}
+
+print "##### USED BUT UNDEFINED: #####\n";
+foreach(%references) {
+ if ($_ != 1) {
+ if ($defines{$_} != 1) {
+ print $_."\n";
+ }
+ }
+}
diff --git a/source4/script/find_unused_options.sh b/source4/script/find_unused_options.sh
new file mode 100755
index 0000000000..d554580959
--- /dev/null
+++ b/source4/script/find_unused_options.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+#
+# this script finds unused lp_*() functions
+#
+# use it like this:
+#
+# user@host:~/samba/source>./script/find_unused_options.sh
+#
+
+LIST_GLOBAL=`grep '^FN_GLOBAL' param/loadparm.c |sed -e's/^FN_GLOBAL.*(\(.*\).*,.*\(&Globals\..*\)).*/\1:\2/'`
+
+LIST_LOCAL=`grep '^FN_LOCAL' param/loadparm.c |sed -e's/^FN_LOCAL.*(\(.*\).*,[ ]*\(.*\)).*/\1:\2/'`
+
+CFILES=`find . -name "*.c"`
+
+for i in $LIST_GLOBAL;do
+ key=`echo $i|cut -d ':' -f1`
+ val=`echo $i|cut -d ':' -f2`
+
+ found=`grep "$key[ ]*()" $CFILES`
+ if test -z "$found"; then
+ echo "Not Used Global: $key() -> $val"
+ fi
+done
+
+for i in $LIST_LOCAL;do
+ key=`echo $i|cut -d ':' -f1`
+ val=`echo $i|cut -d ':' -f2`
+
+ found=`grep "$key[ ]*(" $CFILES`
+
+ if test -z "$found"; then
+ echo "Not Used LOCAL: $key() -> $val"
+ fi
+done
+
+echo "# do a 'make clean;make everything' before removing anything!"
diff --git a/source4/script/findstatic.pl b/source4/script/findstatic.pl
new file mode 100755
index 0000000000..43a4916435
--- /dev/null
+++ b/source4/script/findstatic.pl
@@ -0,0 +1,70 @@
+#!/usr/bin/perl -w
+# find a list of fns and variables in the code that could be static
+# usually called with something like this:
+# findstatic.pl `find . -name "*.o"`
+# Andrew Tridgell <tridge@samba.org>
+
+use strict;
+
+# use nm to find the symbols
+my($saved_delim) = $/;
+undef $/;
+my($syms) = `nm -o @ARGV`;
+$/ = $saved_delim;
+
+my(@lines) = split(/\n/s, $syms);
+
+my(%def);
+my(%undef);
+my(%stype);
+
+my(%typemap) = (
+ "T" => "function",
+ "C" => "uninitialised variable",
+ "D" => "initialised variable"
+ );
+
+
+# parse the symbols into defined and undefined
+for (my($i)=0; $i <= $#{@lines}; $i++) {
+ my($line) = $lines[$i];
+ if ($line =~ /(.*):[a-f0-9]* ([TCD]) (.*)/) {
+ my($fname) = $1;
+ my($symbol) = $3;
+ push(@{$def{$fname}}, $symbol);
+ $stype{$symbol} = $2;
+ }
+ if ($line =~ /(.*):\s* U (.*)/) {
+ my($fname) = $1;
+ my($symbol) = $2;
+ push(@{$undef{$fname}}, $symbol);
+ }
+}
+
+# look for defined symbols that are never referenced outside the place they
+# are defined
+foreach my $f (keys %def) {
+ print "Checking $f\n";
+ my($found_one) = 0;
+ foreach my $s (@{$def{$f}}) {
+ my($found) = 0;
+ foreach my $f2 (keys %undef) {
+ if ($f2 ne $f) {
+ foreach my $s2 (@{$undef{$f2}}) {
+ if ($s2 eq $s) {
+ $found = 1;
+ $found_one = 1;
+ }
+ }
+ }
+ }
+ if ($found == 0) {
+ my($t) = $typemap{$stype{$s}};
+ print " '$s' is unique to $f ($t)\n";
+ }
+ }
+ if ($found_one == 0) {
+ print " all symbols in '$f' are unused (main program?)\n";
+ }
+}
+
diff --git a/source4/script/gdb_backtrace b/source4/script/gdb_backtrace
new file mode 100755
index 0000000000..826381e900
--- /dev/null
+++ b/source4/script/gdb_backtrace
@@ -0,0 +1,87 @@
+#!/bin/sh
+
+BASENAME=`basename $0`
+
+if [ -n "$VALGRIND" -o -n "$SMBD_VALGRIND" ]; then
+ echo "${BASENAME}: Not running debugger under valgrind"
+ exit 1
+fi
+
+# we want everything on stderr, so the program is not disturbed
+exec 1>&2
+
+BASENAME=`basename $0`
+UNAME=`uname`
+
+PID=$1
+BINARY=$2
+
+test x"${PID}" = x"" && {
+ echo "Usage: ${BASENAME} <pid> [<binary>]"
+ exit 1
+}
+
+DB_LIST="gdb"
+case "${UNAME}" in
+ #
+ # on Tru64 we need to try ladebug first
+ # because gdb crashes itself...
+ #
+ OSF1)
+ DB_LIST="ladebug ${DB_LIST}"
+ ;;
+esac
+
+for DB in ${DB_LIST}; do
+ DB_BIN=`which ${DB} 2>/dev/null | grep '^/'`
+ test x"${DB_BIN}" != x"" && {
+ break
+ }
+done
+
+test x"${DB_BIN}" = x"" && {
+ echo "${BASENAME}: ERROR: No debugger found."
+ exit 1
+}
+
+#
+# we first try to use /proc/${PID}/exe
+# then fallback to the binary from the commandline
+# then we search for the commandline argument with
+# 'which'
+#
+test -f "/proc/${PID}/exe" && BINARY="/proc/${PID}/exe"
+test x"${BINARY}" = x"" && BINARY="/proc/${PID}/exe"
+test -f "${BINARY}" || BINARY=`which ${BINARY}`
+
+test -f "${BINARY}" || {
+ echo "${BASENAME}: ERROR: Cannot find binary '${BINARY}'."
+ exit 1
+}
+
+echo "${BASENAME}: Trying to use ${DB_BIN} on ${BINARY} on PID ${PID}"
+
+BATCHFILE_PRE=/tmp/gdb_backtrace_pre.$$
+BATCHFILE_MAIN=/tmp/gdb_backtrace_main.$$
+case "${DB}" in
+ ladebug)
+cat << EOF > ${BATCHFILE_PRE}
+set \$stoponattach
+EOF
+
+cat << EOF > ${BATCHFILE_MAIN}
+where
+quit
+EOF
+ ${DB_BIN} -c "${BATCHFILE_MAIN}" -i "${BATCHFILE_PRE}" -pid "${PID}" "${BINARY}"
+ ;;
+ gdb)
+cat << EOF > ${BATCHFILE_MAIN}
+set height 1000
+bt full
+quit
+EOF
+ ${DB_BIN} -x "${BATCHFILE_MAIN}" "${BINARY}" "${PID}"
+ ;;
+esac
+/bin/rm -f ${BATCHFILE_PRE} ${BATCHFILE_MAIN}
diff --git a/source4/script/gdb_backtrace_test.c b/source4/script/gdb_backtrace_test.c
new file mode 100644
index 0000000000..506784f675
--- /dev/null
+++ b/source4/script/gdb_backtrace_test.c
@@ -0,0 +1,42 @@
+/*
+
+add a usefull tool to test the gdb_backtrace script
+
+just compile it with
+cc -g -o gdb_backtrace_test gdb_backtrace_test.c
+
+and run it in the same directory where your gdb_backtrace script is.
+
+2006 - Stefan Metzmacher <metze@samba.org>
+
+*/
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <signal.h>
+
+static const char *prog;
+
+static void sig_fault(int sig)
+{
+ int ret;
+ char cmdstr[200];
+
+ snprintf(cmdstr, sizeof(cmdstr),
+ "./gdb_backtrace %u %s",
+ getpid(), prog);
+ printf("sig_fault start: %s\n", cmdstr);
+ ret = system(cmdstr);
+ printf("sig_fault end: %d\n", ret);
+}
+
+int main(int argc, const char **argv)
+{
+ prog = argv[0];
+
+ signal(SIGABRT, sig_fault);
+
+ abort();
+ return 0;
+}
diff --git a/source4/script/gdb_run b/source4/script/gdb_run
new file mode 100755
index 0000000000..8ad101ed60
--- /dev/null
+++ b/source4/script/gdb_run
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+ENV="$1"
+
+shift 1
+
+if test -z "$TMPDIR"; then
+ TMPDIR="/tmp"
+fi
+
+TMPFILE=$TMPDIR/gdb_run.$$
+cat << EOF > $TMPFILE
+run
+bt
+EOF
+
+trap "/bin/rm -f $TMPFILE" EXIT
+CMD="gdb -x $TMPFILE --args $@"
+echo $CMD
+eval $ENV "$CMD"
diff --git a/source4/script/harness2subunit.pl b/source4/script/harness2subunit.pl
new file mode 100755
index 0000000000..9f2391ad6c
--- /dev/null
+++ b/source4/script/harness2subunit.pl
@@ -0,0 +1,32 @@
+#!/usr/bin/perl
+
+my $firstline = 1;
+my $error = 0;
+while(<STDIN>) {
+ if ($firstline) {
+ $firstline = 0;
+ next;
+ }
+ if (/^not ok (\d+) - (.*)$/) {
+ print "test: $2\n";
+ print "failure: $2\n";
+ $error = 1;
+ } elsif (/^ok (\d+) - (.*)$/) {
+ print "test: $2\n";
+ print "success: $2\n";
+ } elsif (/^ok (\d+)$/) {
+ print "test: $1\n";
+ print "success: $1\n";
+ } elsif (/^ok (\d+) # skip (.*)$/) {
+ print "test: $1\n";
+ print "skip: $1 [\n$2\n]\n";
+ } elsif (/^not ok (\d+)$/) {
+ print "test: $1\n";
+ print "failure: $1\n";
+ $error = 1;
+ } else {
+ print;
+ }
+}
+exit $error;
+
diff --git a/source4/script/installdat.sh b/source4/script/installdat.sh
new file mode 100755
index 0000000000..7ff88ac788
--- /dev/null
+++ b/source4/script/installdat.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+#fist version March 2002, Herb Lewis
+
+DATDIR=$1
+SRCDIR=$2/
+
+echo Installing dat files in $DATDIR
+
+for f in $SRCDIR/codepages/*.dat; do
+ FNAME=$DATDIR/`basename $f`
+ echo $FNAME
+ cp $f $FNAME || echo Cannot install $FNAME. Does $USER have privileges?
+ chmod 0644 $FNAME
+done
+
+cat << EOF
+======================================================================
+The dat files have been installed.
+======================================================================
+EOF
+
+exit 0
+
diff --git a/source4/script/installdirs.sh b/source4/script/installdirs.sh
new file mode 100755
index 0000000000..9557b86d3b
--- /dev/null
+++ b/source4/script/installdirs.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+while ( test -n "$1" ); do
+ if [ ! -d $1 ]; then
+ mkdir -p $1
+ fi
+
+ if [ ! -d $1 ]; then
+ echo Failed to make directory $1
+ exit 1
+ fi
+
+ shift;
+done
+
+
+
diff --git a/source4/script/installheader.pl b/source4/script/installheader.pl
new file mode 100755
index 0000000000..6b10bde65f
--- /dev/null
+++ b/source4/script/installheader.pl
@@ -0,0 +1,107 @@
+#!/usr/bin/perl
+# Copyright (C) 2006 Jelmer Vernooij
+use strict;
+use File::Basename;
+
+my $includedir = shift;
+
+
+sub read_headermap($)
+{
+ my ($fn) = @_;
+ my %map = ();
+ my $ln = 0;
+ open(MAP, "<headermap.txt");
+ while(<MAP>) {
+ $ln++;
+ s/#.*$//g;
+ next if (/^\s*$/);
+ if (! /^(.*): (.*)$/) {
+ print STDERR "headermap.txt:$ln: Malformed line\n";
+ next;
+ }
+ $map{$1} = $2;
+ }
+
+ close(MAP);
+
+ return %map;
+}
+
+my %map = read_headermap("headermap.txt");
+
+sub findmap($)
+{
+ $_ = shift;
+ s/^\.\///g;
+
+ if (! -f $_ && -f "lib/$_") { $_ = "lib/$_"; }
+
+ return $map{$_};
+}
+
+sub rewrite_include($$)
+{
+ my ($pos,$d) = @_;
+
+ my $n = findmap($d);
+ return $n if $n;
+ return $d;
+}
+
+sub install_header($$)
+{
+ my ($src,$dst) = @_;
+
+ my $lineno = 0;
+
+ open(IN, "<$src");
+ open(OUT, ">$dst");
+
+ while (<IN>) {
+ $lineno++;
+ die("Will not install autogenerated header $src") if (/This file was automatically generated by mkproto.pl. DO NOT EDIT/);
+
+ if (/^#include \"(.*)\"/) {
+ print OUT "#include <" . rewrite_include("$src:$lineno", $1) . ">\n";
+ } else {
+ print OUT $_;
+ }
+ }
+
+ close(OUT);
+ close(IN);
+}
+
+foreach my $p (@ARGV)
+{
+ my $p2 = findmap($p);
+ unless ($p2) {
+ die("Unable to map $p");
+ }
+ print "Installing $p as $includedir/$p2\n";
+
+ my $dirname = dirname($p2);
+
+ if (! -d "$includedir/$dirname") {
+ mkdir("$includedir/$dirname", 0777);
+ }
+
+ if ( -f "$includedir/$p2" ) {
+ unlink("$includedir/$p2.old");
+ rename("$includedir/$p2", "$includedir/$p2.old");
+ }
+
+ install_header($p,"$includedir/$p2");
+}
+
+print <<EOF;
+======================================================================
+The headers are installed. You may restore the old headers (if there
+were any) using the command "make revert". You may uninstall the headers
+using the command "make uninstallheader" or "make uninstall" to uninstall
+binaries, man pages and shell scripts.
+======================================================================
+EOF
+
+exit 0;
diff --git a/source4/script/installlib.sh b/source4/script/installlib.sh
new file mode 100755
index 0000000000..962c9562b1
--- /dev/null
+++ b/source4/script/installlib.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+LIBDIR=$1
+SHLIBEXT=$2
+
+shift
+shift
+
+for p in $*; do
+ p2=`basename $p`
+ lnname=`echo $p2 | sed -e "s/\.$SHLIBEXT.*/.$SHLIBEXT/"`
+ echo Installing $p as $LIBDIR/$p2
+ if [ -f $LIBDIR/$p2 ]; then
+ rm -f $LIBDIR/$p2.old
+ mv $LIBDIR/$p2 $LIBDIR/$p2.old
+ fi
+ cp $p $LIBDIR/
+ ln -sf $p2 $LIBDIR/$lnname
+done
+
+cat << EOF
+======================================================================
+The shared libraries are installed. You may restore the old libraries (if there
+were any) using the command "make revert". You may uninstall the libraries
+using the command "make uninstalllib" or "make uninstall" to uninstall
+binaries, man pages and shell scripts.
+======================================================================
+EOF
+
+exit 0
diff --git a/source4/script/installman.sh b/source4/script/installman.sh
new file mode 100755
index 0000000000..ae99bceacf
--- /dev/null
+++ b/source4/script/installman.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+MANDIR=$1
+shift 1
+MANPAGES=$*
+
+for I in $MANPAGES
+do
+ SECTION=`echo $I | grep -o '.$'`
+ DIR="$MANDIR/man$SECTION"
+ if [ ! -d "$DIR" ]
+ then
+ mkdir "$DIR"
+ fi
+
+ BASE=`basename $I`
+
+ echo "Installing manpage \"$BASE\" in $DIR"
+ cp $I $DIR
+done
+
+cat << EOF
+======================================================================
+The man pages have been installed. You may uninstall them using the command
+the command "make uninstallman" or make "uninstall" to uninstall binaries,
+man pages and shell scripts.
+======================================================================
+EOF
+
+exit 0
diff --git a/source4/script/installmisc.sh b/source4/script/installmisc.sh
new file mode 100755
index 0000000000..5f7e11f083
--- /dev/null
+++ b/source4/script/installmisc.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+# install miscellaneous files
+
+SRCDIR="$1"
+JSDIR="$2"
+SETUPDIR="$3"
+BINDIR="$4"
+
+cd $SRCDIR || exit 1
+
+echo "Installing js libs"
+mkdir -p $JSDIR || exit 1
+cp scripting/libjs/*.js $JSDIR || exit 1
+
+echo "Installing setup templates"
+mkdir -p $SETUPDIR || exit 1
+cp setup/schema-map-* $SETUPDIR || exit 1
+cp setup/DB_CONFIG $SETUPDIR || exit 1
+cp setup/provision-backend $SETUPDIR || exit 1
+cp setup/provision $SETUPDIR || exit 1
+cp setup/newuser $SETUPDIR || exit 1
+cp setup/*.inf $SETUPDIR || exit 1
+cp setup/*.ldif $SETUPDIR || exit 1
+cp setup/*.reg $SETUPDIR || exit 1
+cp setup/*.zone $SETUPDIR || exit 1
+cp setup/*.conf $SETUPDIR || exit 1
+cp setup/*.php $SETUPDIR || exit 1
+cp setup/*.txt $SETUPDIR || exit 1
+cp setup/provision.smb.conf.dc $SETUPDIR || exit 1
+cp setup/provision.smb.conf.member $SETUPDIR || exit 1
+cp setup/provision.smb.conf.standalone $SETUPDIR || exit 1
+
+echo "Installing script tools"
+mkdir -p "$BINDIR"
+rm -f scripting/bin/*~
+cp scripting/bin/* $BINDIR/ || exit 1
+
+exit 0
diff --git a/source4/script/installmodules.sh b/source4/script/installmodules.sh
new file mode 100755
index 0000000000..fb0ad90c14
--- /dev/null
+++ b/source4/script/installmodules.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+INSTALLPERMS=$1
+LIBDIR=$2
+shift
+shift
+shift
+
+if [ ! -d $LIBDIR ]; then
+mkdir $LIBDIR
+if [ ! -d $LIBDIR ]; then
+ echo Failed to make directory $LIBDIR
+ exit 1
+fi
+fi
+
+for p in $*; do
+ p2=`basename $p`
+ echo Installing $p as $LIBDIR/$p2
+ cp -f $p $LIBDIR/
+ chmod $INSTALLPERMS $LIBDIR/$p2
+done
+
+
+cat << EOF
+======================================================================
+The modules are installed. You may uninstall the modules using the
+command "make uninstallmodules" or "make uninstall" to uninstall
+binaries, man pages, shell scripts and modules.
+======================================================================
+EOF
+
+exit 0
diff --git a/source4/script/installpc.sh b/source4/script/installpc.sh
new file mode 100755
index 0000000000..81ca2f8145
--- /dev/null
+++ b/source4/script/installpc.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+# install miscellaneous files
+
+SRCDIR="$1"
+PKGCONFIGDIR="$2"
+shift
+shift
+
+cd $SRCDIR || exit 1
+
+for I in $*
+do
+ cp $I $PKGCONFIGDIR
+done
+
+exit 0
diff --git a/source4/script/installscripts.sh b/source4/script/installscripts.sh
new file mode 100755
index 0000000000..bff5423e7c
--- /dev/null
+++ b/source4/script/installscripts.sh
@@ -0,0 +1,47 @@
+#!/bin/sh
+# this script courtesy of James_K._Foote.PARC@xerox.com
+# 5 July 96 Dan.Shearer@UniSA.Edu.Au Don't hardcode script names, get from Make
+
+INSTALLPERMS=$1
+BINDIR=$2
+
+shift
+shift
+
+echo Installing scripts in $BINDIR
+
+for d in $BINDIR; do
+ if [ ! -d $d ]; then
+ mkdir $d
+ if [ ! -d $d ]; then
+ echo Failed to make directory $d
+ echo Have you run installbin first?
+ exit 1
+ fi
+ fi
+done
+
+for p in $*; do
+ p2=`basename $p`
+ echo Installing $BINDIR/$p2
+ if [ -f $BINDIR/$p2 ]; then
+ rm -f $BINDIR/$p2.old
+ mv $BINDIR/$p2 $BINDIR/$p2.old
+ fi
+ cp $p $BINDIR/
+ chmod $INSTALLPERMS $BINDIR/$p2
+ if [ ! -f $BINDIR/$p2 ]; then
+ echo Cannot copy $p2... does $USER have privileges?
+ fi
+done
+
+cat << EOF
+======================================================================
+The scripts have been installed. You may uninstall them using
+the command "make uninstallscripts" or "make install" to install binaries,
+man pages and shell scripts. You may recover the previous version (if any
+by "make revert".
+======================================================================
+EOF
+
+exit 0
diff --git a/source4/script/installswat.sh b/source4/script/installswat.sh
new file mode 100755
index 0000000000..4304e3e490
--- /dev/null
+++ b/source4/script/installswat.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+SWATDIR=$1
+SRCDIR=$2
+
+echo Installing swat files in $SWATDIR
+
+cd $SRCDIR/../swat || exit 1
+
+mkdir -p $SWATDIR || exit 1
+
+installdir() {
+ for f in $*; do
+ dname=`dirname $f`
+ echo "Installing $f in $dname"
+ test -d $SWATDIR/$dname || mkdir -p $SWATDIR/$dname || exit 1
+ cp $f $SWATDIR/$dname/ || exit 1
+ chmod 0644 $SWATDIR/$f || exit 1
+ done
+}
+
+installdir `find . -name '*.js'`
+installdir `find . -name '*.esp'`
+installdir `find . -name '*.css'`
+installdir `find . -name '*.png'`
+installdir `find . -name '*.ico'`
+installdir `find . -name '*.gif'`
+installdir `find . -name '*.ejs'`
+
+cat << EOF
+======================================================================
+The swat files have been installed.
+======================================================================
+EOF
+
+exit 0
+
diff --git a/source4/script/minimal_includes.pl b/source4/script/minimal_includes.pl
new file mode 100755
index 0000000000..963dc10f8b
--- /dev/null
+++ b/source4/script/minimal_includes.pl
@@ -0,0 +1,150 @@
+#!/usr/bin/perl -w
+# find a list of #include lines in C code that might not be needed
+# usually called with something like this:
+# minimal_includes.pl `find . -name "*.c"`
+# Andrew Tridgell <tridge@samba.org>
+
+use strict;
+use Data::Dumper;
+use Getopt::Long;
+
+my $opt_help = 0;
+my $opt_remove = 0;
+
+#####################################################################
+# write a string into a file
+sub FileSave($$)
+{
+ my($filename) = shift;
+ my($v) = shift;
+ local(*FILE);
+ open(FILE, ">$filename") || die "can't open $filename";
+ print FILE $v;
+ close(FILE);
+}
+
+sub load_lines($)
+{
+ my $fname = shift;
+ my @lines = split(/^/m, `cat $fname`);
+ return @lines;
+}
+
+sub save_lines($$)
+{
+ my $fname = shift;
+ my $lines = shift;
+ my $data = join('', @{$lines});
+ FileSave($fname, $data);
+}
+
+sub test_compile($)
+{
+ my $fname = shift;
+ my $obj;
+ if ($fname =~ s/(.*)\.c$/$1.o/) {
+ $obj = "$1.o";
+ } else {
+ return "NOT A C FILE";
+ }
+ unlink($obj);
+ my $ret = `make $obj 2>&1`;
+ if (!unlink("$obj")) {
+ return "COMPILE FAILED";
+ }
+ return $ret;
+}
+
+sub test_include($$$$)
+{
+ my $fname = shift;
+ my $lines = shift;
+ my $i = shift;
+ my $original = shift;
+ my $line = $lines->[$i];
+
+ $lines->[$i] = "";
+ save_lines("_testcompile.c", $lines);
+
+ my $out = test_compile("_testcompile.c");
+ $out =~ s/_testcompile.c/$fname/g;
+
+ if ($out eq $original) {
+ if ($opt_remove) {
+ print "$fname: removing $line\n";
+ save_lines($fname, $lines);
+ return;
+ }
+ print "$fname: might be able to remove $line\n";
+ }
+
+ $lines->[$i] = $line;
+ unlink("_testcompile.c");
+}
+
+sub process_file($)
+{
+ my $fname = shift;
+ my @lines = load_lines($fname);
+ my $num_lines = $#lines;
+
+ my $original = test_compile($fname);
+
+ if ($original eq "COMPILE FAILED") {
+ print "Failed to compile $fname\n";
+ return;
+ }
+
+ print "Processing $fname (with $num_lines lines)\n";
+
+ my $if_level = 0;
+
+ for (my $i=0;$i<=$num_lines;$i++) {
+ my $line = $lines[$i];
+ if ($line =~ /^\#\s*if/) {
+ $if_level++;
+ }
+ if ($line =~ /^\#\s*endif/) {
+ $if_level--;
+ }
+ if ($if_level == 0 &&
+ $line =~ /^\#\s*include/ &&
+ !($line =~ /needed/)) {
+ test_include($fname, \@lines, $i, $original);
+ }
+ }
+}
+
+
+#########################################
+# display help text
+sub ShowHelp()
+{
+ print "
+ minimise includes
+ Copyright (C) tridge\@samba.org
+
+ Usage: minimal_includes.pl [options] <C files....>
+
+ Options:
+ --help show help
+ --remove remove includes, don't just list them
+";
+}
+
+
+# main program
+GetOptions (
+ 'h|help|?' => \$opt_help,
+ 'remove' => \$opt_remove,
+ );
+
+if ($opt_help) {
+ ShowHelp();
+ exit(0);
+}
+
+for (my $i=0;$i<=$#ARGV;$i++) {
+ my $fname = $ARGV[$i];
+ process_file($fname);
+}
diff --git a/source4/script/mkinstalldirs b/source4/script/mkinstalldirs
new file mode 100755
index 0000000000..f945dbf2bc
--- /dev/null
+++ b/source4/script/mkinstalldirs
@@ -0,0 +1,38 @@
+#! /bin/sh
+# mkinstalldirs --- make directory hierarchy
+# Author: Noah Friedman <friedman@prep.ai.mit.edu>
+# Created: 1993-05-16
+# Public domain
+
+errstatus=0
+
+for file
+do
+ set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
+ shift
+
+ pathcomp=
+ for d
+ do
+ pathcomp="$pathcomp$d"
+ case "$pathcomp" in
+ -* ) pathcomp=./$pathcomp ;;
+ esac
+
+ if test ! -d "$pathcomp"; then
+ echo "mkdir $pathcomp" 1>&2
+
+ mkdir "$pathcomp" || lasterr=$?
+
+ if test ! -d "$pathcomp"; then
+ errstatus=$lasterr
+ fi
+ fi
+
+ pathcomp="$pathcomp/"
+ done
+done
+
+exit $errstatus
+
+# mkinstalldirs ends here
diff --git a/source4/script/mkproto.pl b/source4/script/mkproto.pl
new file mode 100755
index 0000000000..e1b790d41d
--- /dev/null
+++ b/source4/script/mkproto.pl
@@ -0,0 +1,281 @@
+#!/usr/bin/perl
+# Simple script for generating prototypes for C functions
+# Written by Jelmer Vernooij
+# based on the original mkproto.sh by Andrew Tridgell
+
+use strict;
+
+# don't use warnings module as it is not portable enough
+# use warnings;
+
+use Getopt::Long;
+use File::Basename;
+use File::Path;
+
+#####################################################################
+# read a file into a string
+
+my $public_file = undef;
+my $private_file = undef;
+my $all_file = undef;
+my $public_define = undef;
+my $private_define = undef;
+my $_public = "";
+my $_private = "";
+my $public_data = \$_public;
+my $private_data = \$_private;
+my $builddir = ".";
+my $srcdir = ".";
+
+sub public($)
+{
+ my ($d) = @_;
+ $$public_data .= $d;
+}
+
+sub private($)
+{
+ my ($d) = @_;
+ $$private_data .= $d;
+}
+
+sub usage()
+{
+ print "Usage: mkproto.pl [options] [c files]\n";
+ print "OPTIONS:\n";
+ print " --public=FILE Write prototypes for public functions to FILE\n";
+ print " --private=FILE Write prototypes for private functions to FILE\n";
+ print " --define=DEF Use DEF to check whether header was already included\n";
+ print " --public-define=DEF Same as --define, but just for public header\n";
+ print " --private-define=DEF Same as --define, but just for private header\n";
+ print " --srcdir=path Read files relative to this directory\n";
+ print " --builddir=path Write file relative to this directory\n";
+ print " --help Print this help message\n\n";
+ exit 0;
+}
+
+GetOptions(
+ 'public=s' => sub { my ($f,$v) = @_; $public_file = $v; },
+ 'all=s' => sub { my ($f,$v) = @_; $public_file = $v; $private_file = $v; },
+ 'private=s' => sub { my ($f,$v) = @_; $private_file = $v; },
+ 'define=s' => sub {
+ my ($f,$v) = @_;
+ $public_define = $v;
+ $private_define = "$v\_PRIVATE";
+ },
+ 'public-define=s' => \$public_define,
+ 'private-define=s' => \$private_define,
+ 'srcdir=s' => sub { my ($f,$v) = @_; $srcdir = $v; },
+ 'builddir=s' => sub { my ($f,$v) = @_; $builddir = $v; },
+ 'help' => \&usage
+) or exit(1);
+
+sub normalize_define($$)
+{
+ my ($define, $file) = @_;
+
+ if (not defined($define) and defined($file)) {
+ $define = "__" . uc($file) . "__";
+ $define =~ tr{./}{__};
+ $define =~ tr{\-}{_};
+ } elsif (not defined($define)) {
+ $define = '_PROTO_H_';
+ }
+
+ return $define;
+}
+
+$public_define = normalize_define($public_define, $public_file);
+$private_define = normalize_define($private_define, $private_file);
+
+if ((defined($private_file) and defined($public_file) and ($private_file eq $public_file)) or
+ (not defined($private_file) and not defined($public_file))) {
+ $private_data = $public_data;
+}
+
+sub file_load($)
+{
+ my($filename) = @_;
+ local(*INPUTFILE);
+ open(INPUTFILE, $filename) or return undef;
+ my($saved_delim) = $/;
+ undef $/;
+ my($data) = <INPUTFILE>;
+ close(INPUTFILE);
+ $/ = $saved_delim;
+ return $data;
+}
+
+sub print_header($$)
+{
+ my ($file, $header_name) = @_;
+ $file->("#ifndef $header_name\n");
+ $file->("#define $header_name\n\n");
+ $file->("#undef _PRINTF_ATTRIBUTE\n");
+ $file->("#define _PRINTF_ATTRIBUTE(a1, a2) PRINTF_ATTRIBUTE(a1, a2)\n");
+ $file->("/* This file was automatically generated by mkproto.pl. DO NOT EDIT */\n\n");
+}
+
+sub print_footer($$)
+{
+ my ($file, $header_name) = @_;
+ $file->("#undef _PRINTF_ATTRIBUTE\n");
+ $file->("#define _PRINTF_ATTRIBUTE(a1, a2)\n");
+ $file->("\n#endif /* $header_name */\n\n");
+}
+
+sub handle_loadparm($$)
+{
+ my ($file,$line) = @_;
+
+ if ($line =~ /^_PUBLIC_ FN_(GLOBAL|LOCAL)_(CONST_STRING|STRING|BOOL|bool|CHAR|INTEGER|LIST)\((\w+),.*\)/o) {
+ my $scope = $1;
+ my $type = $2;
+ my $name = $3;
+
+ my %tmap = (
+ "BOOL" => "bool ",
+ "CONST_STRING" => "const char *",
+ "STRING" => "const char *",
+ "INTEGER" => "int ",
+ "CHAR" => "char ",
+ "LIST" => "const char **",
+ );
+
+ my %smap = (
+ "GLOBAL" => "struct loadparm_context *",
+ "LOCAL" => "struct loadparm_service *, struct loadparm_service *"
+ );
+
+ $file->("$tmap{$type}$name($smap{$scope});\n");
+ }
+}
+
+sub process_file($$$)
+{
+ my ($public_file, $private_file, $filename) = @_;
+
+ $filename =~ s/\.o$/\.c/g;
+
+ if ($filename =~ /^\//) {
+ open(FH, "<$filename") or die("Failed to open $filename");
+ } elsif (!open(FH, "< $builddir/$filename")) {
+ open(FH, "< $srcdir/$filename") || die "Failed to open $filename";
+ }
+
+ $private_file->("\n/* The following definitions come from $filename */\n\n");
+
+ my $comment = undef;
+ my $incomment = 0;
+ while (my $line = <FH>) {
+ my $target = \&private;
+ my $is_public = 0;
+
+ if ($line =~ /^\/\*\*/) {
+ $comment = "";
+ $incomment = 1;
+ }
+
+ if ($incomment) {
+ $comment .= $line;
+ if ($line =~ /\*\//) {
+ $incomment = 0;
+ }
+ }
+
+ # these are ordered for maximum speed
+ next if ($line =~ /^\s/);
+
+ next unless ($line =~ /\(/);
+
+ next if ($line =~ /^\/|[;]/);
+
+ if ($line =~ /^_PUBLIC_ FN_/) {
+ handle_loadparm($public_file, $line);
+ handle_loadparm($private_file, $line);
+ next;
+ }
+
+ if ($line =~ /^_PUBLIC_[\t ]/) {
+ $target = \&public;
+ $is_public = 1;
+ }
+
+ next unless ( $is_public || $line =~ /
+ ^(_DEPRECATED_ |_NORETURN_ |_WARN_UNUSED_RESULT_ |_PURE_ )*(
+ void|bool|int|struct|char|const|\w+_[tT]\s|uint|unsigned|long|NTSTATUS|
+ ADS_STATUS|enum\s.*\(|DATA_BLOB|WERROR|XFILE|FILE|DIR|
+ double|TDB_CONTEXT|TDB_DATA|TALLOC_CTX|NTTIME|FN_|init_module|
+ GtkWidget|GType|smb_ucs2_t|krb5_error_code)
+ /xo);
+
+ next if ($line =~ /^int\s*main/);
+
+ $target->("\n$comment") if (defined($comment)); $comment = undef;
+
+ if ( $line =~ /\(.*\)\s*$/o ) {
+ chomp $line;
+ $target->("$line;\n");
+ next;
+ }
+
+ $target->($line);
+
+ while ($line = <FH>) {
+ if ($line =~ /\)\s*$/o) {
+ chomp $line;
+ $target->("$line;\n");
+ last;
+ }
+ $target->($line);
+ }
+ }
+
+ close(FH);
+}
+
+
+print_header(\&public, $public_define);
+if (defined($private_file) and defined($public_file) and $public_file ne $private_file) {
+ print_header(\&private, $private_define);
+
+ private("/* this file contains prototypes for functions that " .
+ "are private \n * to this subsystem or library. These functions " .
+ "should not be \n * used outside this particular subsystem! */\n\n");
+
+ public("/* this file contains prototypes for functions that " .
+ "are part of \n * the public API of this subsystem or library. */\n\n");
+
+}
+
+public("#ifndef _PUBLIC_\n#define _PUBLIC_\n#endif\n\n");
+public("#ifndef _PURE_\n#define _PURE_\n#endif\n\n");
+public("#ifndef _NORETURN_\n#define _NORETURN_\n#endif\n\n");
+public("#ifndef _DEPRECATED_\n#define _DEPRECATED_\n#endif\n\n");
+public("#ifndef _WARN_UNUSED_RESULT_\n#define _WARN_UNUSED_RESULT_\n#endif\n\n");
+
+process_file(\&public, \&private, $_) foreach (@ARGV);
+print_footer(\&public, $public_define);
+if (defined($private_file) and $public_file ne $private_file) {
+ print_footer(\&private, $private_define);
+}
+
+if (not defined($public_file)) {
+ print STDOUT $$public_data;
+}
+
+if (not defined($private_file) and defined($public_file)) {
+ print STDOUT $$private_data;
+}
+
+mkpath(dirname($public_file), 0, 0755);
+open(PUBLIC, ">$public_file") or die("Can't open `$public_file': $!");
+print PUBLIC "$$public_data";
+close(PUBLIC);
+
+if (defined($private_file) and $public_file ne $private_file) {
+ mkpath(dirname($private_file), 0, 0755);
+ open(PRIVATE, ">$private_file") or die("Can't open `$private_file': $!");
+ print PRIVATE "$$private_data";
+ close(PRIVATE);
+}
diff --git a/source4/script/mkrelease.sh b/source4/script/mkrelease.sh
new file mode 100755
index 0000000000..0af738deb5
--- /dev/null
+++ b/source4/script/mkrelease.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+if [ ! -d ".git" -o `dirname $0` != "./source/script" ]; then
+ echo "Run this script from the top-level directory in the"
+ echo "repository as: ./source/script/mkrelease.sh"
+ exit 1
+fi
+
+TMPDIR=`mktemp -d samba-XXXXX`
+(git archive --format=tar HEAD | (cd $TMPDIR/ && tar xf -))
+
+( cd $TMPDIR/source || exit 1
+ ./autogen.sh || exit 1
+ ./configure || exit 1
+ make dist || exit 1
+) || exit 1
+
+VERSION=`sed -n 's/^SAMBA_VERSION_STRING=//p' $TMPDIR/source/version.h`
+mv $TMPDIR samba-$VERSION || exit 1
+tar -cf samba-$VERSION.tar samba-$VERSION || (rm -rf samba-$VERSION; exit 1)
+rm -rf samba-$VERSION || exit 1
+echo "Now run: "
+echo "gpg --detach-sign --armor samba-$VERSION.tar"
+echo "gzip samba-$VERSION.tar"
+echo "And then upload "
+echo "samba-$VERSION.tar.gz samba-$VERSION.tar.asc"
+echo "to pub/samba/samba4/ on samba.org"
+
+
+
diff --git a/source4/script/mkversion.sh b/source4/script/mkversion.sh
new file mode 100755
index 0000000000..da912ac092
--- /dev/null
+++ b/source4/script/mkversion.sh
@@ -0,0 +1,133 @@
+#!/bin/sh
+
+VERSION_FILE=$1
+OUTPUT_FILE=$2
+
+if test -z "$VERSION_FILE";then
+ VERSION_FILE="VERSION"
+fi
+
+if test -z "$OUTPUT_FILE";then
+ OUTPUT_FILE="version.h"
+fi
+
+SOURCE_DIR=$3
+
+SAMBA_VERSION_MAJOR=`sed -n 's/^SAMBA_VERSION_MAJOR=//p' $SOURCE_DIR$VERSION_FILE`
+SAMBA_VERSION_MINOR=`sed -n 's/^SAMBA_VERSION_MINOR=//p' $SOURCE_DIR$VERSION_FILE`
+SAMBA_VERSION_RELEASE=`sed -n 's/^SAMBA_VERSION_RELEASE=//p' $SOURCE_DIR$VERSION_FILE`
+
+SAMBA_VERSION_REVISION=`sed -n 's/^SAMBA_VERSION_REVISION=//p' $SOURCE_DIR$VERSION_FILE`
+
+SAMBA_VERSION_TP_RELEASE=`sed -n 's/^SAMBA_VERSION_TP_RELEASE=//p' $SOURCE_DIR$VERSION_FILE`
+SAMBA_VERSION_ALPHA_RELEASE=`sed -n 's/^SAMBA_VERSION_ALPHA_RELEASE=//p' $SOURCE_DIR$VERSION_FILE`
+SAMBA_VERSION_PRE_RELEASE=`sed -n 's/^SAMBA_VERSION_PRE_RELEASE=//p' $SOURCE_DIR$VERSION_FILE`
+SAMBA_VERSION_RC_RELEASE=`sed -n 's/^SAMBA_VERSION_RC_RELEASE=//p' $SOURCE_DIR$VERSION_FILE`
+
+SAMBA_VERSION_IS_GIT_SNAPSHOT=`sed -n 's/^SAMBA_VERSION_IS_GIT_SNAPSHOT=//p' $SOURCE_DIR$VERSION_FILE`
+
+SAMBA_VERSION_RELEASE_NICKNAME=`sed -n 's/^SAMBA_VERSION_RELEASE_NICKNAME=//p' $SOURCE_DIR$VERSION_FILE`
+
+SAMBA_VERSION_VENDOR_SUFFIX=`sed -n 's/^SAMBA_VERSION_VENDOR_SUFFIX=//p' $SOURCE_DIR$VERSION_FILE`
+SAMBA_VERSION_VENDOR_PATCH=`sed -n 's/^SAMBA_VERSION_VENDOR_PATCH=//p' $SOURCE_DIR$VERSION_FILE`
+
+echo "/* Autogenerated by script/mkversion.sh */" > $OUTPUT_FILE
+
+echo "#define SAMBA_VERSION_MAJOR ${SAMBA_VERSION_MAJOR}" >> $OUTPUT_FILE
+echo "#define SAMBA_VERSION_MINOR ${SAMBA_VERSION_MINOR}" >> $OUTPUT_FILE
+echo "#define SAMBA_VERSION_RELEASE ${SAMBA_VERSION_RELEASE}" >> $OUTPUT_FILE
+
+
+##
+## start with "3.0.22"
+##
+SAMBA_VERSION_STRING="${SAMBA_VERSION_MAJOR}.${SAMBA_VERSION_MINOR}.${SAMBA_VERSION_RELEASE}"
+
+
+##
+## maybe add "3.0.22a" or "4.0.0tp11" or "4.0.0alpha1" or "3.0.22pre1" or "3.0.22rc1"
+## We do not do pre or rc version on patch/letter releases
+##
+if test -n "${SAMBA_VERSION_REVISION}";then
+ SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}${SAMBA_VERSION_REVISION}"
+ echo "#define SAMBA_VERSION_REVISION \"${SAMBA_VERSION_REVISION}\"" >> $OUTPUT_FILE
+elif test -n "${SAMBA_VERSION_TP_RELEASE}";then
+ SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}tp${SAMBA_VERSION_TP_RELEASE}"
+ echo "#define SAMBA_VERSION_TP_RELEASE ${SAMBA_VERSION_TP_RELEASE}" >> $OUTPUT_FILE
+elif test -n "${SAMBA_VERSION_ALPHA_RELEASE}";then
+ SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}alpha${SAMBA_VERSION_ALPHA_RELEASE}"
+ echo "#define SAMBA_VERSION_ALPHA_RELEASE ${SAMBA_VERSION_ALPHA_RELEASE}" >> $OUTPUT_FILE
+elif test -n "${SAMBA_VERSION_PRE_RELEASE}";then
+ ## maybe add "3.0.22pre2"
+ SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}pre${SAMBA_VERSION_PRE_RELEASE}"
+ echo "#define SAMBA_VERSION_PRE_RELEASE ${SAMBA_VERSION_PRE_RELEASE}" >> $OUTPUT_FILE
+elif test -n "${SAMBA_VERSION_RC_RELEASE}";then
+ SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}rc${SAMBA_VERSION_RC_RELEASE}"
+ echo "#define SAMBA_VERSION_RC_RELEASE ${SAMBA_VERSION_RC_RELEASE}" >> $OUTPUT_FILE
+fi
+
+##
+## GIT commit details
+##
+if test x"${SAMBA_VERSION_IS_GIT_SNAPSHOT}" = x"yes";then
+ _SAVE_LANG=${LANG}
+ LANG="C"
+ HAVEVER="no"
+
+ if test x"${HAVEVER}" != x"yes" -a -d "${SOURCE_DIR}../.git";then
+ HAVEGIT=no
+ GIT_INFO=`git show --pretty=format:"%h%n%ct%n%H%n%cd" --stat HEAD 2>/dev/null`
+ GIT_COMMIT_ABBREV=`printf %s "${GIT_INFO}" | sed -n 1p`
+ GIT_COMMIT_TIME=`printf %s "${GIT_INFO}" | sed -n 2p`
+ GIT_COMMIT_FULLREV=`printf %s "${GIT_INFO}" | sed -n 3p`
+ GIT_COMMIT_DATE=`printf %s "${GIT_INFO}" | sed -n 4p`
+ if test -n "${GIT_COMMIT_ABBREV}";then
+ HAVEGIT=yes
+ HAVEVER=yes
+ fi
+ fi
+
+ if test x"${HAVEGIT}" = x"yes";then
+ SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}-GIT-${GIT_COMMIT_ABBREV}"
+
+ echo "#define SAMBA_VERSION_GIT_COMMIT_ABBREV \"${GIT_COMMIT_ABBREV}\"" >> $OUTPUT_FILE
+ echo "#define SAMBA_VERSION_GIT_COMMIT_TIME ${GIT_COMMIT_TIME}" >> $OUTPUT_FILE
+ echo "#define SAMBA_VERSION_GIT_COMMIT_FULLREV \"${GIT_COMMIT_FULLREV}\"" >> $OUTPUT_FILE
+ echo "#define SAMBA_VERSION_GIT_COMMIT_DATE \"${GIT_COMMIT_DATE}\"" >> $OUTPUT_FILE
+ else
+ SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}-GIT-UNKNOWN"
+ fi
+ LANG=${_SAVE_LANG}
+fi
+
+echo "#define SAMBA_VERSION_OFFICIAL_STRING \"${SAMBA_VERSION_STRING}\"" >> $OUTPUT_FILE
+
+##
+## Add the vendor string if present
+##
+if test -n "${SAMBA_VERSION_VENDOR_SUFFIX}";then
+ echo "#define SAMBA_VERSION_VENDOR_SUFFIX ${SAMBA_VERSION_VENDOR_SUFFIX}" >> $OUTPUT_FILE
+ SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}-${SAMBA_VERSION_VENDOR_SUFFIX}"
+ if test -n "${SAMBA_VERSION_VENDOR_PATCH}";then
+ echo "#define SAMBA_VERSION_VENDOR_PATCH ${SAMBA_VERSION_VENDOR_PATCH}" >> $OUTPUT_FILE
+ SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}-${SAMBA_VERSION_VENDOR_PATCH}"
+ fi
+fi
+
+echo "/* Version for mkrelease.sh: " >> $OUTPUT_FILE
+echo "SAMBA_VERSION_STRING=$SAMBA_VERSION_STRING" >> $OUTPUT_FILE
+echo "*/" >> $OUTPUT_FILE
+
+##
+## Add a release nickname
+##
+if test -n "${SAMBA_VERSION_RELEASE_NICKNAME}";then
+ echo "#define SAMBA_VERSION_RELEASE_NICKNAME ${SAMBA_VERSION_RELEASE_NICKNAME}" >> $OUTPUT_FILE
+ SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING} (${SAMBA_VERSION_RELEASE_NICKNAME})"
+fi
+
+echo "#define SAMBA_VERSION_STRING \"${SAMBA_VERSION_STRING}\"" >> $OUTPUT_FILE
+
+echo "$0: '$OUTPUT_FILE' created for Samba(\"${SAMBA_VERSION_STRING}\")"
+
+exit 0
diff --git a/source4/script/pkg-config b/source4/script/pkg-config
new file mode 100755
index 0000000000..458cac6be2
--- /dev/null
+++ b/source4/script/pkg-config
@@ -0,0 +1,145 @@
+#!/usr/bin/perl
+# Simple pkg-config implementation in perl
+# jelmer@samba.org, November 2006
+
+use strict;
+use Getopt::Long;
+
+my @dirs = split(/:/, $ENV{PKG_CONFIG_PATH});
+
+my $opt_help = 0;
+my $opt_libs = 0;
+my $opt_cflags = 0;
+my $opt_static = 0;
+
+my $result = GetOptions (
+ 'help|h|?' => \$opt_help,
+ 'static' => \$opt_static,
+ 'libs' => \$opt_libs,
+ 'cflags' => \$opt_cflags
+ );
+
+if (not $result) {
+ exit(1);
+}
+
+if ($opt_help) {
+ print "pkg-config replacement in perl\n";
+ print "Copyright (C) 2006 Jelmer Vernooij <jelmer\@samba.org>\n";
+ print "\n";
+ print "Usage: pkg-config [OPTIONS] PACKAGE...\n";
+ print " --help Print this help message\n";
+ print " --static Print flags for static libraries\n";
+ print " --libs Print linker flags\n";
+ print " --cflags Print C compiler flags\n";
+ print "\n";
+ exit(0);
+}
+
+sub find_path($)
+{
+ my $name = shift;
+ foreach my $dir (@dirs) {
+ if (-f "$dir/$name-uninstalled.pc") {
+ return "$dir/$name-uninstalled.pc";
+ }
+ }
+ foreach my $dir (@dirs) {
+ if (-f "$dir/$name.pc" ) {
+ return "$dir/$name.pc";
+ }
+ }
+ die("No such package `$name'");
+}
+
+sub ReplaceVars($$)
+{
+ my ($expr, $vars) = @_;
+
+ $_ = $expr;
+
+ while (/(.*)\${([^}]+)}(.*)/) {
+ $_ = "$1$vars->{$2}$3";
+ }
+
+ return $_;
+}
+
+sub Parse($)
+{
+ my $name = shift;
+ my $path = find_path($name);
+ my %variables = ();
+ my %fields = ();
+ my $lineno = 0;
+ open(IN, "<$path") or die("Unable to open $path: $!");
+ foreach (<IN>) {
+ $lineno+=1;
+ next if (/^#.*/);
+ if (/^([A-Za-z.]+): (.*)$/) {
+ $fields{$1} = ReplaceVars($2, \%variables);
+ } elsif (/^([A-Za-z_]+)=(.*)$/) {
+ $variables{$1} = ReplaceVars($2, \%variables);
+ } elsif (/^[ \t]*$/) {
+ } else {
+ warn("$path:$lineno: parse error");
+ }
+ }
+ close(IN);
+ return \%fields;
+}
+
+sub Cflags($)
+{
+ my $name = shift;
+ my $fields = Parse($name);
+ my @cflags = split(/ /, $fields->{Cflags});
+ foreach (split(/[, ]/, $fields->{Requires})) {
+ push (@cflags, Cflags($_));
+ }
+ return @cflags;
+}
+
+sub Libs($)
+{
+ my $name = shift;
+ my $fields = Parse($name);
+ my @libs = split(/ /, $fields->{Libs});
+ foreach (split(/[, ]/, $fields->{Requires})) {
+ push (@libs, Libs($_));
+ }
+ if ($opt_static) {
+ foreach (split(/[ ,]/, $fields->{"Requires.private"})) {
+ push (@libs, Libs($_));
+ }
+ }
+ return @libs;
+}
+
+my @out = ();
+
+foreach my $pkg (@ARGV)
+{
+ push (@out, Libs($pkg)) if ($opt_libs);
+ push (@out, Cflags($pkg)) if ($opt_cflags);
+}
+
+sub nub
+{
+ my @list = @_;
+ my @ret = ();
+ my %seen = ();
+ foreach (@list) {
+ next if (defined($seen{$_}));
+ push (@ret, $_);
+ $seen{$_} = 1;
+ }
+ return @ret;
+}
+
+if ($#out >= 0) {
+ @out = nub(@out);
+ print join(' ', @out) . "\n";
+}
+
+exit 0;
diff --git a/source4/script/revert.sh b/source4/script/revert.sh
new file mode 100755
index 0000000000..8df5fd2fbd
--- /dev/null
+++ b/source4/script/revert.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+BINDIR=$1
+shift
+
+for p in $*; do
+ p2=`basename $p`
+ if [ -f $BINDIR/$p2.old ]; then
+ echo Restoring $BINDIR/$p2.old
+ mv $BINDIR/$p2 $BINDIR/$p2.new
+ mv $BINDIR/$p2.old $BINDIR/$p2
+ rm -f $BINDIR/$p2.new
+ else
+ echo Not restoring $p
+ fi
+done
+
+exit 0
+
diff --git a/source4/script/uninstallheader.sh b/source4/script/uninstallheader.sh
new file mode 100755
index 0000000000..cb491f071a
--- /dev/null
+++ b/source4/script/uninstallheader.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+# based on uninstallbin.sh:
+# 4 July 96 Dan.Shearer@UniSA.edu.au
+
+INCLUDEDIR=$1
+shift
+
+if [ ! -d $INCLUDEDIR ]; then
+ echo Directory $INCLUDEDIR does not exist!
+ echo Do a "make installbin" or "make install" first.
+ exit 1
+fi
+
+for p in $*; do
+ p2=`basename $p`
+ if [ -f $INCLUDEDIR/$p2 ]; then
+ echo Removing $INCLUDEDIR/$p2
+ rm -f $INCLUDEDIR/$p2
+ if [ -f $INCLUDEDIR/$p2 ]; then
+ echo Cannot remove $INCLUDEDIR/$p2 ... does $USER have privileges?
+ fi
+ fi
+done
+
+
+cat << EOF
+======================================================================
+The headers have been uninstalled. You may restore the headers using
+the command "make installheader" or "make install" to install binaries,
+man pages, modules and shell scripts. You can restore a previous
+version of the headers (if there were any) using "make revert".
+======================================================================
+EOF
+
+exit 0
diff --git a/source4/script/uninstalllib.sh b/source4/script/uninstalllib.sh
new file mode 100755
index 0000000000..9c45b2c941
--- /dev/null
+++ b/source4/script/uninstalllib.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+# based on uninstallbin.sh
+# 4 July 96 Dan.Shearer@UniSA.edu.au
+
+LIBDIR=$1
+shift
+
+if [ ! -d $LIBDIR ]; then
+ echo Directory $LIBDIR does not exist!
+ echo Do a "make installbin" or "make install" first.
+ exit 1
+fi
+
+for p in $*; do
+ p2=`basename $p`
+ if [ -f $LIBDIR/$p2 ]; then
+ echo Removing $LIBDIR/$p2
+ rm -f $LIBDIR/$p2
+ if [ -f $LIBDIR/$p2 ]; then
+ echo Cannot remove $LIBDIR/$p2 ... does $USER have privileges?
+ fi
+ fi
+done
+
+
+cat << EOF
+======================================================================
+The shared libraries have been uninstalled. You may restore the libraries using
+the command "make installlib" or "make install" to install binaries,
+man pages, modules and shell scripts. You can restore a previous
+version of the libraries (if there were any) using "make revert".
+======================================================================
+EOF
+
+exit 0
diff --git a/source4/script/uninstallman.sh b/source4/script/uninstallman.sh
new file mode 100755
index 0000000000..72b523ed9e
--- /dev/null
+++ b/source4/script/uninstallman.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+# 4 July 96 Dan.Shearer@UniSA.edu.au
+# Updated for Samba4 by Jelmer Vernooij
+
+MANDIR=$1
+shift 1
+MANPAGES=$*
+
+for I in $MANPAGES
+do
+ SECTION=`echo $I | grep -o '.$'`
+ FNAME=$MANDIR/man$SECTION/$I
+ if test -f $FNAME; then
+ echo Deleting $FNAME
+ rm -f $FNAME
+ test -f $FNAME && echo Cannot remove $FNAME... does $USER have privileges?
+ fi
+done
+
+cat << EOF
+======================================================================
+The man pages have been uninstalled. You may install them again using
+the command "make installman" or make "install" to install binaries,
+man pages and shell scripts.
+======================================================================
+EOF
+exit 0
diff --git a/source4/script/uninstallmodules.sh b/source4/script/uninstallmodules.sh
new file mode 100755
index 0000000000..30582a39fa
--- /dev/null
+++ b/source4/script/uninstallmodules.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+#4 July 96 Dan.Shearer@UniSA.edu.au
+
+INSTALLPERMS=$1
+BASEDIR=$2
+LIBDIR=$3
+shift
+shift
+shift
+
+if [ ! -d $LIBDIR ]; then
+ echo Directory $LIBDIR does not exist!
+ echo Do a "make installmodules" or "make install" first.
+ exit 1
+fi
+
+for p in $*; do
+ p2=`basename $p`
+ if [ -f $LIBDIR/$p2 ]; then
+ echo Removing $LIBDIR/$p2
+ rm -f $LIBDIR/$p2
+ if [ -f $LIBDIR/$p2 ]; then
+ echo Cannot remove $LIBDIR/$p2 ... does $USER have privileges?
+ fi
+ fi
+done
+
+
+cat << EOF
+======================================================================
+The modules have been uninstalled. You may restore the modules using
+the command "make installmodules" or "make install" to install
+binaries, modules, man pages and shell scripts.
+======================================================================
+EOF
+
+exit 0
diff --git a/source4/script/uninstallscripts.sh b/source4/script/uninstallscripts.sh
new file mode 100755
index 0000000000..13104acedd
--- /dev/null
+++ b/source4/script/uninstallscripts.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+# 5 July 96 Dan.Shearer@UniSA.Edu.Au - almost identical to uninstallbin.sh
+
+INSTALLPERMS=$1
+BINDIR=$2
+
+shift
+shift
+
+if [ ! -d $BINDIR ]; then
+ echo Directory $BINDIR does not exist!
+ echo Do a "make installscripts" or "make install" first.
+ exit 1
+fi
+
+for p in $*; do
+ p2=`basename $p`
+ if [ -f $BINDIR/$p2 ]; then
+ echo Removing $BINDIR/$p2
+ rm -f $BINDIR/$p2
+ if [ -f $BINDIR/$p2 ]; then
+ echo Cannot remove $BINDIR/$p2 ... does $USER have privileges?
+ fi
+ fi
+done
+
+cat << EOF
+======================================================================
+The scripts have been uninstalled. You may reinstall them using
+the command "make installscripts" or "make install" to install binaries,
+man pages and shell scripts. You may recover a previous version (if any
+with "make revert".
+======================================================================
+EOF
+
+exit 0
diff --git a/source4/script/update-proto.pl b/source4/script/update-proto.pl
new file mode 100755
index 0000000000..c130650fb8
--- /dev/null
+++ b/source4/script/update-proto.pl
@@ -0,0 +1,242 @@
+#!/usr/bin/perl
+# Simple script for updating the prototypes in a C header file
+#
+# Copyright (C) 2006 Jelmer Vernooij <jelmer@samba.org>
+# Published under the GNU GPL
+
+use strict;
+use warnings;
+use Getopt::Long;
+
+=head1 NAME
+
+update-proto - automatically update prototypes in header files
+
+=head1 SYNOPSIS
+
+update-proto [OPTIONS] <HEADER> <C-FILE>...
+
+update-proto [OPTIONS] <HEADER>
+
+=head1 DESCRIPTION
+
+Update-proto makes sure the prototypes in a C header file are current
+by comparing the existing prototypes in a header with the function definition
+in the source file. It aims to keep the diff between the original header
+and generated one as small as possible.
+
+New prototypes are inserted before any line that contains the following comment:
+
+/* New prototypes are inserted above this line */
+
+It will automatically parse C files after it encounters a line that contains:
+
+/* The following definitions come from FILE */
+
+When two or more prototypes exist for a function, only the first one
+will be kept.
+
+=head1 OPTIONS
+
+=over 4
+
+=item I<--verbose|-v>
+
+Increase verbosity. Currently only two levels of verbosity are used.
+
+=item I<--help>
+
+Show list of options
+
+=back
+
+=head1 BUGS
+
+Strange complex functions are not recognized. In particular those
+created by macros or returning (without typedef) function pointers.
+
+=head1 LICENSE
+
+update-proto is licensed under the GNU General Public License L<http://www.gnu.org/licenses/gpl.html>.
+
+=head1 AUTHOR
+
+update-proto was written by Jelmer Vernooij L<jelmer@samba.org>.
+
+=cut
+
+sub Usage()
+{
+ print "Usage: update-proto.pl [OPTIONS] <HEADER> <C-FILE>...\n";
+ exit 1;
+}
+
+sub Help()
+{
+ print "Usage: update-proto.pl [OPTIONS] <HEADER> <C-FILE>...\n";
+ print "Options:\n";
+ print " --help Show this help message\n";
+ print " --verbose Write changes made to standard error\n\n";
+ exit 0;
+}
+
+my %new_protos = ();
+
+my $verbose = 0;
+
+GetOptions(
+ 'help|h' => \&Help,
+ 'v|verbose' => sub { $verbose += 1; }
+) or Usage();
+
+sub count($$)
+{
+ my ($t, $s) = @_;
+ my $count = 0;
+ while($s =~ s/^(.)//) { $count++ if $1 eq $t; }
+ return $count;
+}
+
+my $header = shift @ARGV;
+
+sub process_file($)
+{
+ my $file = shift;
+ open (IN, "<$file");
+ while (my $line = <IN>) {
+ $_ = $line;
+ next if /^\s/;
+ next unless /\(/;
+ next if /^\/|[;]|^#|}|^\s*static/;
+ s/\/\*(.*?)\*\///g;
+ my $public = s/_PUBLIC_//g;
+ s/_PRINTF_ATTRIBUTE\([^)]+\)//g;
+ next unless /^(struct\s+\w+|union\s+\w+|\w+)\s+\**\s*(\w+)\s*\((.*)$/;
+
+ my $name = $2;
+
+ next if ($name eq "main");
+
+ # Read continuation lines if any
+ my $prn = 1 + count("(", $3) - count(")", $3);
+
+ while ($prn) {
+ my $l = <IN>;
+ $l or die("EOF while parsing function prototype");
+ $line .= $l;
+ $prn += count("(", $l) - count(")", $l);
+ }
+
+ $line =~ s/\n$//;
+
+ # Strip off possible start of function
+ $line =~ s/{\s*$//g;
+
+ $new_protos{$name} = "$line;";
+ }
+ close(IN);
+}
+
+process_file($_) foreach (@ARGV);
+
+my $added = 0;
+my $modified = 0;
+my $deleted = 0;
+my $kept = 0;
+
+sub insert_new_protos()
+{
+ foreach (keys %new_protos) {
+ print "$new_protos{$_}\n";
+ print STDERR "Inserted prototype for `$_'\n" if ($verbose);
+ $added+=1;
+ }
+ %new_protos = ();
+}
+
+my $blankline_due = 0;
+
+open (HDR, "<$header");
+while (my $line = <HDR>) {
+ if ($line eq "\n") {
+ $blankline_due = 1;
+ $line = <HDR>;
+ }
+
+ # Recognize C files that prototypes came from
+ if ($line =~ /\/\* The following definitions come from (.*) \*\//) {
+ insert_new_protos();
+ if ($blankline_due) {
+ print "\n";
+ $blankline_due = 0;
+ }
+ process_file($1);
+ print "$line";
+ next;
+ }
+
+ if ($blankline_due) {
+ print "\n";
+ $blankline_due = 0;
+ }
+
+ # Insert prototypes that weren't in the header before
+ if ($line =~ /\/\* New prototypes are inserted above this line.*\*\/\s*/) {
+ insert_new_protos();
+ print "$line\n";
+ next;
+ }
+
+ if ($line =~ /^\s*typedef |^\#|^\s*static/) {
+ print "$line";
+ next;
+ }
+
+ $_ = $line;
+ s/\/\*(.*?)\*\///g;
+ my $public = s/_PUBLIC_//g;
+ s/_PRINTF_ATTRIBUTE\([^)]+\)//g;
+ unless (/^(struct\s+\w+|union\s+\w+|\w+)\s+\**\s*(\w+)\s*\((.*)$/) {
+ print "$line";
+ next;
+ }
+
+ # Read continuation lines if any
+ my $prn = 1 + count("(", $3) - count(")", $3);
+
+ while ($prn) {
+ my $l = <HDR>;
+ $l or die("EOF while parsing function prototype");
+ $line .= $l;
+ $prn += count("(", $l) - count(")", $l);
+ }
+
+ my $name = $2;
+
+ # This prototype is for a function that was removed
+ unless (defined($new_protos{$name})) {
+ $deleted+=1;
+ print STDERR "Removed prototype for `$name'\n" if ($verbose);
+ next;
+ }
+
+ my $nline = $line;
+ chop($nline);
+
+ if ($new_protos{$name} ne $nline) {
+ $modified+=1;
+ print STDERR "Updated prototype for `$name'\n" if ($verbose);
+ print "$new_protos{$name}\n";
+ } else {
+ $kept+=1;
+ print STDERR "Prototype for `$name' didn't change\n" if ($verbose > 1);
+ print "$line";
+ }
+
+ delete $new_protos{$name};
+}
+close(HDR);
+
+print STDERR "$added added, $modified modified, $deleted deleted, $kept unchanged.\n";
+
+1;
diff --git a/source4/script/valgrind_run b/source4/script/valgrind_run
new file mode 100755
index 0000000000..5171d171a7
--- /dev/null
+++ b/source4/script/valgrind_run
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+ENV="$1"
+
+shift 1
+
+CMD="$ENV valgrind -q --db-attach=yes --num-callers=30 $@"
+echo $CMD
+eval $CMD