build: added --minimum-library-version configure option
[samba.git] / buildtools / wafsamba / wscript
1 #!/usr/bin/env python
2
3 # this is a base set of waf rules that everything else pulls in first
4
5 import sys, wafsamba
6 import Options, os, preproc
7 from samba_utils import *
8
9 def set_options(opt):
10     opt.tool_options('compiler_cc')
11
12     opt.tool_options('gnu_dirs')
13
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='')
17
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)
22
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)
27
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)
32
33     opt.add_option('--minimum-library-version',
34                    help=("list of minimum system library versions (LIBNAME1:version,LIBNAME2:version)"),
35                    action="store", dest='MINIMUM_LIBRARY_VERSION', default='')
36
37     opt.add_option('--with-modulesdir',
38                    help=("modules directory [PREFIX/modules]"),
39                    action="store", dest='MODULESDIR', default='${PREFIX}/modules')
40     opt.add_option('--disable-shared',
41                    help=("Disable all use of shared libraries"),
42                    action="store_true", dest='disable_shared', default=False)
43     opt.add_option('--disable-rpath',
44                    help=("Disable use of rpath for build binaries"),
45                    action="store_true", dest='disable_rpath_build', default=False)
46     opt.add_option('--disable-rpath-install',
47                    help=("Disable use of rpath for installed binaries"),
48                    action="store_true", dest='disable_rpath_install', default=False)
49     opt.add_option('--enable-developer',
50                    help=("Turn on developer warnings and debugging"),
51                    action="store_true", dest='developer', default=False)
52     opt.add_option('--picky-developer',
53                    help=("Treat all warnings as errors (enable -Werror)"),
54                    action="store_true", dest='picky_developer', default=False)
55     opt.add_option('--fatal-errors',
56                    help=("Stop compilation on first error (enable -Wfatal-errors)"),
57                    action="store_true", dest='fatal_errors', default=False)
58     opt.add_option('--enable-gccdeps',
59                    help=("Enable use gcc -MD dependency module"),
60                    action="store_true", dest='enable_gccdeps', default=False)
61     opt.add_option('--timestamp-dependencies',
62                    help=("use file timestamps instead of content for build dependencies (BROKEN)"),
63                    action="store_true", dest='timestamp_dependencies', default=False)
64     opt.add_option('-C',
65                    help='enable configure cacheing',
66                    action='store_true', dest='enable_configure_cache')
67     opt.add_option('--pedantic',
68                    help=("Enable even more compiler warnings"),
69                    action='store_true', dest='pedantic', default=False)
70
71 @wafsamba.runonce
72 def configure(conf):
73     conf.env.hlist = []
74     conf.env.srcdir = conf.srcdir
75
76     if Options.options.timestamp_dependencies:
77         conf.ENABLE_TIMESTAMP_DEPENDENCIES()
78
79     conf.SETUP_CONFIGURE_CACHE(Options.options.enable_configure_cache)
80
81     # load our local waf extensions
82     conf.check_tool('gnu_dirs')
83     conf.check_tool('wafsamba')
84
85     conf.CHECK_CC_ENV()
86
87     conf.check_tool('compiler_cc')
88
89     # we need git for 'waf dist'
90     conf.find_program('git', var='GIT')
91
92     if Options.options.enable_gccdeps:
93         # don't enable gccdeps by default as it needs a very recent version gcc
94         conf.check_tool('gccdeps', tooldir=conf.srcdir + "/buildtools/wafsamba")
95
96     # make the install paths available in environment
97     conf.env.LIBDIR = Options.options.LIBDIR or '${PREFIX}/lib'
98     conf.env.BINDIR = Options.options.BINDIR or '${PREFIX}/bin'
99     conf.env.SBINDIR = Options.options.SBINDIR or '${PREFIX}/sbin'
100     conf.env.MODULESDIR = Options.options.MODULESDIR
101     conf.env.BUNDLED_LIBS = Options.options.BUNDLED_LIBS.split(',')
102     conf.env.BUILTIN_LIBRARIES = Options.options.BUILTIN_LIBRARIES.split(',')
103     conf.env.DISABLE_SHARED = Options.options.disable_shared
104
105     conf.env.BUNDLED_EXTENSION = Options.options.BUNDLED_EXTENSION
106     conf.env.BUNDLED_EXTENSION_EXCEPTION = Options.options.BUNDLED_EXTENSION_EXCEPTION.split(',')
107
108     # see if we can compile and run a simple C program
109     conf.CHECK_CODE('printf("hello world\\n")',
110                     define='HAVE_SIMPLE_C_PROG',
111                     mandatory=True,
112                     execute=True,
113                     headers='stdio.h',
114                     msg='Checking simple C program')
115
116     # see if we can build shared libs
117     if not conf.CHECK_LIBRARY_SUPPORT():
118         conf.env.DISABLE_SHARED = True
119
120     # check for rpath
121     if not conf.env.DISABLE_SHARED and conf.CHECK_LIBRARY_SUPPORT(rpath=True):
122         conf.env.RPATH_ON_BUILD   = not Options.options.disable_rpath_build
123         conf.env.RPATH_ON_INSTALL = (conf.env.RPATH_ON_BUILD and
124                                      not Options.options.disable_rpath_install)
125     else:
126         conf.env.RPATH_ON_INSTALL = False
127         conf.env.RPATH_ON_BUILD   = False
128
129     # we should use the PIC options in waf instead
130     conf.ADD_CFLAGS('-fPIC', testflags=True)
131
132     # check for pkgconfig
133     conf.check_cfg(atleast_pkgconfig_version='0.0.0')
134
135     conf.DEFINE('_GNU_SOURCE', 1, add_to_cflags=True)
136     conf.DEFINE('_XOPEN_SOURCE_EXTENDED', 1, add_to_cflags=True)
137
138     # get the base headers we'll use for the rest of the tests
139     conf.CHECK_HEADERS('stdio.h sys/types.h sys/stat.h stdlib.h stddef.h memory.h string.h',
140                        add_headers=True)
141     conf.CHECK_HEADERS('strings.h inttypes.h stdint.h unistd.h minix/config.h', add_headers=True)
142     conf.CHECK_HEADERS('ctype.h standards.h stdbool.h stdint.h stdarg.h vararg.h', add_headers=True)
143     conf.CHECK_HEADERS('limits.h assert.h')
144
145     # see if we need special largefile flags
146     conf.CHECK_LARGEFILE()
147
148     if 'HAVE_STDDEF_H' in conf.env and 'HAVE_STDLIB_H' in conf.env:
149         conf.DEFINE('STDC_HEADERS', 1)
150
151     conf.CHECK_HEADERS('sys/time.h time.h', together=True)
152
153     if 'HAVE_SYS_TIME_H' in conf.env and 'HAVE_TIME_H' in conf.env:
154         conf.DEFINE('TIME_WITH_SYS_TIME', 1)
155
156     conf.define('SHLIBEXT', "so", quote=True)
157
158     conf.CHECK_CODE('long one = 1; return ((char *)(&one))[0]',
159                     execute=True,
160                     define='WORDS_BIGENDIAN')
161
162     # check if signal() takes a void function
163     if conf.CHECK_CODE('return *(signal (0, 0)) (0) == 1',
164                        define='RETSIGTYPE_INT',
165                        execute=False,
166                        headers='signal.h',
167                        msg='Checking if signal handlers return int'):
168         conf.DEFINE('RETSIGTYPE', 'int')
169     else:
170         conf.DEFINE('RETSIGTYPE', 'void')
171
172     conf.CHECK_VARIABLE('__FUNCTION__', define='HAVE_FUNCTION_MACRO')
173
174     conf.CHECK_CODE('va_list ap1,ap2; va_copy(ap1,ap2)',
175                     define="HAVE_VA_COPY",
176                     msg="Checking for va_copy")
177
178     conf.CHECK_CODE('''
179                     #define eprintf(...) fprintf(stderr, __VA_ARGS__)
180                     eprintf("bla", "bar")
181                     ''', define='HAVE__VA_ARGS__MACRO')
182
183     conf.SAMBA_BUILD_ENV()
184
185
186 def build(bld):
187     bld.SETUP_BUILD_GROUPS()
188     bld.ENFORCE_GROUP_ORDERING()
189     bld.CHECK_PROJECT_RULES()