1 | #!/usr/bin/env python
|
---|
2 |
|
---|
3 | # this is a base set of waf rules that everything else pulls in first
|
---|
4 |
|
---|
5 | import os, sys
|
---|
6 | import wafsamba, Configure, Logs, Options, Utils
|
---|
7 | from samba_utils import os_path_relpath
|
---|
8 | from optparse import SUPPRESS_HELP
|
---|
9 |
|
---|
10 | # this forces configure to be re-run if any of the configure
|
---|
11 | # sections of the build scripts change. We have to check
|
---|
12 | # for this in sys.argv as options have not yet been parsed when
|
---|
13 | # we need to set this. This is off by default until some issues
|
---|
14 | # are resolved related to WAFCACHE. It will need a lot of testing
|
---|
15 | # before it is enabled by default.
|
---|
16 | if '--enable-auto-reconfigure' in sys.argv:
|
---|
17 | Configure.autoconfig = True
|
---|
18 |
|
---|
19 | def set_options(opt):
|
---|
20 | opt.tool_options('compiler_cc')
|
---|
21 |
|
---|
22 | opt.tool_options('gnu_dirs')
|
---|
23 |
|
---|
24 | gr = opt.option_group('library handling options')
|
---|
25 |
|
---|
26 | gr.add_option('--bundled-libraries',
|
---|
27 | help=("comma separated list of bundled libraries. May include !LIBNAME to disable bundling a library. Can be 'NONE' or 'ALL' [auto]"),
|
---|
28 | action="store", dest='BUNDLED_LIBS', default='')
|
---|
29 |
|
---|
30 | gr.add_option('--private-libraries',
|
---|
31 | help=("comma separated list of normally public libraries to build instead as private libraries. May include !LIBNAME to disable making a library private. Can be 'NONE' or 'ALL' [auto]"),
|
---|
32 | action="store", dest='PRIVATE_LIBS', default='')
|
---|
33 |
|
---|
34 | extension_default = Options.options['PRIVATE_EXTENSION_DEFAULT']
|
---|
35 | gr.add_option('--private-library-extension',
|
---|
36 | help=("name extension for private libraries [%s]" % extension_default),
|
---|
37 | action="store", dest='PRIVATE_EXTENSION', default=extension_default)
|
---|
38 |
|
---|
39 | extension_exception = Options.options['PRIVATE_EXTENSION_EXCEPTION']
|
---|
40 | gr.add_option('--private-extension-exception',
|
---|
41 | help=("comma separated list of libraries to not apply extension to [%s]" % extension_exception),
|
---|
42 | action="store", dest='PRIVATE_EXTENSION_EXCEPTION', default=extension_exception)
|
---|
43 |
|
---|
44 | builtin_default = Options.options['BUILTIN_LIBRARIES_DEFAULT']
|
---|
45 | gr.add_option('--builtin-libraries',
|
---|
46 | help=("command separated list of libraries to build directly into binaries [%s]" % builtin_default),
|
---|
47 | action="store", dest='BUILTIN_LIBRARIES', default=builtin_default)
|
---|
48 |
|
---|
49 | gr.add_option('--minimum-library-version',
|
---|
50 | help=("list of minimum system library versions (LIBNAME1:version,LIBNAME2:version)"),
|
---|
51 | action="store", dest='MINIMUM_LIBRARY_VERSION', default='')
|
---|
52 |
|
---|
53 | gr.add_option('--disable-rpath',
|
---|
54 | help=("Disable use of rpath for build binaries"),
|
---|
55 | action="store_true", dest='disable_rpath_build', default=False)
|
---|
56 | gr.add_option('--disable-rpath-install',
|
---|
57 | help=("Disable use of rpath for library path in installed files"),
|
---|
58 | action="store_true", dest='disable_rpath_install', default=False)
|
---|
59 | gr.add_option('--disable-rpath-private-install',
|
---|
60 | help=("Disable use of rpath for private library path in installed files"),
|
---|
61 | action="store_true", dest='disable_rpath_private_install', default=False)
|
---|
62 | gr.add_option('--nonshared-binary',
|
---|
63 | help=("Disable use of shared libs for the listed binaries"),
|
---|
64 | action="store", dest='NONSHARED_BINARIES', default='')
|
---|
65 | gr.add_option('--disable-symbol-versions',
|
---|
66 | help=("Disable use of the --version-script linker option"),
|
---|
67 | action="store_true", dest='disable_symbol_versions', default=False)
|
---|
68 |
|
---|
69 | opt.add_option('--with-modulesdir',
|
---|
70 | help=("modules directory [PREFIX/modules]"),
|
---|
71 | action="store", dest='MODULESDIR', default='${PREFIX}/modules')
|
---|
72 |
|
---|
73 | opt.add_option('--with-privatelibdir',
|
---|
74 | help=("private library directory [PREFIX/lib/%s]" % Utils.g_module.APPNAME),
|
---|
75 | action="store", dest='PRIVATELIBDIR', default=None)
|
---|
76 |
|
---|
77 | opt.add_option('--with-libiconv',
|
---|
78 | help='additional directory to search for libiconv',
|
---|
79 | action='store', dest='iconv_open', default='/usr/local',
|
---|
80 | match = ['Checking for library iconv', 'Checking for iconv_open', 'Checking for header iconv.h'])
|
---|
81 | opt.add_option('--without-gettext',
|
---|
82 | help=("Disable use of gettext"),
|
---|
83 | action="store_true", dest='disable_gettext', default=False)
|
---|
84 |
|
---|
85 | gr = opt.option_group('developer options')
|
---|
86 |
|
---|
87 | gr.add_option('-C',
|
---|
88 | help='enable configure cacheing',
|
---|
89 | action='store_true', dest='enable_configure_cache')
|
---|
90 | gr.add_option('--enable-auto-reconfigure',
|
---|
91 | help='enable automatic reconfigure on build',
|
---|
92 | action='store_true', dest='enable_auto_reconfigure')
|
---|
93 | gr.add_option('--enable-debug',
|
---|
94 | help=("Turn on debugging symbols"),
|
---|
95 | action="store_true", dest='debug', default=False)
|
---|
96 | gr.add_option('--enable-developer',
|
---|
97 | help=("Turn on developer warnings and debugging"),
|
---|
98 | action="store_true", dest='developer', default=False)
|
---|
99 | def picky_developer_callback(option, opt_str, value, parser):
|
---|
100 | parser.values.developer = True
|
---|
101 | parser.values.picky_developer = True
|
---|
102 | gr.add_option('--picky-developer',
|
---|
103 | help=("Treat all warnings as errors (enable -Werror)"),
|
---|
104 | action="callback", callback=picky_developer_callback,
|
---|
105 | dest='picky_developer', default=False)
|
---|
106 | gr.add_option('--fatal-errors',
|
---|
107 | help=("Stop compilation on first error (enable -Wfatal-errors)"),
|
---|
108 | action="store_true", dest='fatal_errors', default=False)
|
---|
109 | gr.add_option('--enable-gccdeps',
|
---|
110 | help=("Enable use of gcc -MD dependency module"),
|
---|
111 | action="store_true", dest='enable_gccdeps', default=True)
|
---|
112 | gr.add_option('--timestamp-dependencies',
|
---|
113 | help=("use file timestamps instead of content for build dependencies (BROKEN)"),
|
---|
114 | action="store_true", dest='timestamp_dependencies', default=False)
|
---|
115 | gr.add_option('--pedantic',
|
---|
116 | help=("Enable even more compiler warnings"),
|
---|
117 | action='store_true', dest='pedantic', default=False)
|
---|
118 | gr.add_option('--git-local-changes',
|
---|
119 | help=("mark version with + if local git changes"),
|
---|
120 | action='store_true', dest='GIT_LOCAL_CHANGES', default=False)
|
---|
121 | gr.add_option('--address-sanitizer',
|
---|
122 | help=("Enable address sanitizer compile and linker flags"),
|
---|
123 | action="store_true", dest='address_sanitizer', default=False)
|
---|
124 |
|
---|
125 | gr.add_option('--abi-check',
|
---|
126 | help=("Check ABI signatures for libraries"),
|
---|
127 | action='store_true', dest='ABI_CHECK', default=False)
|
---|
128 | gr.add_option('--abi-check-disable',
|
---|
129 | help=("Disable ABI checking (used with --enable-developer)"),
|
---|
130 | action='store_true', dest='ABI_CHECK_DISABLE', default=False)
|
---|
131 | gr.add_option('--abi-update',
|
---|
132 | help=("Update ABI signature files for libraries"),
|
---|
133 | action='store_true', dest='ABI_UPDATE', default=False)
|
---|
134 |
|
---|
135 | gr.add_option('--show-deps',
|
---|
136 | help=("Show dependency tree for the given target"),
|
---|
137 | dest='SHOWDEPS', default='')
|
---|
138 |
|
---|
139 | gr.add_option('--symbol-check',
|
---|
140 | help=("check symbols in object files against project rules"),
|
---|
141 | action='store_true', dest='SYMBOLCHECK', default=False)
|
---|
142 |
|
---|
143 | gr.add_option('--dup-symbol-check',
|
---|
144 | help=("check for duplicate symbols in object files and system libs (must be configured with --enable-developer)"),
|
---|
145 | action='store_true', dest='DUP_SYMBOLCHECK', default=False)
|
---|
146 |
|
---|
147 | gr.add_option('--why-needed',
|
---|
148 | help=("TARGET:DEPENDENCY check why TARGET needs DEPENDENCY"),
|
---|
149 | action='store', type='str', dest='WHYNEEDED', default=None)
|
---|
150 |
|
---|
151 | gr.add_option('--show-duplicates',
|
---|
152 | help=("Show objects which are included in multiple binaries or libraries"),
|
---|
153 | action='store_true', dest='SHOW_DUPLICATES', default=False)
|
---|
154 |
|
---|
155 | gr = opt.add_option_group('cross compilation options')
|
---|
156 |
|
---|
157 | gr.add_option('--cross-compile',
|
---|
158 | help=("configure for cross-compilation"),
|
---|
159 | action='store_true', dest='CROSS_COMPILE', default=False)
|
---|
160 | gr.add_option('--cross-execute',
|
---|
161 | help=("command prefix to use for cross-execution in configure"),
|
---|
162 | action='store', dest='CROSS_EXECUTE', default='')
|
---|
163 | gr.add_option('--cross-answers',
|
---|
164 | help=("answers to cross-compilation configuration (auto modified)"),
|
---|
165 | action='store', dest='CROSS_ANSWERS', default='')
|
---|
166 | gr.add_option('--hostcc',
|
---|
167 | help=("set host compiler when cross compiling"),
|
---|
168 | action='store', dest='HOSTCC', default=False)
|
---|
169 |
|
---|
170 | # we use SUPPRESS_HELP for these, as they are ignored, and are there only
|
---|
171 | # to allow existing RPM spec files to work
|
---|
172 | opt.add_option('--build',
|
---|
173 | help=SUPPRESS_HELP,
|
---|
174 | action='store', dest='AUTOCONF_BUILD', default='')
|
---|
175 | opt.add_option('--host',
|
---|
176 | help=SUPPRESS_HELP,
|
---|
177 | action='store', dest='AUTOCONF_HOST', default='')
|
---|
178 | opt.add_option('--target',
|
---|
179 | help=SUPPRESS_HELP,
|
---|
180 | action='store', dest='AUTOCONF_TARGET', default='')
|
---|
181 | opt.add_option('--program-prefix',
|
---|
182 | help=SUPPRESS_HELP,
|
---|
183 | action='store', dest='AUTOCONF_PROGRAM_PREFIX', default='')
|
---|
184 | opt.add_option('--disable-dependency-tracking',
|
---|
185 | help=SUPPRESS_HELP,
|
---|
186 | action='store_true', dest='AUTOCONF_DISABLE_DEPENDENCY_TRACKING', default=False)
|
---|
187 | opt.add_option('--disable-silent-rules',
|
---|
188 | help=SUPPRESS_HELP,
|
---|
189 | action='store_true', dest='AUTOCONF_DISABLE_SILENT_RULES', default=False)
|
---|
190 |
|
---|
191 | gr = opt.option_group('dist options')
|
---|
192 | gr.add_option('--sign-release',
|
---|
193 | help='sign the release tarball created by waf dist',
|
---|
194 | action='store_true', dest='SIGN_RELEASE')
|
---|
195 | gr.add_option('--tag',
|
---|
196 | help='tag release in git at the same time',
|
---|
197 | type='string', action='store', dest='TAG_RELEASE')
|
---|
198 |
|
---|
199 | opt.add_option('--extra-python', type=str,
|
---|
200 | help=("build selected libraries for the specified "
|
---|
201 | "additional version of Python "
|
---|
202 | "(example: --extra-python=/usr/bin/python3)"),
|
---|
203 | metavar="PYTHON", dest='EXTRA_PYTHON', default=None)
|
---|
204 |
|
---|
205 |
|
---|
206 | @Utils.run_once
|
---|
207 | def configure(conf):
|
---|
208 | conf.env.hlist = []
|
---|
209 | conf.env.srcdir = conf.srcdir
|
---|
210 |
|
---|
211 | if Options.options.timestamp_dependencies:
|
---|
212 | conf.ENABLE_TIMESTAMP_DEPENDENCIES()
|
---|
213 |
|
---|
214 | conf.SETUP_CONFIGURE_CACHE(Options.options.enable_configure_cache)
|
---|
215 |
|
---|
216 | # load our local waf extensions
|
---|
217 | conf.check_tool('gnu_dirs')
|
---|
218 | conf.check_tool('wafsamba')
|
---|
219 | conf.check_tool('print_commands')
|
---|
220 |
|
---|
221 | conf.CHECK_CC_ENV()
|
---|
222 |
|
---|
223 | conf.check_tool('compiler_cc')
|
---|
224 |
|
---|
225 | conf.CHECK_STANDARD_LIBPATH()
|
---|
226 |
|
---|
227 | # we need git for 'waf dist'
|
---|
228 | conf.find_program('git', var='GIT')
|
---|
229 |
|
---|
230 | # older gcc versions (< 4.4) does not work with gccdeps, so we have to see if the .d file is generated
|
---|
231 | if Options.options.enable_gccdeps:
|
---|
232 | # stale file removal - the configuration may pick up the old .pyc file
|
---|
233 | p = os.path.join(conf.srcdir, 'buildtools/wafsamba/gccdeps.pyc')
|
---|
234 | if os.path.exists(p):
|
---|
235 | os.remove(p)
|
---|
236 |
|
---|
237 | from TaskGen import feature, after
|
---|
238 | @feature('testd')
|
---|
239 | @after('apply_core')
|
---|
240 | def check_d(self):
|
---|
241 | tsk = self.compiled_tasks[0]
|
---|
242 | tsk.outputs.append(tsk.outputs[0].change_ext('.d'))
|
---|
243 |
|
---|
244 | import Task
|
---|
245 | cc = Task.TaskBase.classes['cc']
|
---|
246 | oldmeth = cc.run
|
---|
247 |
|
---|
248 | cc.run = Task.compile_fun_noshell('cc', '${CC} ${CCFLAGS} ${CPPFLAGS} ${_CCINCFLAGS} ${_CCDEFFLAGS} ${CC_SRC_F}${SRC} ${CC_TGT_F}${TGT[0].abspath(env)}')[0]
|
---|
249 | try:
|
---|
250 | try:
|
---|
251 | conf.check(features='c testd', fragment='int main() {return 0;}\n', ccflags=['-MD'], mandatory=True, msg='Check for -MD')
|
---|
252 | except:
|
---|
253 | pass
|
---|
254 | else:
|
---|
255 | conf.check_tool('gccdeps', tooldir=conf.srcdir + "/buildtools/wafsamba")
|
---|
256 | finally:
|
---|
257 | cc.run = oldmeth
|
---|
258 |
|
---|
259 | # make the install paths available in environment
|
---|
260 | conf.env.LIBDIR = Options.options.LIBDIR or '${PREFIX}/lib'
|
---|
261 | conf.env.BINDIR = Options.options.BINDIR or '${PREFIX}/bin'
|
---|
262 | conf.env.SBINDIR = Options.options.SBINDIR or '${PREFIX}/sbin'
|
---|
263 | conf.env.MODULESDIR = Options.options.MODULESDIR
|
---|
264 | conf.env.PRIVATELIBDIR = Options.options.PRIVATELIBDIR
|
---|
265 | conf.env.BUNDLED_LIBS = Options.options.BUNDLED_LIBS.split(',')
|
---|
266 | conf.env.PRIVATE_LIBS = Options.options.PRIVATE_LIBS.split(',')
|
---|
267 | conf.env.BUILTIN_LIBRARIES = Options.options.BUILTIN_LIBRARIES.split(',')
|
---|
268 | conf.env.NONSHARED_BINARIES = Options.options.NONSHARED_BINARIES.split(',')
|
---|
269 |
|
---|
270 | conf.env.PRIVATE_EXTENSION = Options.options.PRIVATE_EXTENSION
|
---|
271 | conf.env.PRIVATE_EXTENSION_EXCEPTION = Options.options.PRIVATE_EXTENSION_EXCEPTION.split(',')
|
---|
272 |
|
---|
273 | conf.env.CROSS_COMPILE = Options.options.CROSS_COMPILE
|
---|
274 | conf.env.CROSS_EXECUTE = Options.options.CROSS_EXECUTE
|
---|
275 | conf.env.CROSS_ANSWERS = Options.options.CROSS_ANSWERS
|
---|
276 | conf.env.HOSTCC = Options.options.HOSTCC
|
---|
277 |
|
---|
278 | conf.env.AUTOCONF_BUILD = Options.options.AUTOCONF_BUILD
|
---|
279 | conf.env.AUTOCONF_HOST = Options.options.AUTOCONF_HOST
|
---|
280 | conf.env.AUTOCONF_PROGRAM_PREFIX = Options.options.AUTOCONF_PROGRAM_PREFIX
|
---|
281 |
|
---|
282 | conf.env.EXTRA_PYTHON = Options.options.EXTRA_PYTHON
|
---|
283 |
|
---|
284 | if (conf.env.AUTOCONF_HOST and
|
---|
285 | conf.env.AUTOCONF_BUILD and
|
---|
286 | conf.env.AUTOCONF_BUILD != conf.env.AUTOCONF_HOST):
|
---|
287 | Logs.error('ERROR: Mismatch between --build and --host. Please use --cross-compile instead')
|
---|
288 | sys.exit(1)
|
---|
289 | if conf.env.AUTOCONF_PROGRAM_PREFIX:
|
---|
290 | Logs.error('ERROR: --program-prefix not supported')
|
---|
291 | sys.exit(1)
|
---|
292 |
|
---|
293 | # enable ABI checking for developers
|
---|
294 | conf.env.ABI_CHECK = Options.options.ABI_CHECK or Options.options.developer
|
---|
295 | if Options.options.ABI_CHECK_DISABLE:
|
---|
296 | conf.env.ABI_CHECK = False
|
---|
297 | try:
|
---|
298 | conf.find_program('gdb', mandatory=True)
|
---|
299 | except:
|
---|
300 | conf.env.ABI_CHECK = False
|
---|
301 |
|
---|
302 | conf.env.GIT_LOCAL_CHANGES = Options.options.GIT_LOCAL_CHANGES
|
---|
303 |
|
---|
304 | conf.CHECK_COMMAND(['uname', '-a'],
|
---|
305 | msg='Checking build system',
|
---|
306 | define='BUILD_SYSTEM',
|
---|
307 | on_target=False)
|
---|
308 | conf.CHECK_UNAME()
|
---|
309 |
|
---|
310 | # see if we can compile and run a simple C program
|
---|
311 | conf.CHECK_CODE('printf("hello world")',
|
---|
312 | define='HAVE_SIMPLE_C_PROG',
|
---|
313 | mandatory=True,
|
---|
314 | execute=True,
|
---|
315 | headers='stdio.h',
|
---|
316 | msg='Checking simple C program')
|
---|
317 |
|
---|
318 | # Try to find the right extra flags for -Werror behaviour
|
---|
319 | for f in ["-Werror", # GCC
|
---|
320 | "-errwarn=%all", # Sun Studio
|
---|
321 | "-qhalt=w", # IBM xlc
|
---|
322 | "-w2", # Tru64
|
---|
323 | ]:
|
---|
324 | if conf.CHECK_CFLAGS([f], '''
|
---|
325 | '''):
|
---|
326 | if not 'WERROR_CFLAGS' in conf.env:
|
---|
327 | conf.env['WERROR_CFLAGS'] = []
|
---|
328 | conf.env['WERROR_CFLAGS'].extend([f])
|
---|
329 | break
|
---|
330 |
|
---|
331 | # check which compiler/linker flags are needed for rpath support
|
---|
332 | if not conf.CHECK_LDFLAGS(['-Wl,-rpath,.']) and conf.CHECK_LDFLAGS(['-Wl,-R,.']):
|
---|
333 | conf.env['RPATH_ST'] = '-Wl,-R,%s'
|
---|
334 |
|
---|
335 | # check for rpath
|
---|
336 | if conf.CHECK_LIBRARY_SUPPORT(rpath=True):
|
---|
337 | support_rpath = True
|
---|
338 | conf.env.RPATH_ON_BUILD = not Options.options.disable_rpath_build
|
---|
339 | conf.env.RPATH_ON_INSTALL = (conf.env.RPATH_ON_BUILD and
|
---|
340 | not Options.options.disable_rpath_install)
|
---|
341 | if not conf.env.PRIVATELIBDIR:
|
---|
342 | conf.env.PRIVATELIBDIR = '%s/%s' % (conf.env.LIBDIR, Utils.g_module.APPNAME)
|
---|
343 | conf.env.RPATH_ON_INSTALL_PRIVATE = (
|
---|
344 | not Options.options.disable_rpath_private_install)
|
---|
345 | else:
|
---|
346 | support_rpath = False
|
---|
347 | conf.env.RPATH_ON_INSTALL = False
|
---|
348 | conf.env.RPATH_ON_BUILD = False
|
---|
349 | conf.env.RPATH_ON_INSTALL_PRIVATE = False
|
---|
350 | if not conf.env.PRIVATELIBDIR:
|
---|
351 | # rpath is not possible so there is no sense in having a
|
---|
352 | # private library directory by default.
|
---|
353 | # the user can of course always override it.
|
---|
354 | conf.env.PRIVATELIBDIR = conf.env.LIBDIR
|
---|
355 |
|
---|
356 | if (not Options.options.disable_symbol_versions and
|
---|
357 | conf.CHECK_LIBRARY_SUPPORT(rpath=support_rpath,
|
---|
358 | version_script=True,
|
---|
359 | msg='-Wl,--version-script support')):
|
---|
360 | conf.env.HAVE_LD_VERSION_SCRIPT = True
|
---|
361 | else:
|
---|
362 | conf.env.HAVE_LD_VERSION_SCRIPT = False
|
---|
363 |
|
---|
364 | if conf.CHECK_CFLAGS(['-fvisibility=hidden'] + conf.env.WERROR_CFLAGS):
|
---|
365 | conf.env.VISIBILITY_CFLAGS = '-fvisibility=hidden'
|
---|
366 | conf.CHECK_CODE('''int main(void) { return 0; }
|
---|
367 | __attribute__((visibility("default"))) void vis_foo2(void) {}''',
|
---|
368 | cflags=conf.env.VISIBILITY_CFLAGS,
|
---|
369 | define='HAVE_VISIBILITY_ATTR', addmain=False)
|
---|
370 |
|
---|
371 | # check HAVE_CONSTRUCTOR_ATTRIBUTE
|
---|
372 | conf.CHECK_CODE('''
|
---|
373 | void test_constructor_attribute(void) __attribute__ ((constructor));
|
---|
374 |
|
---|
375 | void test_constructor_attribute(void)
|
---|
376 | {
|
---|
377 | return;
|
---|
378 | }
|
---|
379 |
|
---|
380 | int main(void) {
|
---|
381 | return 0;
|
---|
382 | }
|
---|
383 | ''',
|
---|
384 | 'HAVE_CONSTRUCTOR_ATTRIBUTE',
|
---|
385 | addmain=False,
|
---|
386 | msg='Checking for library constructor support')
|
---|
387 |
|
---|
388 | # check HAVE_DESTRUCTOR_ATTRIBUTE
|
---|
389 | conf.CHECK_CODE('''
|
---|
390 | void test_destructor_attribute(void) __attribute__ ((destructor));
|
---|
391 |
|
---|
392 | void test_destructor_attribute(void)
|
---|
393 | {
|
---|
394 | return;
|
---|
395 | }
|
---|
396 |
|
---|
397 | int main(void) {
|
---|
398 | return 0;
|
---|
399 | }
|
---|
400 | ''',
|
---|
401 | 'HAVE_DESTRUCTOR_ATTRIBUTE',
|
---|
402 | addmain=False,
|
---|
403 | msg='Checking for library destructor support')
|
---|
404 |
|
---|
405 | conf.CHECK_CODE('''
|
---|
406 | void test_attribute(void) __attribute__ (());
|
---|
407 |
|
---|
408 | void test_attribute(void)
|
---|
409 | {
|
---|
410 | return;
|
---|
411 | }
|
---|
412 |
|
---|
413 | int main(void) {
|
---|
414 | return 0;
|
---|
415 | }
|
---|
416 | ''',
|
---|
417 | 'HAVE___ATTRIBUTE__',
|
---|
418 | addmain=False,
|
---|
419 | msg='Checking for __attribute__')
|
---|
420 |
|
---|
421 | if sys.platform.startswith('aix'):
|
---|
422 | conf.DEFINE('_ALL_SOURCE', 1, add_to_cflags=True)
|
---|
423 | # Might not be needed if ALL_SOURCE is defined
|
---|
424 | # conf.DEFINE('_XOPEN_SOURCE', 600, add_to_cflags=True)
|
---|
425 |
|
---|
426 | # we should use the PIC options in waf instead
|
---|
427 | # Some compilo didn't support -fPIC but just print a warning
|
---|
428 | if conf.env['COMPILER_CC'] == "suncc":
|
---|
429 | conf.ADD_CFLAGS('-KPIC', testflags=True)
|
---|
430 | # we really want define here as we need to have this
|
---|
431 | # define even during the tests otherwise detection of
|
---|
432 | # boolean is broken
|
---|
433 | conf.DEFINE('_STDC_C99', 1, add_to_cflags=True)
|
---|
434 | conf.DEFINE('_XPG6', 1, add_to_cflags=True)
|
---|
435 | else:
|
---|
436 | conf.ADD_CFLAGS('-fPIC', testflags=True)
|
---|
437 |
|
---|
438 | # On Solaris 8 with suncc (at least) the flags for the linker to define the name of the
|
---|
439 | # library are not always working (if the command line is very very long and with a lot
|
---|
440 | # files)
|
---|
441 |
|
---|
442 | if conf.env['COMPILER_CC'] == "suncc":
|
---|
443 | save = conf.env['SONAME_ST']
|
---|
444 | conf.env['SONAME_ST'] = '-Wl,-h,%s'
|
---|
445 | if not conf.CHECK_SHLIB_INTRASINC_NAME_FLAGS("Checking if flags %s are ok" % conf.env['SONAME_ST']):
|
---|
446 | conf.env['SONAME_ST'] = save
|
---|
447 |
|
---|
448 | conf.CHECK_INLINE()
|
---|
449 |
|
---|
450 | # check for pkgconfig
|
---|
451 | conf.CHECK_CFG(atleast_pkgconfig_version='0.0.0')
|
---|
452 |
|
---|
453 | conf.DEFINE('_GNU_SOURCE', 1, add_to_cflags=True)
|
---|
454 | conf.DEFINE('_XOPEN_SOURCE_EXTENDED', 1, add_to_cflags=True)
|
---|
455 |
|
---|
456 | # on Tru64 certain features are only available with _OSF_SOURCE set to 1
|
---|
457 | # and _XOPEN_SOURCE set to 600
|
---|
458 | if conf.env['SYSTEM_UNAME_SYSNAME'] == 'OSF1':
|
---|
459 | conf.DEFINE('_OSF_SOURCE', 1, add_to_cflags=True)
|
---|
460 | conf.DEFINE('_XOPEN_SOURCE', 600, add_to_cflags=True)
|
---|
461 |
|
---|
462 | # SCM_RIGHTS is only avail if _XOPEN_SOURCE iÑ defined on IRIX
|
---|
463 | if conf.env['SYSTEM_UNAME_SYSNAME'] == 'IRIX':
|
---|
464 | conf.DEFINE('_XOPEN_SOURCE', 600, add_to_cflags=True)
|
---|
465 | conf.DEFINE('_BSD_TYPES', 1, add_to_cflags=True)
|
---|
466 |
|
---|
467 | # Try to find the right extra flags for C99 initialisers
|
---|
468 | for f in ["", "-AC99", "-qlanglvl=extc99", "-qlanglvl=stdc99", "-c99"]:
|
---|
469 | if conf.CHECK_CFLAGS([f], '''
|
---|
470 | struct foo {int x;char y;};
|
---|
471 | struct foo bar = { .y = 'X', .x = 1 };
|
---|
472 | '''):
|
---|
473 | if f != "":
|
---|
474 | conf.ADD_CFLAGS(f)
|
---|
475 | break
|
---|
476 |
|
---|
477 | # get the base headers we'll use for the rest of the tests
|
---|
478 | conf.CHECK_HEADERS('stdio.h sys/types.h sys/stat.h stdlib.h stddef.h memory.h string.h',
|
---|
479 | add_headers=True)
|
---|
480 | conf.CHECK_HEADERS('strings.h inttypes.h stdint.h unistd.h minix/config.h', add_headers=True)
|
---|
481 | conf.CHECK_HEADERS('ctype.h', add_headers=True)
|
---|
482 |
|
---|
483 | if sys.platform != 'darwin':
|
---|
484 | conf.CHECK_HEADERS('standards.h', add_headers=True)
|
---|
485 |
|
---|
486 | conf.CHECK_HEADERS('stdbool.h stdint.h stdarg.h vararg.h', add_headers=True)
|
---|
487 | conf.CHECK_HEADERS('limits.h assert.h')
|
---|
488 |
|
---|
489 | # see if we need special largefile flags
|
---|
490 | if not conf.CHECK_LARGEFILE():
|
---|
491 | raise Utils.WafError('Samba requires large file support support, but not available on this platform: sizeof(off_t) < 8')
|
---|
492 |
|
---|
493 | if 'HAVE_STDDEF_H' in conf.env and 'HAVE_STDLIB_H' in conf.env:
|
---|
494 | conf.DEFINE('STDC_HEADERS', 1)
|
---|
495 |
|
---|
496 | conf.CHECK_HEADERS('sys/time.h time.h', together=True)
|
---|
497 |
|
---|
498 | if 'HAVE_SYS_TIME_H' in conf.env and 'HAVE_TIME_H' in conf.env:
|
---|
499 | conf.DEFINE('TIME_WITH_SYS_TIME', 1)
|
---|
500 |
|
---|
501 | # cope with different extensions for libraries
|
---|
502 | (root, ext) = os.path.splitext(conf.env.shlib_PATTERN)
|
---|
503 | if ext[0] == '.':
|
---|
504 | conf.define('SHLIBEXT', ext[1:], quote=True)
|
---|
505 | else:
|
---|
506 | conf.define('SHLIBEXT', "so", quote=True)
|
---|
507 |
|
---|
508 | # First try a header check for cross-compile friendlyness
|
---|
509 | conf.CHECK_CODE(code = """#ifdef __BYTE_ORDER
|
---|
510 | #define B __BYTE_ORDER
|
---|
511 | #elif defined(BYTE_ORDER)
|
---|
512 | #define B BYTE_ORDER
|
---|
513 | #endif
|
---|
514 |
|
---|
515 | #ifdef __LITTLE_ENDIAN
|
---|
516 | #define LITTLE __LITTLE_ENDIAN
|
---|
517 | #elif defined(LITTLE_ENDIAN)
|
---|
518 | #define LITTLE LITTLE_ENDIAN
|
---|
519 | #endif
|
---|
520 |
|
---|
521 | #if !defined(LITTLE) || !defined(B) || LITTLE != B
|
---|
522 | #error Not little endian.
|
---|
523 | #endif
|
---|
524 | int main(void) { return 0; }""",
|
---|
525 | addmain=False,
|
---|
526 | headers="endian.h sys/endian.h",
|
---|
527 | define="HAVE_LITTLE_ENDIAN")
|
---|
528 | conf.CHECK_CODE(code = """#ifdef __BYTE_ORDER
|
---|
529 | #define B __BYTE_ORDER
|
---|
530 | #elif defined(BYTE_ORDER)
|
---|
531 | #define B BYTE_ORDER
|
---|
532 | #endif
|
---|
533 |
|
---|
534 | #ifdef __BIG_ENDIAN
|
---|
535 | #define BIG __BIG_ENDIAN
|
---|
536 | #elif defined(BIG_ENDIAN)
|
---|
537 | #define BIG BIG_ENDIAN
|
---|
538 | #endif
|
---|
539 |
|
---|
540 | #if !defined(BIG) || !defined(B) || BIG != B
|
---|
541 | #error Not big endian.
|
---|
542 | #endif
|
---|
543 | int main(void) { return 0; }""",
|
---|
544 | addmain=False,
|
---|
545 | headers="endian.h sys/endian.h",
|
---|
546 | define="HAVE_BIG_ENDIAN")
|
---|
547 |
|
---|
548 | if not conf.CONFIG_SET("HAVE_BIG_ENDIAN") and not conf.CONFIG_SET("HAVE_LITTLE_ENDIAN"):
|
---|
549 | # That didn't work! Do runtime test.
|
---|
550 | conf.CHECK_CODE("""union { int i; char c[sizeof(int)]; } u;
|
---|
551 | u.i = 0x01020304;
|
---|
552 | return u.c[0] == 0x04 && u.c[1] == 0x03 && u.c[2] == 0x02 && u.c[3] == 0x01 ? 0 : 1;""",
|
---|
553 | addmain=True, execute=True,
|
---|
554 | define='HAVE_LITTLE_ENDIAN',
|
---|
555 | msg="Checking for HAVE_LITTLE_ENDIAN - runtime")
|
---|
556 | conf.CHECK_CODE("""union { int i; char c[sizeof(int)]; } u;
|
---|
557 | u.i = 0x01020304;
|
---|
558 | return u.c[0] == 0x01 && u.c[1] == 0x02 && u.c[2] == 0x03 && u.c[3] == 0x04 ? 0 : 1;""",
|
---|
559 | addmain=True, execute=True,
|
---|
560 | define='HAVE_BIG_ENDIAN',
|
---|
561 | msg="Checking for HAVE_BIG_ENDIAN - runtime")
|
---|
562 |
|
---|
563 | # Extra sanity check.
|
---|
564 | if conf.CONFIG_SET("HAVE_BIG_ENDIAN") == conf.CONFIG_SET("HAVE_LITTLE_ENDIAN"):
|
---|
565 | Logs.error("Failed endian determination. The PDP-11 is back?")
|
---|
566 | sys.exit(1)
|
---|
567 | else:
|
---|
568 | if conf.CONFIG_SET("HAVE_BIG_ENDIAN"):
|
---|
569 | conf.DEFINE('WORDS_BIGENDIAN', 1)
|
---|
570 |
|
---|
571 | # check if signal() takes a void function
|
---|
572 | if conf.CHECK_CODE('return *(signal (0, 0)) (0) == 1',
|
---|
573 | define='RETSIGTYPE_INT',
|
---|
574 | execute=False,
|
---|
575 | headers='signal.h',
|
---|
576 | msg='Checking if signal handlers return int'):
|
---|
577 | conf.DEFINE('RETSIGTYPE', 'int')
|
---|
578 | else:
|
---|
579 | conf.DEFINE('RETSIGTYPE', 'void')
|
---|
580 |
|
---|
581 | conf.CHECK_VARIABLE('__FUNCTION__', define='HAVE_FUNCTION_MACRO')
|
---|
582 |
|
---|
583 | conf.CHECK_CODE('va_list ap1,ap2; va_copy(ap1,ap2)',
|
---|
584 | define="HAVE_VA_COPY",
|
---|
585 | msg="Checking for va_copy")
|
---|
586 |
|
---|
587 | conf.CHECK_CODE('''
|
---|
588 | #define eprintf(...) fprintf(stderr, __VA_ARGS__)
|
---|
589 | eprintf("bla", "bar")
|
---|
590 | ''', define='HAVE__VA_ARGS__MACRO')
|
---|
591 |
|
---|
592 | conf.SAMBA_BUILD_ENV()
|
---|
593 |
|
---|
594 |
|
---|
595 | def build(bld):
|
---|
596 | # give a more useful message if the source directory has moved
|
---|
597 | relpath = os_path_relpath(bld.curdir, bld.srcnode.abspath())
|
---|
598 | if relpath.find('../') != -1:
|
---|
599 | Logs.error('bld.curdir %s is not a child of %s' % (bld.curdir, bld.srcnode.abspath()))
|
---|
600 | raise Utils.WafError('''The top source directory has moved. Please run distclean and reconfigure''')
|
---|
601 |
|
---|
602 | bld.CHECK_MAKEFLAGS()
|
---|
603 | bld.SETUP_BUILD_GROUPS()
|
---|
604 | bld.ENFORCE_GROUP_ORDERING()
|
---|
605 | bld.CHECK_PROJECT_RULES()
|
---|