3 # this is a base set of waf rules that everything else pulls in first
5 import sys
, wafsamba
, Configure
, Logs
6 import Options
, os
, preproc
7 from samba_utils
import *
8 from optparse
import SUPPRESS_HELP
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
20 opt
.tool_options('compiler_cc')
22 opt
.tool_options('gnu_dirs')
24 gr
= opt
.option_group('library handling options')
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
='')
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
='')
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
)
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
)
44 builtin_defauilt
= 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_defauilt
),
47 action
="store", dest
='BUILTIN_LIBRARIES', default
=builtin_defauilt
)
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
='')
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)
69 opt
.add_option('--with-modulesdir',
70 help=("modules directory [PREFIX/modules]"),
71 action
="store", dest
='MODULESDIR', default
='${PREFIX}/modules')
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)
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('--with-gettext',
82 help='additional directory to search for gettext',
83 action
='store', dest
='gettext_location', default
='None')
84 opt
.add_option('--without-gettext',
85 help=("Disable use of gettext"),
86 action
="store_true", dest
='disable_gettext', default
=False)
88 gr
= opt
.option_group('developer options')
91 help='enable configure cacheing',
92 action
='store_true', dest
='enable_configure_cache')
93 gr
.add_option('--enable-auto-reconfigure',
94 help='enable automatic reconfigure on build',
95 action
='store_true', dest
='enable_auto_reconfigure')
96 gr
.add_option('--enable-debug',
97 help=("Turn on debugging symbols"),
98 action
="store_true", dest
='debug', default
=False)
99 gr
.add_option('--enable-developer',
100 help=("Turn on developer warnings and debugging"),
101 action
="store_true", dest
='developer', default
=False)
102 gr
.add_option('--picky-developer',
103 help=("Treat all warnings as errors (enable -Werror)"),
104 action
="store_true", dest
='picky_developer', default
=False)
105 gr
.add_option('--fatal-errors',
106 help=("Stop compilation on first error (enable -Wfatal-errors)"),
107 action
="store_true", dest
='fatal_errors', default
=False)
108 gr
.add_option('--enable-gccdeps',
109 help=("Enable use of gcc -MD dependency module"),
110 action
="store_true", dest
='enable_gccdeps', default
=True)
111 gr
.add_option('--timestamp-dependencies',
112 help=("use file timestamps instead of content for build dependencies (BROKEN)"),
113 action
="store_true", dest
='timestamp_dependencies', default
=False)
114 gr
.add_option('--pedantic',
115 help=("Enable even more compiler warnings"),
116 action
='store_true', dest
='pedantic', default
=False)
117 gr
.add_option('--git-local-changes',
118 help=("mark version with + if local git changes"),
119 action
='store_true', dest
='GIT_LOCAL_CHANGES', default
=False)
121 gr
.add_option('--abi-check',
122 help=("Check ABI signatures for libraries"),
123 action
='store_true', dest
='ABI_CHECK', default
=False)
124 gr
.add_option('--abi-check-disable',
125 help=("Disable ABI checking (used with --enable-developer)"),
126 action
='store_true', dest
='ABI_CHECK_DISABLE', default
=False)
127 gr
.add_option('--abi-update',
128 help=("Update ABI signature files for libraries"),
129 action
='store_true', dest
='ABI_UPDATE', default
=False)
131 gr
.add_option('--show-deps',
132 help=("Show dependency tree for the given target"),
133 dest
='SHOWDEPS', default
='')
135 gr
.add_option('--symbol-check',
136 help=("check symbols in object files against project rules"),
137 action
='store_true', dest
='SYMBOLCHECK', default
=False)
139 gr
.add_option('--dup-symbol-check',
140 help=("check for duplicate symbols in object files and system libs (must be configured with --enable-developer)"),
141 action
='store_true', dest
='DUP_SYMBOLCHECK', default
=False)
143 gr
.add_option('--why-needed',
144 help=("TARGET:DEPENDENCY check why TARGET needs DEPENDENCY"),
145 action
='store', type='str', dest
='WHYNEEDED', default
=None)
147 gr
.add_option('--show-duplicates',
148 help=("Show objects which are included in multiple binaries or libraries"),
149 action
='store_true', dest
='SHOW_DUPLICATES', default
=False)
151 gr
= opt
.add_option_group('cross compilation options')
153 gr
.add_option('--cross-compile',
154 help=("configure for cross-compilation"),
155 action
='store_true', dest
='CROSS_COMPILE', default
=False)
156 gr
.add_option('--cross-execute',
157 help=("command prefix to use for cross-execution in configure"),
158 action
='store', dest
='CROSS_EXECUTE', default
='')
159 gr
.add_option('--cross-answers',
160 help=("answers to cross-compilation configuration (auto modified)"),
161 action
='store', dest
='CROSS_ANSWERS', default
='')
162 gr
.add_option('--hostcc',
163 help=("set host compiler when cross compiling"),
164 action
='store', dest
='HOSTCC', default
=False)
166 # we use SUPPRESS_HELP for these, as they are ignored, and are there only
167 # to allow existing RPM spec files to work
168 opt
.add_option('--build',
170 action
='store', dest
='AUTOCONF_BUILD', default
='')
171 opt
.add_option('--host',
173 action
='store', dest
='AUTOCONF_HOST', default
='')
174 opt
.add_option('--target',
176 action
='store', dest
='AUTOCONF_TARGET', default
='')
177 opt
.add_option('--program-prefix',
179 action
='store', dest
='AUTOCONF_PROGRAM_PREFIX', default
='')
180 opt
.add_option('--disable-dependency-tracking',
182 action
='store_true', dest
='AUTOCONF_DISABLE_DEPENDENCY_TRACKING', default
=False)
183 opt
.add_option('--disable-silent-rules',
185 action
='store_true', dest
='AUTOCONF_DISABLE_SILENT_RULES', default
=False)
187 gr
= opt
.option_group('dist options')
188 gr
.add_option('--sign-release',
189 help='sign the release tarball created by waf dist',
190 action
='store_true', dest
='SIGN_RELEASE')
191 gr
.add_option('--tag',
192 help='tag release in git at the same time',
193 type='string', action
='store', dest
='TAG_RELEASE')
199 conf
.env
.srcdir
= conf
.srcdir
201 if Options
.options
.timestamp_dependencies
:
202 conf
.ENABLE_TIMESTAMP_DEPENDENCIES()
204 conf
.SETUP_CONFIGURE_CACHE(Options
.options
.enable_configure_cache
)
206 # load our local waf extensions
207 conf
.check_tool('gnu_dirs')
208 conf
.check_tool('wafsamba')
212 conf
.check_tool('compiler_cc')
214 # we need git for 'waf dist'
215 conf
.find_program('git', var
='GIT')
217 # older gcc versions (< 4.4) does not work with gccdeps, so we have to see if the .d file is generated
218 if Options
.options
.enable_gccdeps
:
219 from TaskGen
import feature
, after
223 tsk
= self
.compiled_tasks
[0]
224 tsk
.outputs
.append(tsk
.outputs
[0].change_ext('.d'))
227 cc
= Task
.TaskBase
.classes
['cc']
230 cc
.run
= Task
.compile_fun_noshell('cc', '${CC} ${CCFLAGS} ${CPPFLAGS} ${_CCINCFLAGS} ${_CCDEFFLAGS} ${CC_SRC_F}${SRC} ${CC_TGT_F}${TGT[0].abspath(env)}')[0]
233 conf
.check(features
='cc testd', fragment
='int main() {return 0;}\n', ccflags
=['-MD'], mandatory
=True, msg
='Check for -MD')
237 conf
.check_tool('gccdeps', tooldir
=conf
.srcdir
+ "/buildtools/wafsamba")
241 # make the install paths available in environment
242 conf
.env
.LIBDIR
= Options
.options
.LIBDIR
or '${PREFIX}/lib'
243 conf
.env
.BINDIR
= Options
.options
.BINDIR
or '${PREFIX}/bin'
244 conf
.env
.SBINDIR
= Options
.options
.SBINDIR
or '${PREFIX}/sbin'
245 conf
.env
.MODULESDIR
= Options
.options
.MODULESDIR
246 conf
.env
.PRIVATELIBDIR
= Options
.options
.PRIVATELIBDIR
247 conf
.env
.BUNDLED_LIBS
= Options
.options
.BUNDLED_LIBS
.split(',')
248 conf
.env
.PRIVATE_LIBS
= Options
.options
.PRIVATE_LIBS
.split(',')
249 conf
.env
.BUILTIN_LIBRARIES
= Options
.options
.BUILTIN_LIBRARIES
.split(',')
250 conf
.env
.NONSHARED_BINARIES
= Options
.options
.NONSHARED_BINARIES
.split(',')
252 conf
.env
.PRIVATE_EXTENSION
= Options
.options
.PRIVATE_EXTENSION
253 conf
.env
.PRIVATE_EXTENSION_EXCEPTION
= Options
.options
.PRIVATE_EXTENSION_EXCEPTION
.split(',')
255 conf
.env
.CROSS_COMPILE
= Options
.options
.CROSS_COMPILE
256 conf
.env
.CROSS_EXECUTE
= Options
.options
.CROSS_EXECUTE
257 conf
.env
.CROSS_ANSWERS
= Options
.options
.CROSS_ANSWERS
258 conf
.env
.HOSTCC
= Options
.options
.HOSTCC
260 conf
.env
.AUTOCONF_BUILD
= Options
.options
.AUTOCONF_BUILD
261 conf
.env
.AUTOCONF_HOST
= Options
.options
.AUTOCONF_HOST
262 conf
.env
.AUTOCONF_PROGRAM_PREFIX
= Options
.options
.AUTOCONF_PROGRAM_PREFIX
264 if (conf
.env
.AUTOCONF_HOST
and
265 conf
.env
.AUTOCONF_BUILD
and
266 conf
.env
.AUTOCONF_BUILD
!= conf
.env
.AUTOCONF_HOST
):
267 Logs
.error('ERROR: Mismatch between --build and --host. Please use --cross-compile instead')
269 if conf
.env
.AUTOCONF_PROGRAM_PREFIX
:
270 Logs
.error('ERROR: --program-prefix not supported')
273 # enable ABI checking for developers
274 conf
.env
.ABI_CHECK
= Options
.options
.ABI_CHECK
or Options
.options
.developer
275 if Options
.options
.ABI_CHECK_DISABLE
:
276 conf
.env
.ABI_CHECK
= False
278 conf
.find_program('gdb', mandatory
=True)
280 conf
.env
.ABI_CHECK
= False
282 conf
.env
.GIT_LOCAL_CHANGES
= Options
.options
.GIT_LOCAL_CHANGES
284 conf
.CHECK_COMMAND(['uname', '-a'],
285 msg
='Checking build system',
286 define
='BUILD_SYSTEM',
290 # see if we can compile and run a simple C program
291 conf
.CHECK_CODE('printf("hello world")',
292 define
='HAVE_SIMPLE_C_PROG',
296 msg
='Checking simple C program')
299 if conf
.CHECK_LIBRARY_SUPPORT(rpath
=True):
301 conf
.env
.RPATH_ON_BUILD
= not Options
.options
.disable_rpath_build
302 conf
.env
.RPATH_ON_INSTALL
= (conf
.env
.RPATH_ON_BUILD
and
303 not Options
.options
.disable_rpath_install
)
304 if not conf
.env
.PRIVATELIBDIR
:
305 conf
.env
.PRIVATELIBDIR
= '%s/%s' % (conf
.env
.LIBDIR
, Utils
.g_module
.APPNAME
)
306 conf
.env
.RPATH_ON_INSTALL_PRIVATE
= (
307 not Options
.options
.disable_rpath_private_install
)
309 support_rpath
= False
310 conf
.env
.RPATH_ON_INSTALL
= False
311 conf
.env
.RPATH_ON_BUILD
= False
312 conf
.env
.RPATH_ON_INSTALL_PRIVATE
= False
313 if not conf
.env
.PRIVATELIBDIR
:
314 # rpath is not possible so there is no sense in having a
315 # private library directory by default.
316 # the user can of course always override it.
317 conf
.env
.PRIVATELIBDIR
= conf
.env
.LIBDIR
319 if (not Options
.options
.disable_symbol_versions
and
320 conf
.CHECK_LIBRARY_SUPPORT(rpath
=support_rpath
,
322 msg
='-Wl,--version-script support')):
323 conf
.env
.HAVE_LD_VERSION_SCRIPT
= True
325 conf
.env
.HAVE_LD_VERSION_SCRIPT
= False
327 if sys
.platform
.startswith('aix'):
328 conf
.DEFINE('_ALL_SOURCE', 1, add_to_cflags
=True)
329 # Might not be needed if ALL_SOURCE is defined
330 # conf.DEFINE('_XOPEN_SOURCE', 600, add_to_cflags=True)
332 # we should use the PIC options in waf instead
333 # Some compilo didn't support -fPIC but just print a warning
334 if conf
.env
['COMPILER_CC'] == "suncc":
335 conf
.ADD_CFLAGS('-KPIC', testflags
=True)
336 # we really want define here as we need to have this
337 # define even during the tests otherwise detection of
339 conf
.DEFINE('_STDC_C99', 1, add_to_cflags
=True)
340 conf
.DEFINE('_XPG6', 1, add_to_cflags
=True)
342 conf
.ADD_CFLAGS('-fPIC', testflags
=True)
344 # On Solaris 8 with suncc (at least) the flags for the linker to define the name of the
345 # library are not always working (if the command line is very very long and with a lot
348 if conf
.env
['COMPILER_CC'] == "suncc":
349 save
= conf
.env
['SONAME_ST']
350 conf
.env
['SONAME_ST'] = '-Wl,-h,%s'
351 if not conf
.CHECK_SHLIB_INTRASINC_NAME_FLAGS("Checking if flags %s are ok" % conf
.env
['SONAME_ST']):
352 conf
.env
['SONAME_ST'] = save
356 # check for pkgconfig
357 conf
.check_cfg(atleast_pkgconfig_version
='0.0.0')
359 conf
.DEFINE('_GNU_SOURCE', 1, add_to_cflags
=True)
360 conf
.DEFINE('_XOPEN_SOURCE_EXTENDED', 1, add_to_cflags
=True)
362 # get the base headers we'll use for the rest of the tests
363 conf
.CHECK_HEADERS('stdio.h sys/types.h sys/stat.h stdlib.h stddef.h memory.h string.h',
365 conf
.CHECK_HEADERS('strings.h inttypes.h stdint.h unistd.h minix/config.h', add_headers
=True)
366 conf
.CHECK_HEADERS('ctype.h', add_headers
=True)
368 if sys
.platform
!= 'darwin':
369 conf
.CHECK_HEADERS('standards.h', add_headers
=True)
371 conf
.CHECK_HEADERS('stdbool.h stdint.h stdarg.h vararg.h', add_headers
=True)
372 conf
.CHECK_HEADERS('limits.h assert.h')
374 # see if we need special largefile flags
375 if not conf
.CHECK_LARGEFILE():
376 raise Utils
.WafError('Samba requires large file support support, but not available on this platform: sizeof(off_t) < 8')
378 if 'HAVE_STDDEF_H' in conf
.env
and 'HAVE_STDLIB_H' in conf
.env
:
379 conf
.DEFINE('STDC_HEADERS', 1)
381 conf
.CHECK_HEADERS('sys/time.h time.h', together
=True)
383 if 'HAVE_SYS_TIME_H' in conf
.env
and 'HAVE_TIME_H' in conf
.env
:
384 conf
.DEFINE('TIME_WITH_SYS_TIME', 1)
386 # cope with different extensions for libraries
387 (root
, ext
) = os
.path
.splitext(conf
.env
.shlib_PATTERN
)
389 conf
.define('SHLIBEXT', ext
[1:], quote
=True)
391 conf
.define('SHLIBEXT', "so", quote
=True)
393 # First try a header check for cross-compile friendlyness
394 conf
.CHECK_CODE(code
= """#ifdef __BYTE_ORDER
395 #define B __BYTE_ORDER
396 #elif defined(BYTE_ORDER)
400 #ifdef __LITTLE_ENDIAN
401 #define LITTLE __LITTLE_ENDIAN
402 #elif defined(LITTLE_ENDIAN)
403 #define LITTLE LITTLE_ENDIAN
406 #if !defined(LITTLE) || !defined(B) || LITTLE != B
407 #error Not little endian.
409 int main(void) { return 0; }""",
411 headers
="endian.h sys/endian.h",
412 define
="HAVE_LITTLE_ENDIAN")
413 conf
.CHECK_CODE(code
= """#ifdef __BYTE_ORDER
414 #define B __BYTE_ORDER
415 #elif defined(BYTE_ORDER)
420 #define BIG __BIG_ENDIAN
421 #elif defined(BIG_ENDIAN)
422 #define BIG BIG_ENDIAN
425 #if !defined(BIG) || !defined(B) || BIG != B
426 #error Not big endian.
428 int main(void) { return 0; }""",
430 headers
="endian.h sys/endian.h",
431 define
="HAVE_BIG_ENDIAN")
433 if not conf
.CONFIG_SET("HAVE_BIG_ENDIAN") and not conf
.CONFIG_SET("HAVE_LITTLE_ENDIAN"):
434 # That didn't work! Do runtime test.
435 conf
.CHECK_CODE("""union { int i; char c[sizeof(int)]; } u;
437 return u.c[0] == 0x04 && u.c[1] == 0x03 && u.c[2] == 0x02 && u.c[3] == 0x01 ? 0 : 1;""",
438 addmain
=True, execute
=True,
439 define
='HAVE_LITTLE_ENDIAN',
440 msg
="Checking for HAVE_LITTLE_ENDIAN - runtime")
441 conf
.CHECK_CODE("""union { int i; char c[sizeof(int)]; } u;
443 return u.c[0] == 0x01 && u.c[1] == 0x02 && u.c[2] == 0x03 && u.c[3] == 0x04 ? 0 : 1;""",
444 addmain
=True, execute
=True,
445 define
='HAVE_BIG_ENDIAN',
446 msg
="Checking for HAVE_BIG_ENDIAN - runtime")
448 # Extra sanity check.
449 if conf
.CONFIG_SET("HAVE_BIG_ENDIAN") == conf
.CONFIG_SET("HAVE_LITTLE_ENDIAN"):
450 Logs
.error("Failed endian determination. The PDP-11 is back?")
453 if conf
.CONFIG_SET("HAVE_BIG_ENDIAN"):
454 conf
.DEFINE('WORDS_BIGENDIAN', 1)
456 # check if signal() takes a void function
457 if conf
.CHECK_CODE('return *(signal (0, 0)) (0) == 1',
458 define
='RETSIGTYPE_INT',
461 msg
='Checking if signal handlers return int'):
462 conf
.DEFINE('RETSIGTYPE', 'int')
464 conf
.DEFINE('RETSIGTYPE', 'void')
466 conf
.CHECK_VARIABLE('__FUNCTION__', define
='HAVE_FUNCTION_MACRO')
468 conf
.CHECK_CODE('va_list ap1,ap2; va_copy(ap1,ap2)',
469 define
="HAVE_VA_COPY",
470 msg
="Checking for va_copy")
473 #define eprintf(...) fprintf(stderr, __VA_ARGS__)
474 eprintf("bla", "bar")
475 ''', define
='HAVE__VA_ARGS__MACRO')
477 conf
.SAMBA_BUILD_ENV()
481 # give a more useful message if the source directory has moved
482 relpath
= os_path_relpath(bld
.curdir
, bld
.srcnode
.abspath())
483 if relpath
.find('../') != -1:
484 Logs
.error('bld.curdir %s is not a child of %s' % (bld
.curdir
, bld
.srcnode
.abspath()))
485 raise Utils
.WafError('''The top source directory has moved. Please run distclean and reconfigure''')
487 bld
.CHECK_MAKEFLAGS()
488 bld
.SETUP_BUILD_GROUPS()
489 bld
.ENFORCE_GROUP_ORDERING()
490 bld
.CHECK_PROJECT_RULES()