Samba 4 buildsystem; patch in progress

Jelmer Vernooij jelmer at samba.org
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 config.mk 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/config.mk looks like at the
moment:

TDB_OBJ = \
        $(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
TDB_TARGET = $(TDB_LIBS)
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)
	$(BINLINK) -o $@ $(TDBTOOL_OBJ) $(TDB_LIBS)

TDBTORTURE_OBJ = $(tdbdir)/tools/tdbtorture.o
$(buildbindir)/tdbtorture: $(TDBTORTURE_OBJ) $(tdbdir)/libtdb.a
	$(BINLINK) -o $@ $(TDBTORTURE_OBJ) $(TDB_LIBS)

TDBDUMP_OBJ = $(tdbdir)/tools/tdbdump.o
$(buildbindir)/tdbdump: $(TDBDUMP_OBJ) $(TDB_TARGET)
	$(BINLINK) -o $@ $(TDBDUMP_OBJ) $(TDB_LIBS)

TDBBACKUP_OBJ = $(tdbdir)/tools/tdbbackup
$(buildbindir)/tdbbackup: $(TDBBACKUP_OBJ) $(TDB_TARGET)
	$(BINLINK) -o $@ $(TDBBACKUP_OBJ) $(TDB_LIBS)

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

clean::
	rm -f $(tdbdir)/libtdb.a

installbin::
	$(INSTALLDIR)$(bindir)

installstlibs::
	$(INSTALLDIR)$(libdir) 
	$(INSTALLSTLIB) $(DESTDIR)$(libdir)

installheader::
	$(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)/config.mk

The standalone tdb build's Makefile.in uses:
tdbdir = $(srcdir)
include $(tdbdir)/config.mk

Standalone ldb's Makefile.in uses:
tdbdir = @tdbdir@
include $(tdbdir)/config.mk

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
targets:
#
# - clean: Remove architecture-dependent files
# - distclean: Remove all files not removed by clean but that should not
be 
#              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)
<binaries>)
# - installshlib: Install shared libraries and related files (.pc
files). 
#                 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:
#
# MYNAME_LIBS
# MYNAME_CFLAGS
#
# libs include the linker flags required to link to that library. If
the 
# library is static, it *must* include the linker flags for all the
libraries 
# 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
Makefile 
# 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.

Cheers,

Jelmer
-- 
Jelmer Vernooij <jelmer at samba.org> - http://samba.org/~jelmer/
Jabber: jelmer at jabber.fsfe.org
-------------- 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 : http://lists.samba.org/archive/samba-technical/attachments/20080106/773a51e2/attachment.bin


More information about the samba-technical mailing list