Samba 4 buildsystem; patch in progress

Jelmer Vernooij jelmer at
Sun Jan 6 01:32:00 GMT 2008

After discussing this with various people over the last week, I decided
to try and see how hard it would be to get Samba 4 to use a simple
Makefile again. 

I've now got something partially working, heavily based on the "include"
and double-colon features in make (portable across all makes we build
on, afaik). 

So far I've managed to avoid most beartraps; it should work portably
across all platforms, doesn't use recursive make, doesn't use libtool
and variables and rules don't use a lot of magic.

A nice advantage of this system is that you never have to run
config.status if you include one of the files included by the Makefile.
Only when config.status changes do you have to update anything.

Another advantage is that we can include the for tdb, talloc
and ldb within the Samba build and the standalone builds (and
potentially the Samba 3 makefile). So, only one place where the rules
are and thus harder to break.

To give you an idea, here is what lib/tdb/ looks like at the

        $(tdbdir)/common/tdb.o $(tdbdir)/common/dump.o
$(tdbdir)/common/io.o $(tdbdir)/common/lock.o \
        $(tdbdir)/common/open.o $(tdbdir)/common/traverse.o
$(tdbdir)/common/freelist.o \
        $(tdbdir)/common/error.o $(tdbdir)/common/transaction.o

TDB_CFLAGS = -I$(tdbdir)/include
TDB_LIBS = $(tdbdir)/libtdb.a
headers:: $(tdbdir)/include/tdb.h

$(tdbdir)/libtdb.a: $(TDB_OBJ)
stlibs:: $(tdbdir)/libtdb.a

TDBTOOL_OBJ = $(tdbdir)/tools/tdbtool.o
$(buildbindir)/tdbtool: $(TDBTOOL_OBJ) $(TDB_TARGET)

TDBTORTURE_OBJ = $(tdbdir)/tools/tdbtorture.o
$(buildbindir)/tdbtorture: $(TDBTORTURE_OBJ) $(tdbdir)/libtdb.a

TDBDUMP_OBJ = $(tdbdir)/tools/tdbdump.o
$(buildbindir)/tdbdump: $(TDBDUMP_OBJ) $(TDB_TARGET)

TDBBACKUP_OBJ = $(tdbdir)/tools/tdbbackup
$(buildbindir)/tdbbackup: $(TDBBACKUP_OBJ) $(TDB_TARGET)

binaries:: $(buildbindir)/tdbbackup $(buildbindir)/tdbdump \
		   $(buildbindir)/tdbtorture $(buildbindir)/tdbtool

	rm -f $(tdbdir)/libtdb.a



	$(INSTALLDIR) $(DESTDIR)$(includedir)
	$(INSTALLHEADER) $(srcdir)/include/tdb.h $(DESTDIR)$(includedir)

Samba includes this file using the following two Makefile lines:
tdbdir = lib/tdb
include $(tdbdir)/

The standalone tdb build's uses:
tdbdir = $(srcdir)
include $(tdbdir)/

Standalone ldb's uses:
tdbdir = @tdbdir@
include $(tdbdir)/

The header in the Makefile best explains the way it works:
# This Makefile includes some other Makefiles and heavily uses
double-colon (::)
# targets.
# Included Makefile fragments can provide the following double-colon
# - clean: Remove architecture-dependent files
# - distclean: Remove all files not removed by clean but that should not
#              included in a distribution (.tar.gz)
# - realclean: Remove all files that are autogenerated (those files not
in git)
# - manpages: Build manual pages
# - binaries: Build binaries
# - pythonmods: Build python modules
# - shlibs: Build shared libraries
# - stlibs: Build static libraries
# - headers: Build headers (where necessary) (use $(MKPROTO))
# - installman: Install manual pages (use $(INSTALLMAN) <manpagefile>)
# - installbin: Install binaries (use $(INSTALLBIN) <binaries>)
# - installsbin: Install superuser binaries (use $(INSTALLSBIN)
# - installshlib: Install shared libraries and related files (.pc
#                 Use $(INSTALLSHLIB) and $(INSTALLPC)
# - installmisc: Install miscellanous files
# - installdirs: Create install directories (use $(INSTALLDIR))
# - installheader: Install header files (use $(INSTALLHEADER))
# For each library, whether internal or external, the following
variables are 
# provided:
# libs include the linker flags required to link to that library. If
# library is static, it *must* include the linker flags for all the
# it depends on.
# For libraries that can be or are internal, the variable MYNAME_TARGET 
# is also provided. This variable should contain the name of the
# target to depend on to build that library.

The main disadvantage of this system is that CFLAGS is now global and
thus gets quite long. The only ways around that I can think of either
require GNU make or updating extra_cflags.txt manually.

I'll see if I can propose a somewhat cleaned up patch that can be
discussed in one of the next days.


Jelmer Vernooij <jelmer at> -
Jabber: jelmer at
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 307 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
Url :

More information about the samba-technical mailing list