3 # this is a base set of waf rules that everything else pulls in first
6 import Options, os, preproc
7 from samba_utils import *
10 opt.tool_options('compiler_cc')
12 opt.tool_options('gnu_dirs')
14 opt.add_option('--bundled-libraries',
15 help=("comma separated list of bundled libraries. May include !LIBNAME to disable bundling a library. Can be 'NONE' or 'ALL' [auto]"),
16 action="store", dest='BUNDLED_LIBS', default='')
18 extension_default = Options.options['BUNDLED_EXTENSION_DEFAULT']
19 opt.add_option('--bundled-library-extension',
20 help=("name extension for bundled libraries [%s]" % extension_default),
21 action="store", dest='BUNDLED_EXTENSION', default=extension_default)
23 extension_exception = Options.options['BUNDLED_EXTENSION_EXCEPTION']
24 opt.add_option('--bundled-extension-exception',
25 help=("comman separated list of libraries to not apply extension to [%s]" % extension_exception),
26 action="store", dest='BUNDLED_EXTENSION_EXCEPTION', default=extension_exception)
28 builtin_defauilt = Options.options['BUILTIN_LIBRARIES_DEFAULT']
29 opt.add_option('--builtin-libraries',
30 help=("command separated list of libraries to build directly into binaries [%s]" % builtin_defauilt),
31 action="store", dest='BUILTIN_LIBRARIES', default=builtin_defauilt)
33 opt.add_option('--with-modulesdir',
34 help=("modules directory [PREFIX/modules]"),
35 action="store", dest='MODULESDIR', default='${PREFIX}/modules')
36 opt.add_option('--disable-shared',
37 help=("Disable all use of shared libraries"),
38 action="store_true", dest='disable_shared', default=False)
39 opt.add_option('--disable-rpath',
40 help=("Disable use of rpath for build binaries"),
41 action="store_true", dest='disable_rpath_build', default=False)
42 opt.add_option('--disable-rpath-install',
43 help=("Disable use of rpath for installed binaries"),
44 action="store_true", dest='disable_rpath_install', default=False)
45 opt.add_option('--enable-developer',
46 help=("Turn on developer warnings and debugging"),
47 action="store_true", dest='developer', default=False)
48 opt.add_option('--enable-gccdeps',
49 help=("Enable use gcc -MD dependency module"),
50 action="store_true", dest='enable_gccdeps', default=False)
51 opt.add_option('--timestamp-dependencies',
52 help=("use file timestamps instead of content for build dependencies (BROKEN)"),
53 action="store_true", dest='timestamp_dependencies', default=False)
55 help='enable configure cacheing',
56 action='store_true', dest='enable_configure_cache')
57 opt.add_option('--pedantic',
58 help=("Enable even more compiler warnings"),
59 action='store_true', dest='pedantic', default=False)
64 conf.env.srcdir = conf.srcdir
66 if Options.options.timestamp_dependencies:
67 conf.ENABLE_TIMESTAMP_DEPENDENCIES()
69 conf.SETUP_CONFIGURE_CACHE(Options.options.enable_configure_cache)
71 # load our local waf extensions
72 conf.check_tool('gnu_dirs')
73 conf.check_tool('wafsamba')
77 conf.check_tool('compiler_cc')
79 if Options.options.enable_gccdeps:
80 # don't enable gccdeps by default as it needs a very recent version gcc
81 conf.check_tool('gccdeps', tooldir=conf.srcdir + "/buildtools/wafsamba")
83 # make the install paths available in environment
84 conf.env.LIBDIR = Options.options.LIBDIR or '${PREFIX}/lib'
85 conf.env.BINDIR = Options.options.BINDIR or '${PREFIX}/bin'
86 conf.env.SBINDIR = Options.options.SBINDIR or '${PREFIX}/sbin'
87 conf.env.MODULESDIR = Options.options.MODULESDIR
88 conf.env.BUNDLED_LIBS = Options.options.BUNDLED_LIBS.split(',')
89 conf.env.BUILTIN_LIBRARIES = Options.options.BUILTIN_LIBRARIES.split(',')
90 conf.env.DISABLE_SHARED = Options.options.disable_shared
92 conf.env.BUNDLED_EXTENSION = Options.options.BUNDLED_EXTENSION
93 conf.env.BUNDLED_EXTENSION_EXCEPTION = Options.options.BUNDLED_EXTENSION_EXCEPTION.split(',')
95 # see if we can compile and run a simple C program
96 conf.CHECK_CODE('printf("hello world\\n")',
97 define='HAVE_SIMPLE_C_PROG',
101 msg='Checking simple C program')
103 # see if we can build shared libs
104 if not conf.CHECK_LIBRARY_SUPPORT():
105 conf.env.DISABLE_SHARED = True
108 if not conf.env.DISABLE_SHARED and conf.CHECK_LIBRARY_SUPPORT(rpath=True):
109 conf.env.RPATH_ON_BUILD = not Options.options.disable_rpath_build
110 conf.env.RPATH_ON_INSTALL = (conf.env.RPATH_ON_BUILD and
111 not Options.options.disable_rpath_install)
113 conf.env.RPATH_ON_INSTALL = False
114 conf.env.RPATH_ON_BUILD = False
116 # we should use the PIC options in waf instead
117 conf.ADD_CFLAGS('-fPIC', testflags=True)
119 # check for pkgconfig
120 conf.check_cfg(atleast_pkgconfig_version='0.0.0')
122 conf.DEFINE('_GNU_SOURCE', 1, add_to_cflags=True)
123 conf.DEFINE('_XOPEN_SOURCE_EXTENDED', 1, add_to_cflags=True)
125 # get the base headers we'll use for the rest of the tests
126 conf.CHECK_HEADERS('stdio.h sys/types.h sys/stat.h stdlib.h stddef.h memory.h string.h',
128 conf.CHECK_HEADERS('strings.h inttypes.h stdint.h unistd.h minix/config.h', add_headers=True)
129 conf.CHECK_HEADERS('ctype.h standards.h stdbool.h stdint.h stdarg.h vararg.h', add_headers=True)
131 # see if we need special largefile flags
132 conf.CHECK_LARGEFILE()
134 if 'HAVE_STDDEF_H' in conf.env and 'HAVE_STDLIB_H' in conf.env:
135 conf.DEFINE('STDC_HEADERS', 1)
137 conf.CHECK_HEADERS('sys/time.h time.h', together=True)
139 if 'HAVE_SYS_TIME_H' in conf.env and 'HAVE_TIME_H' in conf.env:
140 conf.DEFINE('TIME_WITH_SYS_TIME', 1)
142 conf.define('SHLIBEXT', "so", quote=True)
144 conf.CHECK_CODE('long one = 1; return ((char *)(&one))[0]',
146 define='WORDS_BIGENDIAN')
148 # check if signal() takes a void function
149 if conf.CHECK_CODE('return *(signal (0, 0)) (0) == 1',
150 define='RETSIGTYPE_INT',
153 msg='Checking if signal handlers return int'):
154 conf.DEFINE('RETSIGTYPE', 'int')
156 conf.DEFINE('RETSIGTYPE', 'void')
158 conf.CHECK_VARIABLE('__FUNCTION__', define='HAVE_FUNCTION_MACRO')
160 conf.CHECK_CODE('va_list ap1,ap2; va_copy(ap1,ap2)',
161 define="HAVE_VA_COPY",
162 msg="Checking for va_copy")
165 #define eprintf(...) fprintf(stderr, __VA_ARGS__)
166 eprintf("bla", "bar")
167 ''', define='HAVE__VA_ARGS__MACRO')
169 conf.SAMBA_BUILD_ENV()
173 bld.SETUP_BUILD_GROUPS()
174 bld.ENFORCE_GROUP_ORDERING()
175 bld.CHECK_PROJECT_RULES()