s3: Do not free a string where we should not
[Samba.git] / lib / talloc / wscript
blob8d3246b26bb937cffba24c944719fd13777e4e5b
1 #!/usr/bin/env python
3 APPNAME = 'talloc'
4 VERSION = '2.0.8'
7 blddir = 'bin'
9 import Logs
10 import os, sys
12 # find the buildtools directory
13 srcdir = '.'
14 while not os.path.exists(srcdir+'/buildtools') and len(srcdir.split('/')) < 5:
15 srcdir = '../' + srcdir
16 sys.path.insert(0, srcdir + '/buildtools/wafsamba')
18 import sys
19 sys.path.insert(0, srcdir+"/buildtools/wafsamba")
20 import wafsamba, samba_dist, Options
22 # setup what directories to put in a tarball
23 samba_dist.DIST_DIRS('lib/talloc:. lib/replace:lib/replace buildtools:buildtools')
26 def set_options(opt):
27 opt.BUILTIN_DEFAULT('replace')
28 opt.PRIVATE_EXTENSION_DEFAULT('talloc', noextension='talloc')
29 opt.RECURSE('lib/replace')
30 opt.add_option('--enable-talloc-compat1',
31 help=("Build talloc 1.x.x compat library [False]"),
32 action="store_true", dest='TALLOC_COMPAT1', default=False)
33 if opt.IN_LAUNCH_DIR():
34 opt.add_option('--disable-python',
35 help=("disable the pytalloc module"),
36 action="store_true", dest='disable_python', default=False)
39 def configure(conf):
40 conf.RECURSE('lib/replace')
42 conf.env.standalone_talloc = conf.IN_LAUNCH_DIR()
44 conf.env.disable_python = getattr(Options.options, 'disable_python', False)
46 if not conf.env.standalone_talloc:
47 if conf.CHECK_BUNDLED_SYSTEM_PKG('talloc', minversion=VERSION,
48 implied_deps='replace'):
49 conf.define('USING_SYSTEM_TALLOC', 1)
50 if conf.CHECK_BUNDLED_SYSTEM_PKG('pytalloc-util', minversion=VERSION,
51 implied_deps='talloc replace'):
52 conf.define('USING_SYSTEM_PYTALLOC_UTIL', 1)
54 conf.env.TALLOC_COMPAT1 = Options.options.TALLOC_COMPAT1
56 conf.CHECK_XSLTPROC_MANPAGES()
58 if not conf.env.disable_python:
59 # also disable if we don't have the python libs installed
60 conf.find_program('python', var='PYTHON')
61 conf.check_tool('python')
62 conf.check_python_version((2,4,2))
63 conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=False)
64 if not conf.env.HAVE_PYTHON_H:
65 Logs.warn('Disabling pytalloc-util as python devel libs not found')
66 conf.env.disable_python = True
68 conf.SAMBA_CONFIG_H()
70 conf.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
73 def build(bld):
74 bld.RECURSE('lib/replace')
76 if bld.env.standalone_talloc:
77 bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
78 bld.env.TALLOC_VERSION = VERSION
79 private_library = False
81 # should we also install the symlink to libtalloc1.so here?
82 bld.SAMBA_LIBRARY('talloc-compat1-%s' % (VERSION),
83 'compat/talloc_compat1.c',
84 public_deps='talloc',
85 soname='libtalloc.so.1',
86 pc_files=[],
87 public_headers=[],
88 enabled=bld.env.TALLOC_COMPAT1)
90 bld.SAMBA_BINARY('talloc_testsuite',
91 'testsuite_main.c testsuite.c',
92 deps='talloc',
93 install=False)
95 else:
96 private_library = True
98 if not bld.CONFIG_SET('USING_SYSTEM_TALLOC'):
100 bld.SAMBA_LIBRARY('talloc',
101 'talloc.c',
102 deps='replace',
103 abi_directory='ABI',
104 abi_match='talloc* _talloc*',
105 hide_symbols=True,
106 vnum=VERSION,
107 public_headers='talloc.h',
108 pc_files='talloc.pc',
109 public_headers_install=not private_library,
110 private_library=private_library,
111 manpages='talloc.3')
113 if not bld.CONFIG_SET('USING_SYSTEM_PYTALLOC_UTIL') and not bld.env.disable_python:
114 bld.SAMBA_LIBRARY('pytalloc-util',
115 source='pytalloc_util.c',
116 public_deps='talloc',
117 pyembed=True,
118 vnum=VERSION,
119 hide_symbols=True,
120 abi_directory='ABI',
121 abi_match='pytalloc_*',
122 private_library=private_library,
123 public_headers='pytalloc.h',
124 pc_files='pytalloc-util.pc'
126 bld.SAMBA_PYTHON('pytalloc',
127 'pytalloc.c',
128 deps='talloc pytalloc-util',
129 enabled=True,
130 realname='talloc.so')
132 def test(ctx):
133 '''run talloc testsuite'''
134 import Utils, samba_utils
135 cmd = os.path.join(Utils.g_module.blddir, 'talloc_testsuite')
136 ret = samba_utils.RUN_COMMAND(cmd)
137 print("testsuite returned %d" % ret)
138 sys.exit(ret)
140 def dist():
141 '''makes a tarball for distribution'''
142 samba_dist.dist()
144 def reconfigure(ctx):
145 '''reconfigure if config scripts have changed'''
146 import samba_utils
147 samba_utils.reconfigure(ctx)
150 def pydoctor(ctx):
151 '''build python apidocs'''
152 cmd='PYTHONPATH=bin/python pydoctor --project-name=talloc --project-url=http://talloc.samba.org/ --make-html --docformat=restructuredtext --introspect-c-modules --add-module bin/python/talloc.*'
153 print("Running: %s" % cmd)
154 os.system(cmd)