summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-03-17 20:26:03 +1100
committerAndrew Tridgell <tridge@samba.org>2010-04-06 20:26:34 +1000
commit9a1cd09a10b475a2b18059a7ac6cb6915e9dfaf0 (patch)
tree08a0cc0eb8e23d6e16a2f530724b2577a590c282
parent7723519cf7544382069c7f77f915ebe9fe236efe (diff)
downloadsamba-9a1cd09a10b475a2b18059a7ac6cb6915e9dfaf0.tar.gz
samba-9a1cd09a10b475a2b18059a7ac6cb6915e9dfaf0.tar.bz2
samba-9a1cd09a10b475a2b18059a7ac6cb6915e9dfaf0.zip
build: added ADD_CFLAGS() and started of Samba4 build
-rw-r--r--lib/replace/wafsamba.py112
-rw-r--r--lib/replace/wscript15
-rw-r--r--lib/talloc/wscript2
-rw-r--r--lib/tdb/wscript2
-rw-r--r--lib/tevent/wscript2
-rw-r--r--source4/lib/ldb/wscript4
-rw-r--r--source4/wscript34
7 files changed, 151 insertions, 20 deletions
diff --git a/lib/replace/wafsamba.py b/lib/replace/wafsamba.py
index b01f4ec4f8..5b12cdb718 100644
--- a/lib/replace/wafsamba.py
+++ b/lib/replace/wafsamba.py
@@ -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
-import Build, os, Logs
+import Build, os, Logs, sys
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)
+##############################################################
+# add some CFLAGS to the command line
+@conf
+def ADD_CFLAGS(conf, flags):
+ conf.env.append_value('CCFLAGS', flags.split())
+
################################################################
# magic rpath handling
@@ -74,11 +80,22 @@ def CONFIG_PATH(conf, name, default):
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:
- 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
+#############################################################
+# 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
@@ -97,16 +114,37 @@ def SAMBA_BUILD_ENV(conf):
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 = {}
+################################################################
+# 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
-def SAMBA_LIBRARY_INCLUDE_LIST(bld, libdeps):
+def SAMBA_LIBRARY_INCLUDE_LIST(bld, deps):
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
@@ -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,
- 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,
- uselib_local = libdeps,
+ uselib_local = deps,
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
+
#################################################################
# 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,
- uselib_local = libdeps,
+ uselib_local = deps,
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} .',
)
-
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.
diff --git a/lib/replace/wscript b/lib/replace/wscript
index 04665a0ec1..d40843522c 100644
--- a/lib/replace/wscript
+++ b/lib/replace/wscript
@@ -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('--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):
@@ -30,6 +33,12 @@ def configure(conf):
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)
diff --git a/lib/talloc/wscript b/lib/talloc/wscript
index ad8ef3bd45..ca941c0555 100644
--- a/lib/talloc/wscript
+++ b/lib/talloc/wscript
@@ -17,7 +17,7 @@ def build(bld):
bld.SAMBA_LIBRARY('talloc',
'talloc.c',
- libdeps='replace',
+ deps='replace',
vnum=VERSION)
bld.SAMBA_BINARY('talloc_testsuite',
diff --git a/lib/tdb/wscript b/lib/tdb/wscript
index d7e3d5afd1..0b159d4345 100644
--- a/lib/tdb/wscript
+++ b/lib/tdb/wscript
@@ -22,7 +22,7 @@ def build(bld):
bld.SAMBA_LIBRARY('tdb',
COMMON_SRC,
- libdeps='replace',
+ deps='replace',
include_list='include',
vnum=VERSION)
diff --git a/lib/tevent/wscript b/lib/tevent/wscript
index aaa3ce7fb7..a36d8bf68c 100644
--- a/lib/tevent/wscript
+++ b/lib/tevent/wscript
@@ -30,5 +30,5 @@ def build(bld):
bld.SAMBA_LIBRARY('tevent',
SRC,
- libdeps='replace talloc',
+ deps='replace talloc',
vnum=VERSION)
diff --git a/source4/lib/ldb/wscript b/source4/lib/ldb/wscript
index 1103ec6299..0c06ebbf6b 100644
--- a/source4/lib/ldb/wscript
+++ b/source4/lib/ldb/wscript
@@ -37,7 +37,7 @@ def build(bld):
bld.SAMBA_LIBRARY('ldb',
LDB_TDB_SRC + ' ' + COMMON_SRC + ' ' + MODULES_SRC,
- libdeps='tdb tevent',
+ deps='tdb tevent',
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,
- libdeps='ldb',
+ deps='ldb',
syslibs='dl popt')
diff --git a/source4/wscript b/source4/wscript
new file mode 100644
index 0000000000..ecbcdc2159
--- /dev/null
+++ b/source4/wscript
@@ -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}')