s3-build: Fix inotify detection (bug 8580)
[Samba.git] / buildtools / wafsamba / samba3.py
blobcb459ad115a6523b063d3b8c23dcade64504eebf
1 # a waf tool to add autoconf-like macros to the configure section
2 # and for SAMBA_ macros for building libraries, binaries etc
4 import Options, Build, os
5 from optparse import SUPPRESS_HELP
6 from samba_utils import os_path_relpath, TO_LIST
8 def SAMBA3_ADD_OPTION(opt, option, help=(), dest=None, default=True,
9 with_name="with", without_name="without"):
10 if help == ():
11 help = ("Build with %s support" % option)
12 if dest is None:
13 dest = "with_%s" % option.replace('-', '_')
15 with_val = "--%s-%s" % (with_name, option)
16 without_val = "--%s-%s" % (without_name, option)
18 #FIXME: This is broken and will always default to "default" no matter if
19 # --with or --without is chosen.
20 opt.add_option(with_val, help=help, action="store_true", dest=dest,
21 default=default)
22 opt.add_option(without_val, help=SUPPRESS_HELP, action="store_false",
23 dest=dest)
24 Options.Handler.SAMBA3_ADD_OPTION = SAMBA3_ADD_OPTION
26 def SAMBA3_IS_STATIC_MODULE(bld, module):
27 '''Check whether module is in static list'''
28 if module in bld.env['static_modules']:
29 return True
30 return False
31 Build.BuildContext.SAMBA3_IS_STATIC_MODULE = SAMBA3_IS_STATIC_MODULE
33 def SAMBA3_IS_SHARED_MODULE(bld, module):
34 '''Check whether module is in shared list'''
35 if module in bld.env['shared_modules']:
36 return True
37 return False
38 Build.BuildContext.SAMBA3_IS_SHARED_MODULE = SAMBA3_IS_SHARED_MODULE
40 def SAMBA3_IS_ENABLED_MODULE(bld, module):
41 '''Check whether module is in either shared or static list '''
42 return SAMBA3_IS_STATIC_MODULE(bld, module) or SAMBA3_IS_SHARED_MODULE(bld, module)
43 Build.BuildContext.SAMBA3_IS_ENABLED_MODULE = SAMBA3_IS_ENABLED_MODULE
47 def s3_fix_kwargs(bld, kwargs):
48 '''fix the build arguments for s3 build rules to include the
49 necessary includes, subdir and cflags options '''
50 s3dir = os.path.join(bld.env.srcdir, 'source3')
51 s3reldir = os_path_relpath(s3dir, bld.curdir)
53 # the extra_includes list is relative to the source3 directory
54 extra_includes = [ '.', 'include', 'lib' ]
55 if bld.env.use_intree_heimdal:
56 extra_includes += [ '../source4/heimdal/lib/com_err',
57 '../source4/heimdal/lib/gssapi',
58 '../source4/heimdal_build' ]
60 if not bld.CONFIG_SET('USING_SYSTEM_TDB'):
61 extra_includes += [ '../lib/tdb/include' ]
63 if not bld.CONFIG_SET('USING_SYSTEM_TEVENT'):
64 extra_includes += [ '../lib/tevent' ]
66 if not bld.CONFIG_SET('USING_SYSTEM_TALLOC'):
67 extra_includes += [ '../lib/talloc' ]
69 if not bld.CONFIG_SET('USING_SYSTEM_POPT'):
70 extra_includes += [ '../lib/popt' ]
72 # s3 builds assume that they will have a bunch of extra include paths
73 includes = []
74 for d in extra_includes:
75 includes += [ os.path.join(s3reldir, d) ]
77 # the rule may already have some includes listed
78 if 'includes' in kwargs:
79 includes += TO_LIST(kwargs['includes'])
80 kwargs['includes'] = includes
82 # some S3 code assumes that CONFIGFILE is set
83 cflags = ['-DCONFIGFILE="%s"' % bld.env['CONFIGFILE']]
84 if 'cflags' in kwargs:
85 cflags += TO_LIST(kwargs['cflags'])
86 kwargs['cflags'] = cflags
88 # these wrappers allow for mixing of S3 and S4 build rules in the one build
90 def SAMBA3_LIBRARY(bld, name, *args, **kwargs):
91 s3_fix_kwargs(bld, kwargs)
92 kwargs['allow_undefined_symbols'] = True
93 return bld.SAMBA_LIBRARY(name, *args, **kwargs)
94 Build.BuildContext.SAMBA3_LIBRARY = SAMBA3_LIBRARY
96 def SAMBA3_MODULE(bld, name, *args, **kwargs):
97 s3_fix_kwargs(bld, kwargs)
98 kwargs['allow_undefined_symbols'] = True
99 return bld.SAMBA_MODULE(name, *args, **kwargs)
100 Build.BuildContext.SAMBA3_MODULE = SAMBA3_MODULE
102 def SAMBA3_SUBSYSTEM(bld, name, *args, **kwargs):
103 s3_fix_kwargs(bld, kwargs)
104 return bld.SAMBA_SUBSYSTEM(name, *args, **kwargs)
105 Build.BuildContext.SAMBA3_SUBSYSTEM = SAMBA3_SUBSYSTEM
107 def SAMBA3_BINARY(bld, name, *args, **kwargs):
108 s3_fix_kwargs(bld, kwargs)
109 return bld.SAMBA_BINARY(name, *args, **kwargs)
110 Build.BuildContext.SAMBA3_BINARY = SAMBA3_BINARY