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 Options
, Build
6 from samba_utils
import os_path_relpath
, TO_LIST
7 from samba_autoconf
import library_flags
9 Options
.OptionsContext
.SAMBA3_ADD_OPTION
= Options
.OptionsContext
.samba_add_onoff_option
11 def SAMBA3_IS_STATIC_MODULE(bld
, module
):
12 '''Check whether module is in static list'''
13 if module
in bld
.env
['static_modules']:
16 Build
.BuildContext
.SAMBA3_IS_STATIC_MODULE
= SAMBA3_IS_STATIC_MODULE
18 def SAMBA3_IS_SHARED_MODULE(bld
, module
):
19 '''Check whether module is in shared list'''
20 if module
in bld
.env
['shared_modules']:
23 Build
.BuildContext
.SAMBA3_IS_SHARED_MODULE
= SAMBA3_IS_SHARED_MODULE
25 def SAMBA3_IS_ENABLED_MODULE(bld
, module
):
26 '''Check whether module is in either shared or static list '''
27 return SAMBA3_IS_STATIC_MODULE(bld
, module
) or SAMBA3_IS_SHARED_MODULE(bld
, module
)
28 Build
.BuildContext
.SAMBA3_IS_ENABLED_MODULE
= SAMBA3_IS_ENABLED_MODULE
32 def s3_fix_kwargs(bld
, kwargs
):
33 '''fix the build arguments for s3 build rules to include the
34 necessary includes, subdir and cflags options '''
35 s3dir
= os
.path
.join(bld
.env
.srcdir
, 'source3')
36 s3reldir
= os_path_relpath(s3dir
, bld
.path
.abspath())
38 # the extra_includes list is relative to the source3 directory
39 extra_includes
= [ '.', 'include', 'lib' ]
40 # local heimdal paths only included when USING_SYSTEM_KRB5 is not set
41 if not bld
.CONFIG_SET("USING_SYSTEM_KRB5"):
42 extra_includes
+= [ '../source4/heimdal/lib/com_err',
43 '../source4/heimdal/lib/krb5',
44 '../source4/heimdal/lib/gssapi',
45 '../source4/heimdal_build',
46 '../bin/default/source4/heimdal/lib/asn1' ]
48 if bld
.CONFIG_SET('USING_SYSTEM_TDB'):
49 (tdb_includes
, tdb_ldflags
, tdb_cpppath
) = library_flags(bld
, 'tdb')
50 extra_includes
+= tdb_cpppath
52 extra_includes
+= [ '../lib/tdb/include' ]
54 if bld
.CONFIG_SET('USING_SYSTEM_TEVENT'):
55 (tevent_includes
, tevent_ldflags
, tevent_cpppath
) = library_flags(bld
, 'tevent')
56 extra_includes
+= tevent_cpppath
58 extra_includes
+= [ '../lib/tevent' ]
60 if bld
.CONFIG_SET('USING_SYSTEM_TALLOC'):
61 (talloc_includes
, talloc_ldflags
, talloc_cpppath
) = library_flags(bld
, 'talloc')
62 extra_includes
+= talloc_cpppath
64 extra_includes
+= [ '../lib/talloc' ]
66 if bld
.CONFIG_SET('USING_SYSTEM_POPT'):
67 (popt_includes
, popt_ldflags
, popt_cpppath
) = library_flags(bld
, 'popt')
68 extra_includes
+= popt_cpppath
70 extra_includes
+= [ '../lib/popt' ]
72 # s3 builds assume that they will have a bunch of extra include paths
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 # these wrappers allow for mixing of S3 and S4 build rules in the one build
84 def SAMBA3_LIBRARY(bld
, name
, *args
, **kwargs
):
85 s3_fix_kwargs(bld
, kwargs
)
86 return bld
.SAMBA_LIBRARY(name
, *args
, **kwargs
)
87 Build
.BuildContext
.SAMBA3_LIBRARY
= SAMBA3_LIBRARY
89 def SAMBA3_MODULE(bld
, name
, *args
, **kwargs
):
90 s3_fix_kwargs(bld
, kwargs
)
91 return bld
.SAMBA_MODULE(name
, *args
, **kwargs
)
92 Build
.BuildContext
.SAMBA3_MODULE
= SAMBA3_MODULE
94 def SAMBA3_SUBSYSTEM(bld
, name
, *args
, **kwargs
):
95 s3_fix_kwargs(bld
, kwargs
)
96 return bld
.SAMBA_SUBSYSTEM(name
, *args
, **kwargs
)
97 Build
.BuildContext
.SAMBA3_SUBSYSTEM
= SAMBA3_SUBSYSTEM
99 def SAMBA3_BINARY(bld
, name
, *args
, **kwargs
):
100 s3_fix_kwargs(bld
, kwargs
)
101 return bld
.SAMBA_BINARY(name
, *args
, **kwargs
)
102 Build
.BuildContext
.SAMBA3_BINARY
= SAMBA3_BINARY
104 def SAMBA3_PYTHON(bld
, name
, *args
, **kwargs
):
105 s3_fix_kwargs(bld
, kwargs
)
106 return bld
.SAMBA_PYTHON(name
, *args
, **kwargs
)
107 Build
.BuildContext
.SAMBA3_PYTHON
= SAMBA3_PYTHON