7b42075d1abfb38c0e59a5256e2ef21b385ecabf
[gd/samba-autobuild/.git] / buildtools / wafsamba / samba3.py
1 # a waf tool to add autoconf-like macros to the configure section
2 # and for SAMBA_ macros for building libraries, binaries etc
3
4 import os
5 from waflib import Build
6 from samba_utils import TO_LIST
7 from samba_autoconf import library_flags
8
9 def SAMBA3_IS_STATIC_MODULE(bld, module):
10     '''Check whether module is in static list'''
11     if module in bld.env['static_modules']:
12         return True
13     return False
14 Build.BuildContext.SAMBA3_IS_STATIC_MODULE = SAMBA3_IS_STATIC_MODULE
15
16 def SAMBA3_IS_SHARED_MODULE(bld, module):
17     '''Check whether module is in shared list'''
18     if module in bld.env['shared_modules']:
19         return True
20     return False
21 Build.BuildContext.SAMBA3_IS_SHARED_MODULE = SAMBA3_IS_SHARED_MODULE
22
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
27
28
29
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())
35
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/lib/gssapi/gssapi',
44                             '../source4/heimdal_build/include',
45                             '../bin/default/source4/heimdal/lib/asn1' ]
46
47     if bld.CONFIG_SET('USING_SYSTEM_TDB'):
48         (tdb_includes, tdb_ldflags, tdb_cpppath) = library_flags(bld, 'tdb')
49         extra_includes += tdb_cpppath
50     else:
51         extra_includes += [ '../lib/tdb/include' ]
52
53     if bld.CONFIG_SET('USING_SYSTEM_TEVENT'):
54         (tevent_includes, tevent_ldflags, tevent_cpppath) = library_flags(bld, 'tevent')
55         extra_includes += tevent_cpppath
56     else:
57         extra_includes += [ '../lib/tevent' ]
58
59     if bld.CONFIG_SET('USING_SYSTEM_TALLOC'):
60         (talloc_includes, talloc_ldflags, talloc_cpppath) = library_flags(bld, 'talloc')
61         extra_includes += talloc_cpppath
62     else:
63         extra_includes += [ '../lib/talloc' ]
64
65     if bld.CONFIG_SET('USING_SYSTEM_POPT'):
66         (popt_includes, popt_ldflags, popt_cpppath) = library_flags(bld, 'popt')
67         extra_includes += popt_cpppath
68     else:
69         extra_includes += [ '../lib/popt' ]
70
71     # s3 builds assume that they will have a bunch of extra include paths
72     includes = []
73     for d in extra_includes:
74         includes += [ os.path.join(s3reldir, d) ]
75
76     # the rule may already have some includes listed
77     if 'includes' in kwargs:
78         includes += TO_LIST(kwargs['includes'])
79     kwargs['includes'] = includes
80
81 # these wrappers allow for mixing of S3 and S4 build rules in the one build
82
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
87
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
92
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
97
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
102
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