r8832: Automatically rebuilding C files if headers change (in developer mode)
[sfrench/samba-autobuild/.git] / source / build / smb_build / makefile.pm
index 43c40dc9881399a7b125454e45ff4b7b6287e5b7..01d2de770a10f049a832da6293b7430dddeb1240 100644 (file)
@@ -7,20 +7,18 @@
 ###########################################################
 
 package makefile;
+use config qw(%config);
 use strict;
 
 sub _prepare_command_interpreters($)
 {
        my $ctx = shift;
-       my $output;
 
-       $output = << '__EOD__';
+       return << '__EOD__';
 SHELL=/bin/sh
 PERL=@PERL@
 
 __EOD__
-
-       return $output;
 }
 
 sub _prepare_path_vars($)
@@ -40,6 +38,8 @@ BINDIR = @bindir@
 SBINDIR = @sbindir@
 LIBDIR = @libdir@
 CONFIGDIR = @configdir@
+localstatedir = @localstatedir@
+SWATDIR = @swatdir@
 VARDIR = @localstatedir@
 
 # The permissions to give the executables
@@ -63,16 +63,15 @@ LOCKDIR = @lockdir@
 # the directory where pid files go
 PIDDIR = @piddir@
 
-PASSWD_FLAGS = -DSMB_PASSWD_FILE=\"$(SMB_PASSWD_FILE)\" -DPRIVATE_DIR=\"$(PRIVATEDIR)\"
-PATH_FLAGS1 = -DCONFIGFILE=\"$(CONFIGFILE)\"  -DSBINDIR=\"$(SBINDIR)\"
-PATH_FLAGS2 = $(PATH_FLAGS1) -DBINDIR=\"$(BINDIR)\" 
-PATH_FLAGS3 = $(PATH_FLAGS2) -DLMHOSTSFILE=\"$(LMHOSTSFILE)\" 
-PATH_FLAGS4 = $(PATH_FLAGS3) -DLOCKDIR=\"$(LOCKDIR)\" -DPIDDIR=\"$(PIDDIR)\"
-PATH_FLAGS5 = $(PATH_FLAGS4) -DLIBDIR=\"$(LIBDIR)\" \
-             -DLOGFILEBASE=\"$(LOGFILEBASE)\" -DSHLIBEXT=\"@SHLIBEXT@\"
-PATH_FLAGS6 = $(PATH_FLAGS5) -DCONFIGDIR=\"$(CONFIGDIR)\" -DNCALRPCDIR=\"$(NCALRPCDIR)\"
-PATH_FLAGS = $(PATH_FLAGS6) $(PASSWD_FLAGS)
+MANDIR = @mandir@
 
+PATH_FLAGS = -DCONFIGFILE=\"$(CONFIGFILE)\"  -DSBINDIR=\"$(SBINDIR)\" \
+        -DBINDIR=\"$(BINDIR)\" -DLMHOSTSFILE=\"$(LMHOSTSFILE)\" \
+        -DLOCKDIR=\"$(LOCKDIR)\" -DPIDDIR=\"$(PIDDIR)\" -DLIBDIR=\"$(LIBDIR)\" \
+        -DLOGFILEBASE=\"$(LOGFILEBASE)\" -DSHLIBEXT=\"@SHLIBEXT@\" \
+        -DCONFIGDIR=\"$(CONFIGDIR)\" -DNCALRPCDIR=\"$(NCALRPCDIR)\" \
+        -DSWATDIR=\"$(SWATDIR)\" -DSMB_PASSWD_FILE=\"$(SMB_PASSWD_FILE)\" \
+        -DPRIVATE_DIR=\"$(PRIVATEDIR)\"
 __EOD__
 
        return $output;
@@ -81,24 +80,23 @@ __EOD__
 sub _prepare_compiler_linker($)
 {
        my $ctx = shift;
-       my $output;
 
-       $output = << '__EOD__';
+       return << '__EOD__';
 CC=@CC@
-CC_FLAGS=-Iinclude -I. -I$(srcdir)/include -I$(srcdir) -D_SAMBA_BUILD_ -Ilib @CFLAGS@ @CPPFLAGS@
+CFLAGS=-Iinclude -I. -I$(srcdir)/include -I$(srcdir) -D_SAMBA_BUILD_ -DHAVE_CONFIG_H -Ilib @CFLAGS@ @CPPFLAGS@
 
 LD=@CC@
-LD_FLAGS=@LDFLAGS@ @CFLAGS@
+LD_FLAGS=@LDFLAGS@ @CFLAGS@ -Lbin
 
 STLD=ar
 STLD_FLAGS=-rc
 
 SHLD=@CC@
-SHLD_FLAGS=@LDSHFLAGS@ @LDFLAGS@
+SHLD_FLAGS=@LDSHFLAGS@ @LDFLAGS@ -Lbin
 
-__EOD__
+XSLTPROC=@XSLTPROC@
 
-       return $output;
+__EOD__
 }
 
 sub _prepare_default_rule($)
@@ -121,7 +119,7 @@ sub _prepare_SUFFIXES($)
 
        $output = << '__EOD__';
 .SUFFIXES:
-.SUFFIXES: .c .o .h .h.gch .a .so
+.SUFFIXES: .c .d .o .h .h.gch .a .so .1 .1.xml .3 .3.xml .5 .5.xml .7 .7.xml
 
 __EOD__
 
@@ -131,57 +129,98 @@ __EOD__
 sub _prepare_IDL($)
 {
        my $ctx = shift;
-       my $output;
 
-       $output = << '__EOD__';
-idl_full: build/pidl/idl.pm
-       CPP="@CPP@" PERL="$(PERL)" script/build_idl.sh FULL
+       return << '__EOD__';
+idl_full: build/pidl/Parse/Pidl/IDL.pm
+       CPP="@CPP@" PERL="$(PERL)" script/build_idl.sh FULL @PIDL_ARGS@
 
-idl: build/pidl/idl.pm
-       @CPP="@CPP@" PERL="$(PERL)" script/build_idl.sh PARTIAL
+idl: build/pidl/Parse/Pidl/IDL.pm
+       @CPP="@CPP@" PERL="$(PERL)" script/build_idl.sh PARTIAL @PIDL_ARGS@
 
-build/pidl/idl.pm: build/pidl/idl.yp
-       -yapp -s build/pidl/idl.yp
+build/pidl/Parse/Pidl/IDL.pm: build/pidl/idl.yp
+       -yapp -s -m 'Parse::Pidl::IDL' -o build/pidl/Parse/Pidl/IDL.pm build/pidl/idl.yp 
 
 pch: proto include/includes.h.gch
 
 pch_clean:
        -rm -f include/includes.h.gch
 
-basics: idl proto_exists
+basics: idl proto_exists HEIMDAL_EXTERNAL
 
-test: all
-       ./script/tests/selftest.sh
-       
-SOCKET_WRAPPER_DIR=`pwd`/sockdir
+test: @DEFAULT_TEST_TARGET@
 
 test-swrap: all
-       export SOCKET_WRAPPER_DIR
-       mkdir -p $(SOCKET_WRAPPER_DIR)
-       ./script/tests/selftest.sh
+       ./script/tests/selftest.sh @selftest_prefix@/st all SOCKET_WRAPPER
+
+test-noswrap: all
+       ./script/tests/selftest.sh @selftest_prefix@/st all
+
+quicktest: all
+       ./script/tests/selftest.sh @selftest_prefix@/st quick SOCKET_WRAPPER
+
+valgrindtest: all
+       SMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \
+       ./script/tests/selftest.sh @selftest_prefix@/st quick SOCKET_WRAPPER
 
 __EOD__
+}
 
-       return $output;
+sub _prepare_man_rule($)
+{
+       my $suffix = shift;
+
+       return << "__EOD__";
+.$suffix.xml.$suffix:
+       \$(XSLTPROC) -o \$@ http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl \$<
+
+__EOD__
+}
+
+sub _prepare_manpages($)
+{
+       my $ctx = shift;
+
+       my @mp_list = ();
+
+       foreach (values %$ctx) {
+               if (defined($_->{MANPAGE}) and $_->{MANPAGE} ne "") {
+                       push (@mp_list, $_->{MANPAGE});
+               }
+       }
+       
+       my $mp = join(' ', @mp_list);
+       return << "__EOD__";
+MANPAGES = $mp
+
+manpages: \$(MANPAGES)
+
+__EOD__
 }
 
 sub _prepare_dummy_MAKEDIR()
 {
        my $ctx = shift;
-       my $output;
 
-       $output =  << '__EOD__';
+       return  << '__EOD__';
 bin/.dummy:
        @: >> $@ || : > $@
 
 dynconfig.o: dynconfig.c Makefile
        @echo Compiling $*.c
-       @$(CC) $(CC_FLAGS) @PICFLAG@ $(PATH_FLAGS) -c $< -o $@
+       @$(CC) $(CFLAGS) @PICFLAG@ $(PATH_FLAGS) -c $< -o $@
 @BROKEN_CC@    -mv `echo $@ | sed 's%^.*/%%g'` $@
 
 __EOD__
+}
 
-       return $output;
+sub _prepare_depend_CC_rule()
+{
+       return << '__EOD__';
+.c.d:
+       @echo "Generating dependencies for $<"
+       @$(CC) -MM -MG -MT $(<:.c=.o) -MF $@ $(CFLAGS) $<
+
+__EOD__
 }
 
 ###########################################################
@@ -211,14 +250,11 @@ sub _prepare_std_CC_rule($$$$$)
        my $output;
 
        $output = << "__EOD__";
-###################################
-# Start $comment
+# $comment
 .$src.$dst:
        \@echo $message \$\*.$src
-       \@\$(CC) \$(CC_FLAGS) $flags -c \$< -o \$\@
+       \@\$(CC) `script/cflags.sh \$\@` \$(CFLAGS) $flags -c \$< -o \$\@
 \@BROKEN_CC\@  -mv `echo \$\@ | sed 's%^.*/%%g'` \$\@
-#End $comment
-###################################
 
 __EOD__
 
@@ -228,16 +264,12 @@ __EOD__
 sub array2oneperline($)
 {
        my $array = shift;
-       my $i;
        my $output = "";
 
-       foreach my $str (@{$array}) {
-               if (!defined($str)) {
-                       next;
-               }
+       foreach (@$array) {
+               next unless defined($_);
 
-               $output .= " \\\n\t\t";
-               $output .= $str;
+               $output .= " \\\n\t\t$_";
        }
 
        return $output;
@@ -249,13 +281,10 @@ sub array2oneline($)
        my $i;
        my $output = "";
 
-       foreach my $str (@{$array}) {
-               if (!defined($str)) {
-                       next;
-               }
+       foreach (@{$array}) {
+               next unless defined($_);
 
-               $output .= $str;
-               $output .= " ";
+               $output .= "$_ ";
        }
 
        return $output;
@@ -274,60 +303,27 @@ sub array2oneline($)
 # $output -            the resulting output buffer
 sub _prepare_obj_list($$)
 {
-       my $var = shift;
-       my $ctx = shift;
-       my $tmpobjlist;
-       my $output;
+       my ($var,$ctx) = @_;
 
-       $tmpobjlist = array2oneperline($ctx->{OBJ_LIST});
+       my $tmplist = array2oneperline($ctx->{OBJ_LIST});
 
-       $output = << "__EOD__";
-###################################
-# Start $var $ctx->{NAME} OBJ LIST
-$var\_$ctx->{NAME}_OBJS =$tmpobjlist
-# End $var $ctx->{NAME} OBJ LIST
-###################################
+       return << "__EOD__";
+# $var $ctx->{NAME} OBJ LIST
+$var\_$ctx->{NAME}_OBJS =$tmplist
 
 __EOD__
-
-       return $output;
 }
 
-###########################################################
-# This function creates a object file list for a subsystem
-#
-# $output = _prepare_subsystem_obj_list($subsystem_ctx)
-#
-# $subsystem_ctx -             the subsystem context
-#
-# $subsystem_ctx->{NAME} -     the subsystem name
-# $subsystem_ctx->{OBJ_LIST} - the list of objectfiles which sould be linked to this subsystem
-#
-# $output -            the resulting output buffer
-sub _prepare_subsystem_obj_list($)
+sub _prepare_cflags($$)
 {
-       my $ctx = shift;
+       my ($var,$ctx) = @_;
 
-       return _prepare_var_obj_list("SUBSYSTEM",$ctx);
-}
+       my $tmplist = array2oneperline($ctx->{CFLAGS});
 
-###########################################################
-# This function creates a object file list for a module
-#
-# $output = _prepare_module_obj_and_lib_list($module_ctx)
-#
-# $module_ctx -                the module context
-#
-# $module_ctx->{NAME} -                the module binary name
-# $module_ctx->{OBJ_LIST} -    the list of objectfiles which sould be linked to this module
-#
-# $output -            the resulting output buffer
-sub _prepare_module_obj_list($)
-{
-       my $ctx = shift;
-
-       return _prepare_var_obj_list("MODULE",$ctx);
+       return << "__EOD__";
+$var\_$ctx->{NAME}_CFLAGS =$tmplist
 
+__EOD__
 }
 
 ###########################################################
@@ -359,25 +355,19 @@ sub _prepare_shared_library_rule($)
        my $tmpshflag;
        my $tmprules;
        my $output;
-       my $outname = $ctx->{OUTPUT};
 
        $tmpdepend = array2oneperline($ctx->{DEPEND_LIST});
-
        $tmpshlink = array2oneperline($ctx->{LINK_LIST});
        $tmpshflag = array2oneperline($ctx->{LINK_FLAGS});
 
        $output = << "__EOD__";
-###################################
-# Start Library $ctx->{NAME}
-#
 LIBRARY_$ctx->{NAME}_DEPEND_LIST =$tmpdepend
 #
 LIBRARY_$ctx->{NAME}_SHARED_LINK_LIST =$tmpshlink
 LIBRARY_$ctx->{NAME}_SHARED_LINK_FLAGS =$tmpshflag
 #
 
-# Shared $ctx->{LIBRARY_NAME}
-$ctx->{OUTPUT}: \$(LIBRARY_$ctx->{NAME}_DEPEND_LIST) bin/.dummy
+$ctx->{TARGET}: \$(LIBRARY_$ctx->{NAME}_DEPEND_LIST) \$(LIBRARY_$ctx->{NAME}_OBJS) bin/.dummy
        \@echo Linking \$\@
        \@\$(SHLD) \$(SHLD_FLAGS) -o \$\@ \\
                \$(LIBRARY_$ctx->{NAME}_SHARED_LINK_FLAGS) \\
@@ -397,19 +387,32 @@ bin/$ctx->{LIBRARY_NAME}: bin/$ctx->{LIBRARY_SONAME} bin/.dummy
        \@ln -sf $ctx->{LIBRARY_SONAME} \$\@
 
 __EOD__
-               $outname = $ctx->{LIBRARY_NAME};
        }
 
 $output .= << "__EOD__";
-library_$ctx->{NAME}: basics bin/$outname
-# End Library $ctx->{NAME}
-###################################
+library_$ctx->{NAME}: basics bin/lib$ctx->{LIBRARY_NAME}
 
 __EOD__
 
        return $output;
 }
 
+sub _prepare_objlist_rule($)
+{
+       my $ctx = shift;
+       my $tmpdepend = array2oneperline($ctx->{DEPEND_LIST});
+       my $output;
+
+       return "" unless $ctx->{TARGET};
+
+       $output = "$ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST = $tmpdepend\n";
+       $output .= "$ctx->{TARGET}: ";
+       $output .= "\$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_OBJS)\n";
+       $output .= "\t\@touch $ctx->{TARGET}\n";
+
+       return $output;
+}
+
 ###########################################################
 # This function creates a make rule for linking a library
 #
@@ -439,37 +442,26 @@ sub _prepare_static_library_rule($)
        my $output;
 
        $tmpdepend = array2oneperline($ctx->{DEPEND_LIST});
-
        $tmpstlink = array2oneperline($ctx->{LINK_LIST});
        $tmpstflag = array2oneperline($ctx->{LINK_FLAGS});
 
-       $tmprules = "bin/$ctx->{LIBRARY_NAME}";
-
-       $output = << '__EOD__';
-###################################
-# Start Library $ctx->{NAME}
-#
+       $output = << "__EOD__";
 LIBRARY_$ctx->{NAME}_DEPEND_LIST =$tmpdepend
 #
 LIBRARY_$ctx->{NAME}_STATIC_LINK_LIST =$tmpstlink
 #
-# Static $ctx->{LIBRARY_NAME}
-$ctx->{OUTPUT}: $(LIBRARY_$ctx->{NAME}_DEPEND_LIST) bin/.dummy
-       @echo Linking $@
-       @$(STLD) $(STLD_FLAGS) $@ \\
-               $(LIBRARY_$ctx->{NAME}_STATIC_LINK_LIST)
+$ctx->{TARGET}: \$(LIBRARY_$ctx->{NAME}_DEPEND_LIST) \$(LIBRARY_$ctx->{NAME}_OBJS) bin/.dummy
+       \@echo Linking \$@
+       \@\$(STLD) \$(STLD_FLAGS) \$@ \\
+               \$(LIBRARY_$ctx->{NAME}_STATIC_LINK_LIST)
 
-library_$ctx->{NAME}: basics $tmprules
-# End Library $ctx->{NAME}
-###################################
+library_$ctx->{NAME}: basics $ctx->{TARGET}
 
 __EOD__
 
        return $output;
 }
 
-
-
 ###########################################################
 # This function creates a make rule for linking a binary
 #
@@ -499,28 +491,36 @@ sub _prepare_binary_rule($)
        $tmpflag = array2oneperline($ctx->{LINK_FLAGS});
 
        $output = << "__EOD__";
-###################################
-# Start Binary $ctx->{BINARY}
 #
 BINARY_$ctx->{NAME}_DEPEND_LIST =$tmpdepend
 BINARY_$ctx->{NAME}_LINK_LIST =$tmplink
 BINARY_$ctx->{NAME}_LINK_FLAGS =$tmpflag
 #
-bin/$ctx->{BINARY}: bin/.dummy \$(BINARY_$ctx->{NAME}_DEPEND_LIST)
+bin/$ctx->{BINARY}: bin/.dummy \$(BINARY_$ctx->{NAME}_DEPEND_LIST) \$(BINARY_$ctx->{NAME}_OBJS)
        \@echo Linking \$\@
        \@\$(LD) \$(LD_FLAGS) -o \$\@ \\
                \$\(BINARY_$ctx->{NAME}_LINK_FLAGS) \\
                \$\(BINARY_$ctx->{NAME}_LINK_LIST) \\
                \$\(BINARY_$ctx->{NAME}_LINK_FLAGS)
 binary_$ctx->{BINARY}: basics bin/$ctx->{BINARY}
-# End Binary $ctx->{BINARY}
-###################################
 
 __EOD__
 
        return $output;
 }
 
+sub _prepare_custom_rule($)
+{
+       my $ctx = shift;
+       return "
+$ctx->{NAME}: bin/.TARGET_$ctx->{NAME}
+
+bin/.TARGET_$ctx->{NAME}:
+       $ctx->{CMD}
+       touch bin/.TARGET_$ctx->{NAME}
+";
+}
+
 sub _prepare_proto_rules()
 {
        my $output = "";
@@ -530,20 +530,16 @@ sub _prepare_proto_rules()
 # exist, not necessarily that they are up to date.  Since they're
 # removed by 'make clean' this will always be run when you do anything
 # afterwards.
-proto_exists: include/proto.h include/build_env.h
+proto_exists: include/proto.h
 
 delheaders: pch_clean
-       -rm -f $(builddir)/include/proto.h $(builddir)/include/build_env.h:
+       -rm -f $(builddir)/include/proto.h
 
 include/proto.h:
        @cd $(srcdir) && $(SHELL) script/mkproto.sh "$(PERL)" \
          -h _PROTO_H_ $(builddir)/include/proto.h \
          $(PROTO_PROTO_OBJS)
 
-include/build_env.h:
-       @echo Building include/build_env.h
-       @cd $(srcdir) && $(SHELL) script/build_env.sh $(srcdir) $(builddir) $(CC) > $(builddir)/include/build_env.h
-
 # 'make headers' or 'make proto' calls a subshell because we need to
 # make sure these commands are executed in sequence even for a
 # parallel make.
@@ -555,24 +551,43 @@ proto_test:
        @[ -f $(builddir)/include/proto.h ] || $(MAKE) proto
 
 clean: delheaders
-       -rm -f *.o */*.o */*/*.o */*/*/*.o bin/*
-       -rm -rf librpc/gen_*
+       @echo Removing objects
+       @-find . -name '*.o' -exec rm -f '{}' \;
+       @echo Removing binaries
+       @-rm -f bin/*
+       @echo Removing dummy targets
+       @-rm -f bin/.*_*
+       @echo Removing generated files
+       @-rm -rf librpc/gen_*
+       @echo Removing generated ASN1 files
+       @-find heimdal/lib/asn1 -name 'asn1_*.[xc]' -exec rm -f '{}' \;
+       @-find heimdal/lib/gssapi -name 'asn1_*.[xc]' -exec rm -f '{}' \;
+       @-find heimdal/lib/hdb -name 'asn1_*.[xc]' -exec rm -f '{}' \;
 
 distclean: clean
        -rm -f bin/.dummy
-       -rm -f include/config.h 
+       -rm -f include/config.h include/smb_build.h
        -rm -f Makefile*
        -rm -f config.status
-       -rm -f config.smb_build.*
        -rm -f config.log config.cache
+       -rm -f samba4-deps.dot
+       -rm -f lib/registry/winregistry.pc
+__EOD__
+
+       if ($config{developer} eq "yes") {
+               $output .= "\t@-rm -f \$(_ALL_OBJS_OBJS:.o=.d)\n";
+       }
+
+       $output .= << '__EOD__';
 
 removebackup:
        -rm -f *.bak *~ */*.bak */*~ */*/*.bak */*/*~ */*/*/*.bak */*/*/*~
 
 realdistclean: distclean removebackup
        -rm -f include/config.h.in
-       -rm -f lib/version.h
+       -rm -f include/version.h
        -rm -f configure
+       -rm -f $(MANPAGES)
 __EOD__
 
        return $output;
@@ -586,26 +601,25 @@ sub _prepare_make_target($)
 
        $tmpdepend = array2oneperline($ctx->{DEPEND_LIST});
 
-       $output = << "__EOD__";
-###################################
-# Start Target $ctx->{TARGET}
+       return << "__EOD__";
 $ctx->{TARGET}: basics $tmpdepend
-# End Target $ctx->{TARGET}
-###################################
 
 __EOD__
-
-       return $output;
 }
 
-sub _prepare_obj_lists($)
+sub _prepare_target_settings($)
 {
        my $CTX = shift;
        my $output = "";
 
-       foreach my $key (values %{$CTX}) {
-               next if not defined($key->{OBJ_LIST});
-               $output .= _prepare_obj_list($key->{TYPE}, $key);
+       foreach my $key (values %$CTX) {
+               if (defined($key->{OBJ_LIST})) {
+                       $output .= _prepare_obj_list($key->{TYPE}, $key);
+               }
+
+               if (defined($key->{OBJ_LIST})) {
+                       $output .= _prepare_cflags($key->{TYPE}, $key);
+               }
        }
 
        return $output;
@@ -626,12 +640,14 @@ showlayout:
        @echo "  libdir:  $(LIBDIR)"
        @echo "  vardir:  $(VARDIR)"
        @echo "  privatedir:  $(PRIVATEDIR)"
-       @echo "  piddir:  $(PIDDIR)"
+       @echo "  piddir:   $(PIDDIR)"
        @echo "  lockdir:  $(LOCKDIR)"
+       @echo "  swatdir:  $(SWATDIR)"
+       @echo "  mandir:   $(MANDIR)"
 
 showflags:
        @echo "Samba will be compiled with flags:"
-       @echo "  CC_FLAGS = $(CC_FLAGS)"
+       @echo "  CFLAGS = $(CFLAGS)"
        @echo "  LD_FLAGS = $(LD_FLAGS)"
        @echo "  STLD_FLAGS = $(STLD_FLAGS)"
        @echo "  SHLD_FLAGS = $(SHLD_FLAGS)"
@@ -641,6 +657,7 @@ SBIN_PROGS = bin/smbd
 BIN_PROGS = bin/smbclient \
                bin/net \
                bin/nmblookup \
+               bin/smbscript \
                bin/ntlm_auth
 
 TORTURE_PROGS = bin/smbtorture \
@@ -658,21 +675,24 @@ LDB_PROGS =       bin/ldbadd \
 REG_PROGS =    bin/regpatch \
                bin/regshell \
                bin/regtree \
-               bin/regpatch \
                bin/regdiff
 
-install: showlayout installbin installtorture installldb installreg installdat 
+GTK_PROGS = bin/gregedit \
+               bin/gwsam \
+               bin/gepdump
+
+install: showlayout installbin installtorture installldb installreg installdat installswat installmisc installgtk
 
 # DESTDIR is used here to prevent packagers wasting their time
-# duplicating the Makefile. Remove it and you will have the privelege
-# of package each samba release for muliple versions of multiple
+# duplicating the Makefile. Remove it and you will have the privilege
+# of package each samba release for multiple versions of multiple
 # distributions and operating systems, or at least supplying patches
 # to all the packaging files required for this, prior to committing
 # the removal of DESTDIR. Do not remove it even though you think it
-# is not used
+# is not used.
 
 installdirs:
-       @$(SHELL) $(srcdir)/script/installdirs.sh $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(SBINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(PRIVATEDIR) $(DESTDIR)$(PIDDIR) $(DESTDIR)$(LOCKDIR)
+       @$(SHELL) $(srcdir)/script/installdirs.sh $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(SBINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(PRIVATEDIR) $(DESTDIR)$(PIDDIR) $(DESTDIR)$(LOCKDIR) $(DESTDIR)$(PRIVATEDIR)/tls
 
 installbin: all installdirs
        @$(SHELL) $(srcdir)/script/installbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(SBINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(SBIN_PROGS)
@@ -687,10 +707,22 @@ installldb: all installdirs
 installreg: all installdirs
        @$(SHELL) $(srcdir)/script/installbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(REG_PROGS)
 
+installgtk: all installdirs
+       @$(SHELL) $(srcdir)/script/installbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(GTK_PROGS)
+
 installdat: installdirs
        @$(SHELL) $(srcdir)/script/installdat.sh $(DESTDIR)$(LIBDIR) $(srcdir)
 
-uninstall: uninstallbin uninstalltorture uninstallldb uninstallreg
+installswat: installdirs
+       @$(SHELL) $(srcdir)/script/installswat.sh $(DESTDIR)$(SWATDIR) $(srcdir) $(DESTDIR)$(LIBDIR)
+
+installmisc: installdirs
+       @$(SHELL) $(srcdir)/script/installmisc.sh $(srcdir) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(BINDIR)
+
+installman: installdirs
+       @$(SHELL) $(srcdir)/script/installman.sh $(DESTDIR)$(MANDIR) $(MANPAGES)
+
+uninstall: uninstallbin uninstalltorture uninstallldb uninstallreg uninstallgtk
 
 uninstallbin:
        @$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(SBINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(SBIN_PROGS)
@@ -704,6 +736,12 @@ uninstallldb:
 uninstallreg:
        @$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(REG_PROGS)
 
+uninstallgtk:
+       @$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(GTK_PROGS)
+
+uninstallman:
+       @$(SHELL) $(srcdir)/script/uninstallman.sh $(DESTDIR)$(MANDIR) $(MANPAGES)
+
 # Swig extensions
 
 swig: scripting/swig/_tdb.so scripting/swig/_dcerpc.so
@@ -747,17 +785,18 @@ sub _prepare_rule_lists($)
        my $output = "";
 
        foreach my $key (values %{$depend}) {
-               next if not defined $key->{OUTPUT_TYPE};
+               next unless defined $key->{OUTPUT_TYPE};
+
+               ($output .= _prepare_objlist_rule($key)) if $key->{OUTPUT_TYPE} eq "OBJLIST";
                ($output .= _prepare_static_library_rule($key)) if $key->{OUTPUT_TYPE} eq "STATIC_LIBRARY";
                ($output .= _prepare_shared_library_rule($key)) if $key->{OUTPUT_TYPE} eq "SHARED_LIBRARY";
                ($output .= _prepare_binary_rule($key)) if $key->{OUTPUT_TYPE} eq "BINARY";
+               ($output .= _prepare_custom_rule($key) ) if $key->{TYPE} eq "TARGET";
        }
 
        my $idl_ctx;
        $output .= _prepare_IDL($idl_ctx);
-
        $output .= _prepare_proto_rules();
-
        $output .= _prepare_install_rules($depend);
 
        return $output;
@@ -766,14 +805,14 @@ sub _prepare_rule_lists($)
 ###########################################################
 # This function prepares the output for Makefile
 #
-# $output = _prepare_makefile_in($SMB_BUILD_CTX)
+# $output = _prepare_makefile_in($OUTPUT)
 #
-# $SMB_BUILD_CTX -     the global SMB_BUILD context
+# $OUTPUT -    the global OUTPUT context
 #
 # $output -            the resulting output buffer
 sub _prepare_makefile_in($)
 {
-       my $CTX = shift;
+       my ($CTX) = @_;
        my $output;
 
        $output  = "########################################\n";
@@ -797,44 +836,60 @@ sub _prepare_makefile_in($)
        $output .= _prepare_SUFFIXES($suffix_ctx);
 
        $output .= _prepare_dummy_MAKEDIR();
-
        $output .= _prepare_std_CC_rule("c","o",'@PICFLAG@',"Compiling","Rule for std objectfiles");
        $output .= _prepare_std_CC_rule("h","h.gch",'@PICFLAG@',"Precompiling","Rule for precompiled headerfiles");
 
-       $output .= _prepare_obj_lists($CTX);
-
+       $output .= _prepare_depend_CC_rule();
+       
+       $output .= _prepare_man_rule("1");
+       $output .= _prepare_man_rule("3");
+       $output .= _prepare_man_rule("5");
+       $output .= _prepare_man_rule("7");
+       $output .= _prepare_manpages($CTX);
+       $output .= _prepare_target_settings($CTX);
        $output .= _prepare_rule_lists($CTX);
 
        my @all = ();
        
        foreach my $part (values %{$CTX}) {
-               push (@all, $part->{OUTPUT}) if defined ($part->{OUTPUT_TYPE}) and $part->{OUTPUT_TYPE} eq "BINARY";    
+               push (@all, $part->{TARGET}) if defined ($part->{OUTPUT_TYPE}) and $part->{OUTPUT_TYPE} eq "BINARY";    
        }
        
        $output .= _prepare_make_target({ TARGET => "all", DEPEND_LIST => \@all });
 
+       if ($config{developer} eq "yes") {
+               $output .= <<__EOD__
+-include \$(_ALL_OBJS_OBJS:.o=.d)
+IDL_FILES = \$(wildcard librpc/idl/*.idl)
+\$(patsubst librpc/idl/%.idl,librpc/gen_ndr/ndr_%.c,\$(IDL_FILES)) \\
+\$(patsubst librpc/idl/%.idl,librpc/gen_ndr/ndr_\%_c.c,\$(IDL_FILES)) \\
+\$(patsubst librpc/idl/%.idl,librpc/gen_ndr/ndr_%.h,\$(IDL_FILES)): idl
+__EOD__
+       }
+
        return $output;
 }
 
 ###########################################################
-# This function creates Makefile.in from the SMB_BUILD 
+# This function creates Makefile.in from the OUTPUT 
 # context
 #
-# create_makefile_in($SMB_BUILD_CTX)
+# create_makefile_in($OUTPUT)
 #
-# $SMB_BUILD_CTX -     the global SMB_BUILD context
+# $OUTPUT      -       the global OUTPUT context
 #
 # $output -            the resulting output buffer
-sub create_makefile_in($)
+sub create_makefile_in($$)
 {
-       my $CTX = shift;
+       my ($CTX, $file) = @_;
 
-       open(MAKEFILE_IN,"> Makefile.in") || die ("Can't open Makefile.in\n");
+       open(MAKEFILE_IN,">$file") || die ("Can't open $file\n");
        print MAKEFILE_IN _prepare_makefile_in($CTX);
        close(MAKEFILE_IN);
 
-       print "config.smb_build.pl: creating Makefile.in\n";
+       print "config.smb_build.pl: creating $file\n";
        return; 
 }
 
 1;
+