@conf
def CHECK_HEADERS(conf, list):
- for hdr in list.rsplit(' '):
+ for hdr in list.split():
if conf.check(header_name=hdr):
conf.env.hlist.append(hdr)
@conf
def CHECK_TYPES(conf, list):
- for t in list.rsplit(' '):
+ for t in list.split():
conf.check(type_name=t, header_name=conf.env.hlist)
@conf
@conf
def CHECK_FUNCS(conf, list):
- for f in list.rsplit(' '):
+ for f in list.split():
conf.check(function_name=f, header_name=conf.env.hlist)
@conf
def CHECK_FUNCS_IN(conf, list, library):
if conf.check(lib=library, uselib_store=library):
- for f in list.rsplit(' '):
+ for f in list.split():
conf.check(function_name=f, lib=library, header_name=conf.env.hlist)
+#################################################
+# write out config.h in the right directory
+@conf
+def SAMBA_CONFIG_H(conf):
+ import os
+ if os.path.normpath(conf.curdir) == os.path.normpath(conf.srcdir):
+ conf.write_config_header('config.h')
+
+
################################################################
# magic rpath handling
#
bld.env.append_value('RPATH', '-Wl,-rpath=build/default')
Build.BuildContext.set_rpath = set_rpath
+
+################################################################
+# create a list of files by pre-pending each with a subdir name
+def SUBDIR(bld, subdir, list):
+ ret = ''
+ for l in list.split():
+ ret = ret + subdir + '/' + l + ' '
+ return ret
+Build.BuildContext.SUBDIR = SUBDIR
+
################################################################
# this will contain the set of includes needed per Samba library
Build.BuildContext.SAMBA_LIBRARY_INCLUDES = {}
# return a include list for a set of library dependencies
def SAMBA_LIBRARY_INCLUDE_LIST(bld, libdeps):
ret = bld.curdir + ' '
- for l in libdeps.rsplit(' '):
+ for l in libdeps.split():
if l in bld.SAMBA_LIBRARY_INCLUDES:
ret = ret + bld.SAMBA_LIBRARY_INCLUDES[l] + ' '
return ret
#################################################################
# define a Samba library
-def SAMBA_LIBRARY(bld, libname, source_list, libdeps='', include_list=''):
- ilist = bld.SAMBA_LIBRARY_INCLUDE_LIST(libdeps) + include_list
+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)
bld(
features = 'cc cshlib',
source = source_list,
target=libname,
- includes=ilist)
+ includes='. ' + ilist,
+ vnum=vnum)
bld.SAMBA_LIBRARY_INCLUDES[libname] = ilist
Build.BuildContext.SAMBA_LIBRARY = SAMBA_LIBRARY
source = source_list,
target = binname,
uselib_local = libdeps,
- includes = bld.SAMBA_LIBRARY_INCLUDE_LIST(libdeps) + include_list)
+ includes = '. ' + bld.SAMBA_LIBRARY_INCLUDE_LIST(libdeps) + include_list)
Build.BuildContext.SAMBA_BINARY = SAMBA_BINARY
############################################################
-# this overrides the normal -v debug output to be in a nice
-# unix like format. Thanks to ita on #waf for this
+# this overrides the 'waf -v' debug output to be in a nice
+# unix like format instead of a python list.
+# Thanks to ita on #waf for this
def exec_command(self, cmd, **kw):
- import Utils
- from Logs import debug
+ import Utils, Logs
_cmd = cmd
if isinstance(cmd, list):
_cmd = ' '.join(cmd)
- debug('runner: %s' % _cmd)
+ Logs.debug('runner: %s' % _cmd)
if self.log:
self.log.write('%s\n' % cmd)
kw['log'] = self.log
except AttributeError:
self.cwd = kw['cwd'] = self.bldnode.abspath()
return Utils.exec_command(cmd, **kw)
-
-import Build
Build.BuildContext.exec_command = exec_command
+
+
+######################################################
+# this is used as a decorator to make functions only
+# run once. Based on the idea from
+# http://stackoverflow.com/questions/815110/is-there-a-decorator-to-simply-cache-function-return-values
+runonce_ret = {}
+def runonce(function):
+ def wrapper(*args):
+ if args in runonce_ret:
+ return runonce_ret[args]
+ else:
+ ret = function(*args)
+ runonce_ret[args] = ret
+ return ret
+ return wrapper
srcdir = '.'
blddir = 'build'
-import Options, os
+import Options, os, wafsamba
def set_options(opt):
opt.tool_options('compiler_cc')
help=("Disable use of rpath"),
action="store_true", dest='disable_rpath', default=False)
+@wafsamba.runonce
def configure(conf):
conf.env.hlist = []
conf.DEFUN('_XOPEN_SOURCE_EXTENDED', 1)
conf.DEFUN('LIBREPLACE_NETWORK_CHECKS', 1)
- conf.CHECK_HEADERS('unistd.h sys/types.h stdlib.h stdio.h')
+ conf.CHECK_HEADERS('unistd.h sys/types.h stdlib.h stdio.h stddef.h')
conf.CHECK_HEADERS('sys/wait.h sys/stat.h malloc.h grp.h')
conf.CHECK_HEADERS('crypt.h dlfcn.h dl.h standards.h stdbool.h stdint.h')
conf.CHECK_HEADERS('sys/select.h setjmp.h utime.h sys/syslog.h syslog.h')
conf.CHECK_HEADERS('sys/uio.h ifaddrs.h direct.h dirent.h')
conf.CHECK_HEADERS('windows.h winsock2.h ws2tcpip.h')
+ if 'HAVE_STDDEF_H' in conf.env and 'HAVE_STDLIB_H' in conf.env:
+ conf.DEFUN('STDC_HEADERS', 1)
+
conf.check(type_name='long long')
conf.CHECK_TYPES('intptr_t uintptr_t ptrdiff_t')
conf.CHECK_TYPES('comparison_fn_t socklen_t bool')
conf.CHECK_FUNCS_IN('dlopen dlsym dlerror dlclose', 'dl')
+ conf.check_cc(fragment='''
+ #include <stdarg.h>
+ va_list ap1,ap2;
+ va_copy(ap1,ap2);
+ int main(void)
+ { return 0; }''',
+ define_name="HAVE_VA_COPY",
+ execute=0,
+ link=0,
+ define_ret=0,
+ quote=0,
+ msg="Checking for va_copy")
+
+
# we could also put code fragments like this in separate files,
# for example in test/snprintf.c
conf.check_cc(fragment='''
quote=0,
msg="Checking for C99 vsnprintf")
- conf.write_config_header('config.h')
+ conf.SAMBA_CONFIG_H()
def build(bld):
bld.set_rpath()
+VERSION='1.2.1'
+
srcdir = '.'
blddir = 'build'
+LIBREPLACE_DIR='../replace'
+
def set_options(opt):
- opt.recurse('../talloc')
+ opt.recurse(LIBREPLACE_DIR)
def configure(conf):
- conf.recurse('../talloc')
+ conf.sub_config(LIBREPLACE_DIR)
+ conf.SAMBA_CONFIG_H()
def build(bld):
- bld.recurse('../talloc')
+ bld.add_subdirs(LIBREPLACE_DIR)
- COMMON_SOURCE = '''common/check.c common/error.c common/tdb.c common/traverse.c
- common/freelistcheck.c common/lock.c common/dump.c common/freelist.c
- common/io.c common/open.c common/transaction.c'''
+ COMMON_SRC = bld.SUBDIR('common',
+ '''check.c error.c tdb.c traverse.c
+ freelistcheck.c lock.c dump.c freelist.c
+ io.c open.c transaction.c''')
bld.SAMBA_LIBRARY('tdb',
- COMMON_SOURCE,
- 'replace talloc',
- 'include')
+ COMMON_SRC,
+ libdeps='replace talloc',
+ include_list='include',
+ vnum=VERSION)
bld.SAMBA_BINARY('tdbtorture',
'tools/tdbtorture.c',