summaryrefslogtreecommitdiff
path: root/lib/replace
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-03-17 20:31:46 +1100
committerAndrew Tridgell <tridge@samba.org>2010-04-06 20:26:33 +1000
commit8f062f4a0f781b351e361ce07d0701f312069851 (patch)
tree25a71819137eafbc12ecd080e0af517d6fd52cb2 /lib/replace
parent8fd62757d25133cda01b38823040e05ac16ca7dc (diff)
downloadsamba-8f062f4a0f781b351e361ce07d0701f312069851.tar.gz
samba-8f062f4a0f781b351e361ce07d0701f312069851.tar.bz2
samba-8f062f4a0f781b351e361ce07d0701f312069851.zip
build: neater way to find libreplace and start on tevent waf build
Diffstat (limited to 'lib/replace')
-rw-r--r--lib/replace/wafsamba.py67
-rw-r--r--lib/replace/wscript24
2 files changed, 72 insertions, 19 deletions
diff --git a/lib/replace/wafsamba.py b/lib/replace/wafsamba.py
index 07eb1c9cfc..f0f4910d15 100644
--- a/lib/replace/wafsamba.py
+++ b/lib/replace/wafsamba.py
@@ -16,13 +16,13 @@ def DEFUN(conf, d, v):
@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
@@ -37,15 +37,24 @@ def CHECK_TYPE(conf, t, alternate):
@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
#
@@ -60,6 +69,16 @@ def set_rpath(bld):
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 = {}
@@ -72,7 +91,7 @@ Build.BuildContext.SAMBA_LIBRARY_DEPS = {}
# 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
@@ -81,13 +100,15 @@ Build.BuildContext.SAMBA_LIBRARY_INCLUDE_LIST = SAMBA_LIBRARY_INCLUDE_LIST
#################################################################
# 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
@@ -99,19 +120,19 @@ def SAMBA_BINARY(bld, binname, source_list, libdeps='', include_list=''):
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
@@ -121,6 +142,20 @@ def exec_command(self, cmd, **kw):
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
diff --git a/lib/replace/wscript b/lib/replace/wscript
index 6fc49e57dc..e4eebdf6de 100644
--- a/lib/replace/wscript
+++ b/lib/replace/wscript
@@ -1,7 +1,7 @@
srcdir = '.'
blddir = 'build'
-import Options, os
+import Options, os, wafsamba
def set_options(opt):
opt.tool_options('compiler_cc')
@@ -9,6 +9,7 @@ def set_options(opt):
help=("Disable use of rpath"),
action="store_true", dest='disable_rpath', default=False)
+@wafsamba.runonce
def configure(conf):
conf.env.hlist = []
@@ -20,7 +21,7 @@ def configure(conf):
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')
@@ -31,6 +32,9 @@ def configure(conf):
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')
@@ -68,6 +72,20 @@ def configure(conf):
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='''
@@ -110,7 +128,7 @@ main() { foo("hello"); }
quote=0,
msg="Checking for C99 vsnprintf")
- conf.write_config_header('config.h')
+ conf.SAMBA_CONFIG_H()
def build(bld):
bld.set_rpath()