build: added ADD_CFLAGS() and started of Samba4 build
authorAndrew Tridgell <tridge@samba.org>
Wed, 17 Mar 2010 09:26:03 +0000 (20:26 +1100)
committerAndrew Tridgell <tridge@samba.org>
Tue, 6 Apr 2010 10:26:34 +0000 (20:26 +1000)
lib/replace/wafsamba.py
lib/replace/wscript
lib/talloc/wscript
lib/tdb/wscript
lib/tevent/wscript
source4/lib/ldb/wscript
source4/wscript [new file with mode: 0644]

index b01f4ec4f8cc971f8c02b4d1330b1b0581fc004b..5b12cdb7184a3a6e965b8b5d4d14ff9b19708571 100644 (file)
@@ -1,7 +1,7 @@
 # a waf tool to add autoconf-like macros to the configure section
 # and for SAMBA_ macros for building libraries, binaries etc
 
 # a waf tool to add autoconf-like macros to the configure section
 # and for SAMBA_ macros for building libraries, binaries etc
 
-import Build, os, Logs
+import Build, os, Logs, sys
 from Configure import conf
 
 LIB_PATH="shared"
 from Configure import conf
 
 LIB_PATH="shared"
@@ -64,6 +64,12 @@ def CONFIG_PATH(conf, name, default):
         conf.env[name] = conf.env['PREFIX'] + default
     conf.define(name, conf.env[name], quote=True)
 
         conf.env[name] = conf.env['PREFIX'] + default
     conf.define(name, conf.env[name], quote=True)
 
+##############################################################
+# add some CFLAGS to the command line
+@conf
+def ADD_CFLAGS(conf, flags):
+    conf.env.append_value('CCFLAGS', flags.split())
+
 
 ################################################################
 # magic rpath handling
 
 ################################################################
 # magic rpath handling
@@ -74,11 +80,22 @@ def CONFIG_PATH(conf, name, default):
 def set_rpath(bld):
     import Options
     if Options.is_install:
 def set_rpath(bld):
     import Options
     if Options.is_install:
-        bld.env['RPATH'] = ['-Wl,-rpath=%s/%s' % (bld.env.PREFIX, LIB_PATH)]
+        if bld.env['RPATH_ON_INSTALL']:
+            bld.env['RPATH'] = ['-Wl,-rpath=%s/lib' % bld.env.PREFIX]
+        else:
+            bld.env['RPATH'] = []
     else:
     else:
-        bld.env.append_value('RPATH', '-Wl,-rpath=bin/%s' % LIB_PATH)
+        rpath = os.path.normpath('%s/bin/%s' % (bld.curdir, LIB_PATH))
+        bld.env.append_value('RPATH', '-Wl,-rpath=%s' % rpath)
 Build.BuildContext.set_rpath = set_rpath
 
 Build.BuildContext.set_rpath = set_rpath
 
+#############################################################
+# a build assert call
+def ASSERT(ctx, expression, msg):
+    if not expression:
+        sys.stderr.write("ERROR: %s\n" % msg)
+        raise AssertionError
+Build.BuildContext.ASSERT = ASSERT
 
 ################################################################
 # create a list of files by pre-pending each with a subdir name
 
 ################################################################
 # create a list of files by pre-pending each with a subdir name
@@ -97,16 +114,37 @@ def SAMBA_BUILD_ENV(conf):
     if not os.path.exists(libpath):
         os.mkdir(libpath)
 
     if not os.path.exists(libpath):
         os.mkdir(libpath)
 
+##############################################
+# remove .. elements from a path list
+def NORMPATH(bld, ilist):
+    return " ".join([os.path.normpath(p) for p in ilist.split(" ")])
+Build.BuildContext.NORMPATH = NORMPATH
 
 ################################################################
 # this will contain the set of includes needed per Samba library
 Build.BuildContext.SAMBA_LIBRARY_INCLUDES = {}
 
 
 ################################################################
 # this will contain the set of includes needed per Samba library
 Build.BuildContext.SAMBA_LIBRARY_INCLUDES = {}
 
+################################################################
+# init function list for a subsystem
+Build.BuildContext.SAMBA_INIT_FUNCTIONS = {}
+
+################################################################
+# add an init_function to the list for a subsystem
+def ADD_INIT_FUNCTION(bld, subsystem, init_function):
+    if init_function is None:
+        return
+    bld.ASSERT(subsystem is not None, "You must specify a subsystem for init_function '%s'" % init_function)
+    if not subsystem in bld.SAMBA_INIT_FUNCTIONS:
+        bld.SAMBA_INIT_FUNCTIONS[subsystem] = ''
+    bld.SAMBA_INIT_FUNCTIONS[subsystem] += '%s,' % init_function
+Build.BuildContext.ADD_INIT_FUNCTION = ADD_INIT_FUNCTION
+
+
 #################################################################
 # return a include list for a set of library dependencies
 #################################################################
 # return a include list for a set of library dependencies
-def SAMBA_LIBRARY_INCLUDE_LIST(bld, libdeps):
+def SAMBA_LIBRARY_INCLUDE_LIST(bld, deps):
     ret = bld.curdir + ' '
     ret = bld.curdir + ' '
-    for l in libdeps.split():
+    for l in deps.split():
         if l in bld.SAMBA_LIBRARY_INCLUDES:
             ret = ret + bld.SAMBA_LIBRARY_INCLUDES[l] + ' '
     return ret
         if l in bld.SAMBA_LIBRARY_INCLUDES:
             ret = ret + bld.SAMBA_LIBRARY_INCLUDES[l] + ' '
     return ret
@@ -115,13 +153,14 @@ Build.BuildContext.SAMBA_LIBRARY_INCLUDE_LIST = SAMBA_LIBRARY_INCLUDE_LIST
 #################################################################
 # define a Samba library
 def SAMBA_LIBRARY(bld, libname, source_list,
 #################################################################
 # define a Samba library
 def SAMBA_LIBRARY(bld, libname, source_list,
-                  libdeps='', include_list='.', vnum=None):
-    ilist = bld.SAMBA_LIBRARY_INCLUDE_LIST(libdeps) + bld.SUBDIR(bld.curdir, include_list)
+                  deps='', include_list='.', vnum=None):
+    ilist = bld.SAMBA_LIBRARY_INCLUDE_LIST(deps) + bld.SUBDIR(bld.curdir, include_list)
+    ilist = bld.NORMPATH(ilist)
     bld(
         features = 'cc cshlib',
         source = source_list,
         target=libname,
     bld(
         features = 'cc cshlib',
         source = source_list,
         target=libname,
-        uselib_local = libdeps,
+        uselib_local = deps,
         includes='. ' + os.environ.get('PWD') + '/bin/default ' + ilist,
         vnum=vnum)
 
         includes='. ' + os.environ.get('PWD') + '/bin/default ' + ilist,
         vnum=vnum)
 
@@ -139,25 +178,74 @@ def SAMBA_LIBRARY(bld, libname, source_list,
     bld.SAMBA_LIBRARY_INCLUDES[libname] = ilist
 Build.BuildContext.SAMBA_LIBRARY = SAMBA_LIBRARY
 
     bld.SAMBA_LIBRARY_INCLUDES[libname] = ilist
 Build.BuildContext.SAMBA_LIBRARY = SAMBA_LIBRARY
 
+
 #################################################################
 # define a Samba binary
 #################################################################
 # define a Samba binary
-def SAMBA_BINARY(bld, binname, source_list, libdeps='', syslibs='', include_list=''):
+def SAMBA_BINARY(bld, binname, source_list, deps='', syslibs='',
+                 include_list='', modules=None):
+    ilist = '. ' + os.environ.get('PWD') + '/bin/default ' + bld.SAMBA_LIBRARY_INCLUDE_LIST(deps) + ' ' + include_list
+    ilist = bld.NORMPATH(ilist)
+    ccflags = ''
+
+    if modules is not None:
+        for m in modules.split():
+            bld.ASSERT(m in bld.SAMBA_INIT_FUNCTIONS,
+                       "No init_function defined for module '%s' in binary '%s'" % (m, binname))
+            modlist = bld.SAMBA_INIT_FUNCTIONS[m]
+            ccflags += ' -DSTATIC_%s_MODULES="%s"' % (m, modlist)
+
     bld(
         features = 'cc cprogram',
         source = source_list,
         target = binname,
     bld(
         features = 'cc cprogram',
         source = source_list,
         target = binname,
-        uselib_local = libdeps,
+        uselib_local = deps,
         uselib = syslibs,
         uselib = syslibs,
-        includes = '. ' + os.environ.get('PWD') + '/bin/default ' + bld.SAMBA_LIBRARY_INCLUDE_LIST(libdeps) + include_list,
+        includes = ilist,
+        ccflags = ccflags,
         top=True)
     # put a link to the binary in bin/
     bld(
         source = binname,
         rule = 'ln -sf ${SRC} .',
         )
         top=True)
     # put a link to the binary in bin/
     bld(
         source = binname,
         rule = 'ln -sf ${SRC} .',
         )
-
 Build.BuildContext.SAMBA_BINARY = SAMBA_BINARY
 
 Build.BuildContext.SAMBA_BINARY = SAMBA_BINARY
 
+
+################################################################
+# build a C prototype file automatically
+def AUTOPROTO(bld, header, source_list):
+    if header is not None:
+        bld(
+            source = source_list,
+            target = header,
+            rule = '../script/mkproto.pl --srcdir=.. --builddir=. --public=/dev/null --private=${TGT} ${SRC}'
+            )
+Build.BuildContext.AUTOPROTO = AUTOPROTO
+
+
+#################################################################
+# define a Samba module.
+def SAMBA_MODULE(bld, modname, source_list,
+                 deps='', include_list='.',
+                 subsystem=None,
+                 init_function=None,
+                 autoproto=None):
+    bld.ADD_INIT_FUNCTION(subsystem, init_function)
+    bld.AUTOPROTO(autoproto, source_list)
+    bld.SAMBA_LIBRARY(modname, source_list,
+                      deps=deps, include_list=include_list)
+Build.BuildContext.SAMBA_MODULE = SAMBA_MODULE
+
+#################################################################
+# define a Samba subsystem
+def SAMBA_SUBSYSTEM(bld, modname, source_list,
+                    deps='', include_list='.',
+                    autoproto=None):
+    bld.SAMBA_LIBRARY(modname, source_list,
+                      deps=deps, include_list=include_list)
+Build.BuildContext.SAMBA_SUBSYSTEM = SAMBA_SUBSYSTEM
+
+
 ############################################################
 # this overrides the 'waf -v' debug output to be in a nice
 # unix like format instead of a python list.
 ############################################################
 # this overrides the 'waf -v' debug output to be in a nice
 # unix like format instead of a python list.
index 04665a0ec168a3b06cd7959945b9222e247cf072..d40843522cfe2e6c437f42e4b11f3fee61f61f2c 100644 (file)
@@ -14,9 +14,12 @@ def set_options(opt):
     opt.add_option('--sbindir',
                    help=("system admin executables [PREFIX/sbin]"),
                    action="store", dest='SBINDIR', default=None)
     opt.add_option('--sbindir',
                    help=("system admin executables [PREFIX/sbin]"),
                    action="store", dest='SBINDIR', default=None)
-    opt.add_option('--disable-rpath',
-                   help=("Disable use of rpath"),
-                   action="store_true", dest='disable_rpath', default=False)
+    opt.add_option('--enable-rpath',
+                   help=("Enable use of rpath for installed binaries"),
+                   action="store_true", dest='enable_rpath', default=False)
+    opt.add_option('--enable-developer',
+                   help=("Turn on developer warnings and debugging"),
+                   action="store_true", dest='developer', default=False)
 
 @wafsamba.runonce
 def configure(conf):
 
 @wafsamba.runonce
 def configure(conf):
@@ -30,6 +33,12 @@ def configure(conf):
     conf.CONFIG_PATH('SBINDIR', '/sbin')
 
     conf.check_tool('compiler_cc')
     conf.CONFIG_PATH('SBINDIR', '/sbin')
 
     conf.check_tool('compiler_cc')
+
+    if Options.options.developer:
+        conf.ADD_CFLAGS('-Wall -g -DDEVELOPER')
+
+    conf.env['RPATH_ON_INSTALL'] = Options.options.enable_rpath
+
     conf.DEFUN('_GNU_SOURCE', 1)
     conf.DEFUN('_XOPEN_SOURCE_EXTENDED', 1)
     conf.DEFUN('LIBREPLACE_NETWORK_CHECKS', 1)
     conf.DEFUN('_GNU_SOURCE', 1)
     conf.DEFUN('_XOPEN_SOURCE_EXTENDED', 1)
     conf.DEFUN('LIBREPLACE_NETWORK_CHECKS', 1)
index ad8ef3bd454cb1f5a1d76f1435284b1c5bbc7068..ca941c0555bd92c0a15028ee12f95e3f8417624a 100644 (file)
@@ -17,7 +17,7 @@ def build(bld):
 
     bld.SAMBA_LIBRARY('talloc',
                       'talloc.c',
 
     bld.SAMBA_LIBRARY('talloc',
                       'talloc.c',
-                      libdeps='replace',
+                      deps='replace',
                       vnum=VERSION)
 
     bld.SAMBA_BINARY('talloc_testsuite',
                       vnum=VERSION)
 
     bld.SAMBA_BINARY('talloc_testsuite',
index d7e3d5afd1d1bf5b5329ff98191f732bf934c9dc..0b159d4345f8922b4a716b9fd8a67da27102a0cb 100644 (file)
@@ -22,7 +22,7 @@ def build(bld):
 
     bld.SAMBA_LIBRARY('tdb',
                       COMMON_SRC,
 
     bld.SAMBA_LIBRARY('tdb',
                       COMMON_SRC,
-                      libdeps='replace',
+                      deps='replace',
                       include_list='include',
                       vnum=VERSION)
 
                       include_list='include',
                       vnum=VERSION)
 
index aaa3ce7fb710e751e4f099d29b59a524edf689f8..a36d8bf68c4f7c2a2a085d001fe5f798aa3f68ee 100644 (file)
@@ -30,5 +30,5 @@ def build(bld):
 
     bld.SAMBA_LIBRARY('tevent',
                       SRC,
 
     bld.SAMBA_LIBRARY('tevent',
                       SRC,
-                      libdeps='replace talloc',
+                      deps='replace talloc',
                       vnum=VERSION)
                       vnum=VERSION)
index 1103ec62994bc0357c9939a7e4d22db84b19dfc5..0c06ebbf6b3fe58ef94ad6c12f361427a667dc63 100644 (file)
@@ -37,7 +37,7 @@ def build(bld):
 
     bld.SAMBA_LIBRARY('ldb',
                      LDB_TDB_SRC + ' ' + COMMON_SRC + ' ' + MODULES_SRC,
 
     bld.SAMBA_LIBRARY('ldb',
                      LDB_TDB_SRC + ' ' + COMMON_SRC + ' ' + MODULES_SRC,
-                     libdeps='tdb tevent',
+                     deps='tdb tevent',
                      include_list='include',
                       vnum=VERSION)
 
                      include_list='include',
                       vnum=VERSION)
 
@@ -45,5 +45,5 @@ def build(bld):
     for t in LDB_TOOLS.split():
         bld.SAMBA_BINARY(t,
                          'tools/%s.c tools/ldbutil.c tools/cmdline.c' % t,
     for t in LDB_TOOLS.split():
         bld.SAMBA_BINARY(t,
                          'tools/%s.c tools/ldbutil.c tools/cmdline.c' % t,
-                         libdeps='ldb',
+                         deps='ldb',
                          syslibs='dl popt')
                          syslibs='dl popt')
diff --git a/source4/wscript b/source4/wscript
new file mode 100644 (file)
index 0000000..ecbcdc2
--- /dev/null
@@ -0,0 +1,34 @@
+srcdir = '..'
+blddir = 'bin'
+
+LIBREPLACE_DIR= srcdir + '/lib/replace'
+LIBLDB_DIR=     srcdir + '/source4/lib/ldb'
+
+def set_options(opt):
+    opt.recurse(LIBREPLACE_DIR)
+    opt.recurse(LIBLDB_DIR)
+
+def configure(conf):
+    conf.DEFUN('_SAMBA_BUILD_', 4)
+    conf.sub_config(LIBREPLACE_DIR)
+    conf.sub_config(LIBLDB_DIR)
+
+    conf.DEFUN('CONFIG_H_IS_FROM_SAMBA', 1)
+    conf.ADD_CFLAGS('-I.. -I../lib -I../../lib  -I../.. -I../include -Idefault/source4')
+    conf.ADD_CFLAGS('-I../../lib/socket_wrapper -I../../lib/talloc -I../../lib/replace -I../../lib/tevent')
+
+
+    conf.ADD_CFLAGS('-I../heimdal_build -I../heimdal/lib/krb5 -I../heimdal/lib/asn1 -I../heimdal/lib/com_err -I -I../heimdal/lib/hx509 -I../heimdal/lib/roken -I../heimdal/lib/hx509 -I../heimdal/lib/asn1 -I../heimdal/lib/hcrypto -I../heimdal/lib -I../heimdal/lib/hcrypto/imath -I../heimdal/lib/wind')
+    conf.DEFUN('HAVE_KRB5', 1)
+    conf.SAMBA_CONFIG_H()
+
+def build(bld):
+    bld.add_subdirs(LIBREPLACE_DIR)
+    bld.add_subdirs(LIBLDB_DIR)
+    bld.add_subdirs('dsdb')
+    bld.add_subdirs('smbd')
+
+    # some of source wants include/config.h, so
+    # create a link from the real config.h
+    bld(target='include/config.h',
+        rule='ln -sf ../../config.h ${TGT}')