1 # a waf tool to add autoconf-like macros to the configure section
2 # and for SAMBA_ macros for building libraries, binaries etc
5 from waflib import Build
6 from samba_utils import TO_LIST
7 from samba_autoconf import library_flags
9 def SAMBA3_IS_STATIC_MODULE(bld, module):
10 '''Check whether module is in static list'''
11 if module in bld.env['static_modules']:
14 Build.BuildContext.SAMBA3_IS_STATIC_MODULE = SAMBA3_IS_STATIC_MODULE
16 def SAMBA3_IS_SHARED_MODULE(bld, module):
17 '''Check whether module is in shared list'''
18 if module in bld.env['shared_modules']:
21 Build.BuildContext.SAMBA3_IS_SHARED_MODULE = SAMBA3_IS_SHARED_MODULE
23 def SAMBA3_IS_ENABLED_MODULE(bld, module):
24 '''Check whether module is in either shared or static list '''
25 return SAMBA3_IS_STATIC_MODULE(bld, module) or SAMBA3_IS_SHARED_MODULE(bld, module)
26 Build.BuildContext.SAMBA3_IS_ENABLED_MODULE = SAMBA3_IS_ENABLED_MODULE
30 def s3_fix_kwargs(bld, kwargs):
31 '''fix the build arguments for s3 build rules to include the
32 necessary includes, subdir and cflags options '''
33 s3dir = os.path.join(bld.env.srcdir, 'source3')
34 s3reldir = os.path.relpath(s3dir, bld.path.abspath())
36 # the extra_includes list is relative to the source3 directory
37 extra_includes = [ '.', 'include', 'lib' ]
38 # local heimdal paths only included when USING_SYSTEM_KRB5 is not set
39 if not bld.CONFIG_SET("USING_SYSTEM_KRB5"):
40 extra_includes += [ '../source4/heimdal/lib/com_err',
41 '../source4/heimdal/lib/krb5',
42 '../source4/heimdal/lib/gssapi',
43 '../source4/heimdal_build',
44 '../bin/default/source4/heimdal/lib/asn1' ]
46 if bld.CONFIG_SET('USING_SYSTEM_TDB'):
47 (tdb_includes, tdb_ldflags, tdb_cpppath) = library_flags(bld, 'tdb')
48 extra_includes += tdb_cpppath
50 extra_includes += [ '../lib/tdb/include' ]
52 if bld.CONFIG_SET('USING_SYSTEM_TEVENT'):
53 (tevent_includes, tevent_ldflags, tevent_cpppath) = library_flags(bld, 'tevent')
54 extra_includes += tevent_cpppath
56 extra_includes += [ '../lib/tevent' ]
58 if bld.CONFIG_SET('USING_SYSTEM_TALLOC'):
59 (talloc_includes, talloc_ldflags, talloc_cpppath) = library_flags(bld, 'talloc')
60 extra_includes += talloc_cpppath
62 extra_includes += [ '../lib/talloc' ]
64 if bld.CONFIG_SET('USING_SYSTEM_POPT'):
65 (popt_includes, popt_ldflags, popt_cpppath) = library_flags(bld, 'popt')
66 extra_includes += popt_cpppath
68 extra_includes += [ '../lib/popt' ]
70 # s3 builds assume that they will have a bunch of extra include paths
72 for d in extra_includes:
73 includes += [ os.path.join(s3reldir, d) ]
75 # the rule may already have some includes listed
76 if 'includes' in kwargs:
77 includes += TO_LIST(kwargs['includes'])
78 kwargs['includes'] = includes
80 # these wrappers allow for mixing of S3 and S4 build rules in the one build
82 def SAMBA3_LIBRARY(bld, name, *args, **kwargs):
83 s3_fix_kwargs(bld, kwargs)
84 return bld.SAMBA_LIBRARY(name, *args, **kwargs)
85 Build.BuildContext.SAMBA3_LIBRARY = SAMBA3_LIBRARY
87 def SAMBA3_MODULE(bld, name, *args, **kwargs):
88 s3_fix_kwargs(bld, kwargs)
89 return bld.SAMBA_MODULE(name, *args, **kwargs)
90 Build.BuildContext.SAMBA3_MODULE = SAMBA3_MODULE
92 def SAMBA3_SUBSYSTEM(bld, name, *args, **kwargs):
93 s3_fix_kwargs(bld, kwargs)
94 return bld.SAMBA_SUBSYSTEM(name, *args, **kwargs)
95 Build.BuildContext.SAMBA3_SUBSYSTEM = SAMBA3_SUBSYSTEM
97 def SAMBA3_BINARY(bld, name, *args, **kwargs):
98 s3_fix_kwargs(bld, kwargs)
99 return bld.SAMBA_BINARY(name, *args, **kwargs)
100 Build.BuildContext.SAMBA3_BINARY = SAMBA3_BINARY
102 def SAMBA3_PYTHON(bld, name, *args, **kwargs):
103 s3_fix_kwargs(bld, kwargs)
104 return bld.SAMBA_PYTHON(name, *args, **kwargs)
105 Build.BuildContext.SAMBA3_PYTHON = SAMBA3_PYTHON