waf: Move python build instructions to wscript
[metze/samba/wip.git] / python / wscript
1 #!/usr/bin/env python
2
3 import os
4
5 def configure(conf):
6     kerberos_py = conf.srcdir + "/python/samba/provision/kerberos_implementation.py"
7
8     f = open(kerberos_py, 'w')
9     try:
10         header = """#
11 # Copyright (c) 2016      Andreas Schneider <asn@samba.org>
12 #
13 # This program is free software; you can redistribute it and/or modify
14 # it under the terms of the GNU General Public License as published by
15 # the Free Software Foundation; either version 3 of the License, or
16 # (at your option) any later version.
17 #
18 # This program is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 # GNU General Public License for more details.
22 #
23 # You should have received a copy of the GNU General Public License
24 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
25 #
26 """
27         f.write(header)
28
29         data = """kdb_modules_dir = "{0}"
30 kdc_default_config_dir = "{1}"
31 """
32
33         if conf.env.HEIMDAL_KRB5_CONFIG:
34             f.write(data.format("", ""))
35         else:
36             modulesdir = "%s/krb5/plugins/kdb" % conf.env.LIBDIR
37             paths = [ "/var/kerberos/krb5kdc", "/var/lib/kerberos/krb5kdc" ]
38             kdc_path = None
39             for p in paths:
40                 if os.path.exists(p):
41                     kdc_path = p
42
43             f.write(data.format(modulesdir, kdc_path))
44     finally:
45         f.close()
46
47 def build(bld):
48     bld.SAMBA_LIBRARY('samba_python',
49                       source=[],
50                       deps='''
51                            LIBPYTHON
52                            pytalloc-util
53                            pyrpc_util
54                            ''',
55                       grouping_library=True,
56                       private_library=True,
57                       pyembed=True,
58                       enabled=bld.PYTHON_BUILD_IS_ENABLED())
59
60     bld.SAMBA_SUBSYSTEM('LIBPYTHON',
61                         source='modules.c',
62                         public_deps='',
63                         init_function_sentinel='{NULL,NULL}',
64                         deps='talloc',
65                         pyext=True,
66                         enabled=bld.PYTHON_BUILD_IS_ENABLED())
67
68     for env in bld.gen_python_environments():
69         pytalloc_util = bld.pyembed_libname('pytalloc-util')
70         pyparam_util = bld.pyembed_libname('pyparam_util')
71
72         bld.SAMBA_PYTHON('python_glue',
73                          source='pyglue.c',
74                          deps='''
75                               %s
76                               samba-util
77                               netif
78                               %s
79                               ''' % (pyparam_util, pytalloc_util),
80                          realname='samba/_glue.so')
81
82     if bld.PYTHON_BUILD_IS_ENABLED():
83         for env in bld.gen_python_environments():
84             # install out various python scripts for use by make test
85             bld.SAMBA_SCRIPT('samba_python_files',
86                              pattern='samba/**/*.py',
87                              installdir='python')
88
89             bld.INSTALL_WILDCARD('${PYTHONARCHDIR}', 'samba/**/*.py', flat=False)