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 samba_utils
import os_path_relpath
, TO_LIST
, samba_add_onoff_option
6 from samba_autoconf
import library_flags
8 Options
.Handler
.SAMBA3_ADD_OPTION
= samba_add_onoff_option
10 def SAMBA3_IS_STATIC_MODULE(bld
, module
):
11 '''Check whether module is in static list'''
12 if module
in bld
.env
['static_modules']:
15 Build
.BuildContext
.SAMBA3_IS_STATIC_MODULE
= SAMBA3_IS_STATIC_MODULE
17 def SAMBA3_IS_SHARED_MODULE(bld
, module
):
18 '''Check whether module is in shared list'''
19 if module
in bld
.env
['shared_modules']:
22 Build
.BuildContext
.SAMBA3_IS_SHARED_MODULE
= SAMBA3_IS_SHARED_MODULE
24 def SAMBA3_IS_ENABLED_MODULE(bld
, module
):
25 '''Check whether module is in either shared or static list '''
26 return SAMBA3_IS_STATIC_MODULE(bld
, module
) or SAMBA3_IS_SHARED_MODULE(bld
, module
)
27 Build
.BuildContext
.SAMBA3_IS_ENABLED_MODULE
= SAMBA3_IS_ENABLED_MODULE
31 def s3_fix_kwargs(bld
, kwargs
):
32 '''fix the build arguments for s3 build rules to include the
33 necessary includes, subdir and cflags options '''
34 s3dir
= os
.path
.join(bld
.env
.srcdir
, 'source3')
35 s3reldir
= os_path_relpath(s3dir
, bld
.curdir
)
37 # the extra_includes list is relative to the source3 directory
38 extra_includes
= [ '.', 'include', 'lib' ]
39 # local heimdal paths only included when USING_SYSTEM_KRB5 is not set
40 if not bld
.CONFIG_SET("USING_SYSTEM_KRB5"):
41 extra_includes
+= [ '../source4/heimdal/lib/com_err',
42 '../source4/heimdal/lib/krb5',
43 '../source4/heimdal/lib/gssapi',
44 '../source4/heimdal_build',
45 '../bin/default/source4/heimdal/lib/asn1' ]
47 if bld
.CONFIG_SET('USING_SYSTEM_TDB'):
48 (tdb_includes
, tdb_ldflags
, tdb_cpppath
) = library_flags(bld
, 'tdb')
49 extra_includes
+= tdb_cpppath
51 extra_includes
+= [ '../lib/tdb/include' ]
53 if bld
.CONFIG_SET('USING_SYSTEM_TEVENT'):
54 (tevent_includes
, tevent_ldflags
, tevent_cpppath
) = library_flags(bld
, 'tevent')
55 extra_includes
+= tevent_cpppath
57 extra_includes
+= [ '../lib/tevent' ]
59 if bld
.CONFIG_SET('USING_SYSTEM_TALLOC'):
60 (talloc_includes
, talloc_ldflags
, talloc_cpppath
) = library_flags(bld
, 'talloc')
61 extra_includes
+= talloc_cpppath
63 extra_includes
+= [ '../lib/talloc' ]
65 if bld
.CONFIG_SET('USING_SYSTEM_POPT'):
66 (popt_includes
, popt_ldflags
, popt_cpppath
) = library_flags(bld
, 'popt')
67 extra_includes
+= popt_cpppath
69 extra_includes
+= [ '../lib/popt' ]
71 # s3 builds assume that they will have a bunch of extra include paths
73 for d
in extra_includes
:
74 includes
+= [ os
.path
.join(s3reldir
, d
) ]
76 # the rule may already have some includes listed
77 if 'includes' in kwargs
:
78 includes
+= TO_LIST(kwargs
['includes'])
79 kwargs
['includes'] = includes
81 # these wrappers allow for mixing of S3 and S4 build rules in the one build
83 def SAMBA3_LIBRARY(bld
, name
, *args
, **kwargs
):
84 s3_fix_kwargs(bld
, kwargs
)
85 return bld
.SAMBA_LIBRARY(name
, *args
, **kwargs
)
86 Build
.BuildContext
.SAMBA3_LIBRARY
= SAMBA3_LIBRARY
88 def SAMBA3_MODULE(bld
, name
, *args
, **kwargs
):
89 s3_fix_kwargs(bld
, kwargs
)
90 return bld
.SAMBA_MODULE(name
, *args
, **kwargs
)
91 Build
.BuildContext
.SAMBA3_MODULE
= SAMBA3_MODULE
93 def SAMBA3_SUBSYSTEM(bld
, name
, *args
, **kwargs
):
94 s3_fix_kwargs(bld
, kwargs
)
95 return bld
.SAMBA_SUBSYSTEM(name
, *args
, **kwargs
)
96 Build
.BuildContext
.SAMBA3_SUBSYSTEM
= SAMBA3_SUBSYSTEM
98 def SAMBA3_BINARY(bld
, name
, *args
, **kwargs
):
99 s3_fix_kwargs(bld
, kwargs
)
100 return bld
.SAMBA_BINARY(name
, *args
, **kwargs
)
101 Build
.BuildContext
.SAMBA3_BINARY
= SAMBA3_BINARY
103 def SAMBA3_PYTHON(bld
, name
, *args
, **kwargs
):
104 s3_fix_kwargs(bld
, kwargs
)
105 return bld
.SAMBA_PYTHON(name
, *args
, **kwargs
)
106 Build
.BuildContext
.SAMBA3_PYTHON
= SAMBA3_PYTHON