10 from optparse
import SUPPRESS_HELP
11 sys
.path
.insert(0, srcdir
+"/buildtools/wafsamba")
12 import wafsamba
, Options
14 import samba_utils
, samba_version
18 opt
.BUILTIN_DEFAULT('NONE')
19 opt
.PRIVATE_EXTENSION_DEFAULT('s3')
20 opt
.RECURSE('../lib/replace')
22 opt
.RECURSE('selftest')
23 opt
.RECURSE('../lib/nss_wrapper')
24 opt
.RECURSE('../lib/socket_wrapper')
25 opt
.RECURSE('../lib/tevent')
26 opt
.RECURSE('../lib/tdb')
28 opt
.add_option('--with-static-modules',
29 help=("Comma-separated list of names of modules to statically link in"),
30 action
="store", dest
='static_modules', default
=None)
31 opt
.add_option('--with-shared-modules',
32 help=("Comma-separated list of names of modules to build shared"),
33 action
="store", dest
='shared_modules', default
=None)
34 opt
.add_option('--enable-selftest',
35 help=("enable options necessary for selftest"),
36 action
="store_true", dest
='enable_selftest', default
=False)
38 opt
.SAMBA3_ADD_OPTION('winbind')
39 opt
.SAMBA3_ADD_OPTION('swat')
40 opt
.SAMBA3_ADD_OPTION('ads')
41 opt
.SAMBA3_ADD_OPTION('krb5')
42 opt
.SAMBA3_ADD_OPTION('ldap')
43 opt
.SAMBA3_ADD_OPTION('cups', with_name
="enable", without_name
="disable")
44 opt
.SAMBA3_ADD_OPTION('merged-build', with_name
="enable", without_name
="disable")
45 opt
.SAMBA3_ADD_OPTION('pam')
46 opt
.SAMBA3_ADD_OPTION('quotas')
47 opt
.SAMBA3_ADD_OPTION('sys-quotas')
48 opt
.SAMBA3_ADD_OPTION('sendfile-support')
49 opt
.SAMBA3_ADD_OPTION('utmp')
50 opt
.SAMBA3_ADD_OPTION('pthreadpool', with_name
="enable", without_name
="disable")
51 opt
.SAMBA3_ADD_OPTION('avahi', with_name
="enable", without_name
="disable")
52 opt
.SAMBA3_ADD_OPTION('iconv')
53 opt
.SAMBA3_ADD_OPTION('acl-support')
54 opt
.SAMBA3_ADD_OPTION('dnsupdate')
58 from samba_utils
import TO_LIST
60 version
= samba_version
.load_version(env
=conf
.env
)
62 conf
.DEFINE('CONFIG_H_IS_FROM_SAMBA', 1)
63 conf
.DEFINE('_SAMBA_BUILD_', version
.MAJOR
, add_to_cflags
=True)
64 conf
.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags
=True)
66 if Options
.options
.developer
:
67 conf
.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
68 conf
.env
['developer'] = True
70 if Options
.options
.with_swat
:
71 conf
.env
['build_swat'] = True
73 conf
.ADD_EXTRA_INCLUDES('''#source3 #source3/include #lib/replace #lib/talloc
74 #lib/tevent #source3/libaddns #source3/librpc
75 #source3/lib #lib/tdb/include #lib/popt #source4''')
77 conf
.RECURSE('../lib/replace')
79 conf
.RECURSE('../lib/tdb')
80 conf
.RECURSE('../lib/talloc')
81 conf
.RECURSE('../lib/tevent')
82 conf
.RECURSE('../lib/popt')
83 conf
.RECURSE('../lib/nss_wrapper')
84 conf
.RECURSE('../lib/socket_wrapper')
85 conf
.RECURSE('../lib/zlib')
86 conf
.RECURSE('../libcli/smbreadline')
88 conf
.ADD_LDFLAGS("-Wl,--export-dynamic", testflags
=True)
90 conf
.CHECK_HEADERS('execinfo.h libexc.h libunwind.h netdb.h')
91 conf
.CHECK_HEADERS('linux/falloc.h')
93 conf
.CHECK_FUNCS('getcwd fchown chmod fchmod mknod mknod64')
94 conf
.CHECK_FUNCS('strtol strchr strupr chflags')
95 conf
.CHECK_FUNCS('getrlimit fsync fdatasync setpgid')
96 conf
.CHECK_FUNCS('setsid glob strpbrk crypt16 getauthuid')
97 conf
.CHECK_FUNCS('sigprocmask sigblock sigaction sigset innetgr')
98 conf
.CHECK_FUNCS('initgroups select poll rdchk getgrnam getgrent pathconf')
99 conf
.CHECK_FUNCS('setpriv setgidx setuidx setgroups sysconf stat64 fstat64')
100 conf
.CHECK_FUNCS('lstat64 fopen64 atexit grantpt lseek64 ftruncate64 fallocate fallocate64 posix_fallocate posix_fallocate64')
101 conf
.CHECK_FUNCS('fseek64 fseeko64 ftell64 ftello64 setluid')
102 conf
.CHECK_FUNCS('getpwnam', headers
='sys/types.h pwd.h')
103 conf
.CHECK_FUNCS('opendir64 readdir64 seekdir64 telldir64 rewinddir64 closedir64')
104 conf
.CHECK_FUNCS('getpwent_r getdents64 setenv strcasecmp fcvt fcvtl')
105 conf
.CHECK_FUNCS('syslog vsyslog timegm setlocale nl_langinfo')
106 conf
.CHECK_FUNCS_IN('nanosleep', 'rt')
107 conf
.CHECK_FUNCS('lutimes futimes utimensat futimens')
108 conf
.CHECK_FUNCS('mlock munlock mlockall munlockall')
109 conf
.CHECK_FUNCS('memalign posix_memalign hstrerror')
110 conf
.CHECK_FUNCS('shmget')
111 conf
.CHECK_FUNCS_IN('shm_open', 'rt', checklibc
=True)
112 conf
.CHECK_FUNCS('gettext dgettext bindtextdomain textdomain')
113 #FIXME: for some reason this one still fails
114 conf
.CHECK_FUNCS_IN('yp_get_default_domain', 'nsl')
115 conf
.CHECK_FUNCS_IN('dn_expand _dn_expand __dn_expand', 'resolv')
116 conf
.CHECK_DECLS('fdatasync', reverse
=True)
117 conf
.CHECK_DECLS('readahead', reverse
=True, headers
='fcntl.h')
119 if conf
.CONFIG_SET('HAVE_LONG_LONG'):
120 conf
.DEFINE('HAVE_LONGLONG', 1)
122 if conf
.CHECK_CODE('''
123 #if defined(HAVE_UNISTD_H)
126 long ret = splice(0,0,1,0,400,0);
130 conf
.CHECK_DECLS('splice', reverse
=True, headers
='fcntl.h')
132 # Check for inotify support
133 conf
.CHECK_HEADERS('linux/inotify.h asm/unistd.h sys/inotify.h')
134 conf
.CHECK_FUNCS('inotify_init')
135 if "HAVE_LINUX_INOTIFY_H" in conf
.env
and "HAVE_INOTIFY_INIT" in conf
.env
:
136 conf
.DEFINE('HAVE_INOTIFY', 1)
138 # Check for kernel change notify support
141 #define F_NOTIFY 1026
144 exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ? 1 : 0);
145 }''', 'HAVE_KERNEL_CHANGE_NOTIFY', addmain
=False, execute
=True,
146 headers
='fcntl.h signal.h',
147 msg
="Checking for kernel change notify support")
149 # Check for Linux kernel oplocks
151 #include <sys/types.h>
155 #define F_NOTIFY 1026
158 exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ? 1 : 0);
159 }''', 'HAVE_KERNEL_OPLOCKS_LINUX', addmain
=False, execute
=True,
160 msg
="Checking for Linux kernel oplocks")
162 # Check for IRIX kernel oplock types
163 conf
.CHECK_CODE('oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;',
164 'HAVE_KERNEL_OPLOCKS_IRIX', headers
='fcntl.h',
165 msg
="Checking for IRIX kernel oplock types")
167 # Check for krenel share modes
169 #include <sys/types.h>
172 #include <sys/file.h>
178 exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
179 }''', 'HAVE_KERNEL_SHARE_MODES', addmain
=False, execute
=True,
180 msg
="Checking for krenel share modes")
182 # Check for various members of the stat structure
183 conf
.CHECK_TYPES('blksize_t blkcnt_t')
184 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_blocks', define
='HAVE_STAT_ST_BLOCKS',
185 headers
='sys/stat.h')
186 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_blksize', define
='HAVE_STAT_ST_BLKSIZE',
187 headers
='sys/stat.h')
189 # Check for POSIX capability support
190 conf
.CHECK_FUNCS_IN('cap_get_proc', 'cap', headers
='sys/capability.h')
192 if "HAVE_SYS_CAPABILITY_H" in conf
.env
:
196 if (!(cap = cap_get_proc())) exit(1);
198 cap_set_flag(cap, CAP_INHERITABLE, 1, vals, CAP_CLEAR);
199 cap_set_proc(cap);''',
200 'HAVE_POSIX_CAPABILITIES', execute
=True, lib
="cap",
201 headers
='sys/capability.h',
202 msg
="Checking whether POSIX capabilities are available")
204 # Check for int16, uint16, int32 and uint32 in rpc/types.h included from
205 # rpc/rpc.h. This is *really* broken but some systems (DEC OSF1) do this.
207 if conf
.CONFIG_SET("HAVE_RPC_RPC_H"):
208 conf
.CHECK_TYPE('int16', headers
='rpc/rpc.h',
209 define
='HAVE_INT16_FROM_RPC_RPC_H',
210 msg
="Checking for int16 typedef included by rpc/rpc.h")
211 conf
.CHECK_CODE('uint16 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
212 headers
='sys/types.h rpc/rpc.h',
213 msg
="Checking for uint16 typedef included by rpc/rpc.h")
214 conf
.CHECK_CODE('int32 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
215 headers
='sys/types.h rpc/rpc.h',
216 msg
="Checking for int32 typedef included by rpc/rpc.h")
217 conf
.CHECK_CODE('uint32 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
218 headers
='sys/types.h rpc/rpc.h',
219 msg
="Checking for uint32 typedef included by rpc/rpc.h")
220 conf
.CHECK_CODE('int i;', 'BROKEN_NISPLUS_INCLUDE_FILES',
221 headers
='sys/types.h sys/acl.h rpcsvc/nis.h',
222 msg
="Checking for broken nisplus include files")
224 # Check if the compiler will optimize out functions
227 this_function_does_not_exist();
230 }''', 'HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS',
231 msg
="Checking if the compiler will optimize out functions")
233 # Check if the compiler supports the LL suffix on long long integers
235 conf
.CHECK_CODE('long long i = 0x8000000000LL', 'COMPILER_SUPPORTS_LL',
237 msg
="Checking for LL suffix on long long integers")
240 _acl __acl add_proplist_entry atexit attr_getf attr_list attr_listf
241 attropen attr_remove attr_removef attr_set attr_setf backtrace_symbols
242 bindtextdomain _chdir __chdir chflags chmod _close __close _closedir
243 __closedir closedir64 creat64 crypt16 delproplist devnm dgettext dirfd
244 DNSServiceRegister _dup __dup _dup2 __dup2 endmntent execl
245 extattr_delete_fd extattr_delete_link extattr_get_fd extattr_get_file
246 extattr_get_link extattr_list_fd extattr_list_file extattr_list_link
247 extattr_set_fd extattr_set_file extattr_set_link _facl __facl _fchdir
248 __fchdir fchmod fchown _fcntl __fcntl fcvt fcvtl fdatasync
249 fdelproplist fgetea fgetproplist fgetxattr flistea flistxattr fopen64
250 _fork __fork fremoveea fremovexattr fseek64 fseeko64 fsetea
251 fsetproplist fsetxattr _fstat __fstat fstat64 _fstat64 __fstat64 fsync
252 ftell64 ftello64 ftruncate64 futimens futimes __fxstat getauthuid
253 getcwd _getcwd __getcwd getdents __getdents getdents64 getdirentries
254 getgrent getgrnam getgrouplist getmntent getpagesize
255 getproplist get_proplist_entry getpwanam getpwent_r getrlimit gettext
256 glob grantpt hstrerror initgroups innetgr
257 inotify_init lgetea lgetxattr listea listxattr llistea llistxattr
258 llseek _llseek __llseek lremoveea lremovexattr _lseek __lseek lseek64
259 lsetea lsetxattr _lstat __lstat lstat64 _lstat64 __lstat64 lutimes
260 __lxstat memalign mknod mknod64 mlock mlockall munlock munlockall
261 nl_langinfo _open __open open64 _open64 __open64 _opendir __opendir
262 opendir64 pathconf poll posix_fallocate posix_fallocate64
263 posix_memalign prctl pread _pread __pread pread64 _pread64 __pread64
264 pwrite _pwrite __pwrite pwrite64 _pwrite64
265 __pwrite64 rdchk _read __read _readdir __readdir readdir64 _readdir64
266 __readdir64 removeea removexattr rewinddir64 _seekdir __seekdir
267 seekdir64 select setea setenv setgidx setgroups setlocale setluid
268 setmntent setpgid setpriv setproplist setsid setuidx
269 setxattr shmget shm_open sigaction sigblock sigprocmask sigset
270 sizeof_proplist_entry _stat __stat stat64 _stat64 __stat64 statvfs
271 strcasecmp strchr strpbrk strsignal strtol strupr sysconf sysctlbyname
272 __sys_llseek syslog _telldir __telldir telldir64 textdomain timegm
273 utimensat vsyslog _write __write __xstat
276 conf
.CHECK_TYPE('struct timespec', headers
='sys/time.h time.h')
278 conf
.CHECK_SAMBA3_CHARSET() # see build/charset.py
280 # FIXME: these should be tests for features, but the old build system just
283 host_os
= sys
.platform
285 # Python doesn't have case switches... :/
286 # FIXME: original was *linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu | *qnx*)
287 # the search for .rfind('gnu') covers gnu* and *-gnu is that too broad?
288 if (host_os
.rfind('linux') > -1) or (host_os
.rfind('gnu') > -1) or (host_os
.rfind('qnx') > -1):
289 if host_os
.rfind('linux') > -1:
290 conf
.DEFINE('LINUX', '1')
291 elif host_os
.rfind('qnx') > -1:
292 conf
.DEFINE('QNX', '1')
293 conf
.DEFINE('STAT_ST_BLOCKSIZE', '512')
294 elif (host_os
.rfind('darwin') > -1):
295 conf
.DEFINE('DARWINOS', 1)
296 conf
.DEFINE('STAT_ST_BLOCKSIZE', '512')
297 conf
.ADD_CFLAGS('-fno-common')
298 # FIXME: Add more checks here.
300 print "Unknown host_os '%s', please report this to samba-technical@samba.org" % host_os
302 #FIXME: add more checks
303 if Options
.options
.with_acl_support
:
304 if host_os
.rfind('linux') > -1:
305 conf
.CHECK_FUNCS_IN('acl_get_file', 'acl')
306 conf
.CHECK_FUNCS_IN('getxattr', 'attr')
307 if conf
.CHECK_CODE('''
310 acl_entry_t *entry_p;
311 return acl_get_entry(acl, entry_id, entry_p);
314 headers
='sys/types.h sys/acl.h', link
=False,
315 msg
="Checking for POSIX ACL support") :
317 acl_permset_t permset_d;
319 return acl_get_perm_np(permset_d, perm);
321 'HAVE_ACL_GET_PERM_NP',
322 headers
='sys/types.h sys/acl.h', link
=True,
323 msg
="Checking whether acl_get_perm_np() is available")
325 conf
.DEFINE('HAVE_NO_ACLS', 1)
326 conf
.SET_TARGET_TYPE('acl', 'EMPTY')
327 conf
.SET_TARGET_TYPE('attr', 'EMPTY')
329 conf
.DEFINE('HAVE_NO_ACLS', 1)
330 conf
.SET_TARGET_TYPE('acl', 'EMPTY')
331 conf
.SET_TARGET_TYPE('attr', 'EMPTY')
333 if conf
.CHECK_FUNCS('dirfd'):
334 conf
.DEFINE('HAVE_DIRFD_DECL', 1)
336 conf
.CHECK_CODE('struct statfs fsd; fsid_t fsid = fsd.f_fsid; return statfs(".", &fsd);',
337 'HAVE_STATFS_F_FSID',
338 msg
="vfs_fileid: checking for statfs() and struct statfs.f_fsid",
339 headers
='sys/types.h sys/statfs.h',
342 if conf
.CONFIG_SET('HAVE_FALLOCATE'):
344 #if defined(HAVE_UNISTD_H)
347 #include <sys/types.h>
350 #if defined(HAVE_LINUX_FALLOC_H)
351 #include <linux/falloc.h>
353 int ret = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 10);''',
354 'HAVE_LINUX_FALLOCATE',
355 msg
="Checking whether the Linux 'fallocate' function is available")
356 if conf
.CONFIG_SET('HAVE_FALLOCATE64'):
358 #if defined(HAVE_UNISTD_H)
361 #include <sys/types.h>
364 #if defined(HAVE_LINUX_FALLOC_H)
365 #include <linux/falloc.h>
367 int ret = fallocate64(0, FALLOC_FL_KEEP_SIZE, 0, 10);''',
368 'HAVE_LINUX_FALLOCATE64',
369 msg
="Checking whether the Linux 'fallocate64' function is available")
371 #if defined(HAVE_UNISTD_H)
375 ssize_t err = readahead(0,0,0x80000);''',
376 'HAVE_LINUX_READAHEAD',
377 msg
="Checking whether Linux readahead is available")
378 conf
.CHECK_DECLS('readahead', headers
='fcntl.h', always
=True)
381 #include <sys/types.h>
382 #include <sys/socket.h>],
385 int ret = getsockopt(0, SOL_SOCKET, SO_PEERCRED, &cred, &cred_len);''',
387 msg
="Checking whether we can use SO_PEERCRED to get socket credentials")
390 #if defined(HAVE_LONGLONG) && (defined(HAVE_OFF64_T) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8)))
391 #include <sys/types.h>
396 'HAVE_EXPLICIT_LARGEFILE_SUPPORT',
397 msg
="Checking whether large file support can be enabled")
399 default_static_modules
=TO_LIST('''pdb_smbpasswd pdb_tdbsam pdb_wbc_sam pdb_ldap
400 auth_sam auth_unix auth_winbind auth_wbc auth_server
401 auth_domain auth_builtin auth_netlogond vfs_default
402 nss_info_template idmap_ldap idmap_tdb idmap_passdb
405 default_shared_modules
=TO_LIST('''vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk
406 vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap
407 vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2 charset_CP850
408 charset_CP437 auth_script vfs_readahead vfs_xattr_tdb
409 vfs_streams_xattr vfs_streams_depot vfs_acl_xattr vfs_acl_tdb
410 vfs_smb_traffic_analyzer vfs_preopen vfs_catia vfs_scannedonly
411 vfs_crossrename vfs_linux_xfs_sgid
412 vfs_time_audit idmap_autorid''')
414 if Options
.options
.developer
:
415 default_static_modules
.extend(TO_LIST('pdb_ads'))
416 default_shared_modules
.extend(TO_LIST('charset_weird perfcount_test'))
418 if Options
.options
.with_acl_support
and conf
.CONFIG_SET('HAVE_POSIX_ACLS'):
419 default_static_modules
.extend(TO_LIST('vfs_posixacl'))
421 if conf
.CONFIG_SET('HAVE_DIRFD_DECL'):
422 default_shared_modules
.extend(TO_LIST('vfs_syncops vfs_dirsort'))
424 if conf
.CONFIG_SET('HAVE_STATFS_F_FSID'):
425 default_shared_modules
.extend(TO_LIST('vfs_fileid'))
427 explicit_shared_modules
= TO_LIST(Options
.options
.shared_modules
, delimiter
=',')
428 explicit_static_modules
= TO_LIST(Options
.options
.static_modules
, delimiter
=',')
430 final_static_modules
= default_static_modules
431 final_shared_modules
= default_shared_modules
433 for m
in explicit_static_modules
:
434 if m
in final_shared_modules
:
435 final_shared_modules
.remove(m
)
436 final_static_modules
.append(m
)
437 for m
in explicit_shared_modules
:
438 if m
in final_static_modules
:
439 final_static_modules
.remove(m
)
440 final_shared_modules
.append(m
)
442 conf
.env
['static_modules'] = final_static_modules
443 conf
.env
['shared_modules'] = final_shared_modules
445 conf
.DEFINE('STRING_STATIC_MODULES', ' '.join(final_static_modules
), quote
=True)
450 prefixes
= ['vfs', 'pdb', 'auth', 'nss_info', 'charset', 'idmap', 'gpext', 'perfcount']
451 conf
.env
['MODULE_PREFIXES'] = prefixes
453 for m
in final_static_modules
:
455 if not p
in static_list
:
457 static_list
[p
].append(m
)
458 for m
in final_shared_modules
:
460 if not p
in shared_list
:
462 shared_list
[p
].append(m
)
465 static_env
= "%s_STATIC" % p
.upper()
466 shared_env
= "%s_SHARED" % p
.upper()
467 conf
.env
[static_env
] = []
468 conf
.env
[shared_env
] = []
471 for entry
in static_list
[p
]:
472 decl_list
+= "extern NTSTATUS %s_init(void); " % entry
473 conf
.env
[static_env
].append('%s' % entry
)
474 decl_list
= decl_list
.rstrip()
475 conf
.DEFINE('static_decl_%s' % p
, decl_list
)
476 conf
.DEFINE('static_init_%s' % p
, '{ %s_init(); }' % '_init(); '.join(static_list
[p
]))
478 conf
.DEFINE('static_decl_%s' % p
, '')
479 conf
.DEFINE('static_init_%s' % p
, '{}')
481 for entry
in shared_list
[p
]:
482 conf
.DEFINE('%s_init' % entry
, 'init_samba_module')
483 conf
.env
[shared_env
].append('%s' % entry
)
485 if Options
.options
.with_winbind
:
486 conf
.env
.build_winbind
= True
487 conf
.DEFINE('WITH_WINBIND', '1')
489 conf
.find_program('awk', var
='AWK')
490 conf
.find_program('perl', var
='PERL')
492 # Darwin has extra options to xattr-family functions
493 conf
.CHECK_CODE('getxattr(0, 0, 0, 0, 0, 0);',
495 msg
="Checking whether xattr interface takes additional options",
496 headers
='sys/types.h attr/xattr.h sys/xattr.h')
498 conf
.CHECK_HEADERS('asm/types.h')
500 conf
.CHECK_CODE('dev_t dev; int i = major(dev); return 0', "HAVE_DEVICE_MAJOR_FN",
501 headers
='unistd.h sys/types.h',
502 msg
="Checking for major macro")
504 conf
.CHECK_CODE('dev_t dev; int i = minor(dev); return 0', "HAVE_DEVICE_MINOR_FN",
505 headers
='unistd.h sys/types.h',
506 msg
="Checking for minor macro")
508 conf
.CHECK_STRUCTURE_MEMBER('struct dirent', 'd_off',
509 headers
='unistd.h sys/types.h dirent.h',
510 define
='HAVE_DIRENT_D_OFF')
512 conf
.CHECK_FUNCS('setnetgrent getnetgrent endnetgrent')
513 conf
.CHECK_CODE('setnetgrent("foo")', 'HAVE_SETNETGRENT_PROTOTYPE',
514 msg
="Checking for setnetgrent prototype",
515 headers
='netdb.h netgroup.h',
516 cflags
="-Werror-implicit-function-declaration")
517 conf
.CHECK_CODE('getnetgrent', 'HAVE_GETNETGRENT_PROTOTYPE',
518 msg
="Checking for getnetgrent prototype",
519 headers
='netdb.h netgroup.h',
520 cflags
="-Werror-implicit-function-declaration")
521 conf
.CHECK_CODE('endnetgrent', 'HAVE_ENDNETGRENT_PROTOTYPE',
522 msg
="Checking for endnetgrent prototype",
523 headers
='netdb.h netgroup.h',
524 cflags
="-Werror-implicit-function-declaration")
526 #FIXME: Should just be set when krb5 and ldap requirements are fulfilled
527 if Options
.options
.with_ads
:
528 conf
.DEFINE('WITH_ADS', '1')
531 conf
.find_program('cups-config', var
='CUPS_CONFIG')
532 if conf
.env
.CUPS_CONFIG
and Options
.options
.with_cups
:
533 conf
.check_cfg(path
="cups-config", args
="--cflags --ldflags --libs",
534 package
="", uselib_store
="cups")
535 conf
.CHECK_HEADERS('cups/cups.h cups/language.h', lib
='cups')
536 conf
.CHECK_LIB('cups')
537 conf
.CHECK_FUNCS_IN('httpConnect httpConnectEncrypt', 'cups')
539 # define an empty subsystem for cups, to allow it to be used as an empty dependency
540 conf
.SET_TARGET_TYPE('cups', 'EMPTY')
543 if Options
.options
.with_ldap
:
544 conf
.CHECK_HEADERS('ldap.h lber.h')
545 conf
.CHECK_TYPE('ber_tag_t', 'unsigned int', headers
='ldap.h lber.h')
546 conf
.CHECK_FUNCS_IN('ber_scanf ber_sockbuf_add_io', 'lber')
547 conf
.CHECK_VARIABLE('LDAP_OPT_SOCKBUF', headers
='ldap.h')
548 # if ber_sockbuf_add_io() and LDAP_OPT_SOCKBUF are available, we can add
549 # SASL wrapping hooks
550 if conf
.CONFIG_SET('HAVE_BER_SOCKBUF_ADD_IO') and \
551 conf
.CONFIG_SET('HAVE_LDAP_OPT_SOCKBUF'):
552 conf
.DEFINE('HAVE_LDAP_SASL_WRAPPING', '1')
554 # if we LBER_OPT_LOG_PRINT_FN we can intercept ldap logging and print it out
556 conf
.CHECK_VARIABLE('LBER_OPT_LOG_PRINT_FN',
557 define
='HAVE_LBER_LOG_PRINT_FN', headers
='lber.h')
559 conf
.CHECK_FUNCS_IN('ldap_init ldap_initialize ldap_set_rebind_proc', 'ldap')
560 conf
.CHECK_FUNCS_IN('ldap_add_result_entry', 'ldap')
562 # Check if ldap_set_rebind_proc() takes three arguments
563 if conf
.CHECK_CODE('ldap_set_rebind_proc(0, 0, 0)',
564 'LDAP_SET_REBIND_PROC_ARGS',
565 msg
="Checking whether ldap_set_rebind_proc takes 3 arguments",
566 headers
='ldap.h lber.h', link
=False):
567 conf
.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '3')
569 conf
.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '2')
571 # last but not least, if ldap_init() exists, we want to use ldap
572 if conf
.CONFIG_SET('HAVE_LDAP_INIT'):
573 conf
.DEFINE('HAVE_LDAP', '1')
574 conf
.DEFINE('LDAP_DEPRECATED', '1')
575 conf
.env
['SMBLDAP'] = 'lib/smbldap.c'
576 conf
.env
['SMBLDAPUTIL'] = 'lib/smbldap_util.c'
578 conf
.SET_TARGET_TYPE('ldap', 'EMPTY')
579 conf
.SET_TARGET_TYPE('lber', 'EMPTY')
582 conf
.find_program('krb5-config', var
='KRB5_CONFIG')
583 if conf
.env
.KRB5_CONFIG
and Options
.options
.with_krb5
:
584 conf
.check_cfg(path
="krb5-config", args
="--cflags --libs",
585 package
="gssapi", uselib_store
="krb5")
586 conf
.CHECK_HEADERS('krb5.h krb5/locate_plugin.h', lib
='krb5')
587 conf
.CHECK_HEADERS('gssapi.h gssapi/gssapi_generic.h gssapi/gssapi.h gssapi/gssapi_ext.h com_err.h', lib
='krb5')
589 if conf
.CONFIG_SET('HAVE_KRB5_LOCATE_PLUGIN_H'):
590 conf
.env
['WINBIND_KRB5_LOCATOR'] = 'bin/winbind_krb5_locator.so'
592 conf
.CHECK_FUNCS_IN('_et_list', 'com_err')
593 conf
.CHECK_FUNCS_IN('krb5_encrypt_data', 'k5crypto')
594 conf
.CHECK_FUNCS_IN('crypto', 'des_set_key')
595 conf
.CHECK_FUNCS_IN('copy_Authenticator', 'asn1')
596 conf
.CHECK_FUNCS_IN('roken_getaddrinfo_hostspec', 'roken')
597 if conf
.CHECK_FUNCS_IN('gss_display_status', 'gssapi gssapi_krb5'):
598 conf
.DEFINE('HAVE_GSSAPI', '1')
599 conf
.CHECK_FUNCS_IN('gss_wrap_iov', 'gssapi gssapi_krb5 krb5')
600 conf
.CHECK_FUNCS_IN('krb5_mk_req_extended krb5_kt_compare', 'krb5')
602 krb5_set_real_time krb5_set_default_in_tkt_etypes krb5_set_default_tgs_enctypes
603 krb5_set_default_tgs_ktypes krb5_principal2salt krb5_use_enctype
604 krb5_string_to_key krb5_get_pw_salt krb5_string_to_key_salt krb5_auth_con_setkey
605 krb5_auth_con_setuseruserkey krb5_locate_kdc krb5_get_permitted_enctypes
606 krb5_get_default_in_tkt_etypes krb5_free_data_contents
607 krb5_principal_get_comp_string krb5_free_unparsed_name
608 krb5_free_keytab_entry_contents krb5_kt_free_entry krb5_krbhst_init
609 krb5_krbhst_get_addrinfo krb5_c_enctype_compare krb5_enctypes_compatible_keys
610 krb5_crypto_init krb5_crypto_destroy krb5_decode_ap_req free_AP_REQ
611 krb5_verify_checksum krb5_c_verify_checksum krb5_principal_compare_any_realm
612 krb5_parse_name_norealm krb5_princ_size krb5_get_init_creds_opt_set_pac_request
613 krb5_get_renewed_creds krb5_get_kdc_cred krb5_free_error_contents
614 initialize_krb5_error_table krb5_get_init_creds_opt_alloc
615 krb5_get_init_creds_opt_free krb5_get_init_creds_opt_get_error
616 krb5_enctype_to_string krb5_fwd_tgt_creds krb5_auth_con_set_req_cksumtype
617 krb5_get_creds_opt_alloc krb5_get_creds_opt_set_impersonate krb5_get_creds
618 krb5_get_credentials_for_user krb5_get_host_realm krb5_free_host_realm''',
620 conf
.CHECK_DECLS('''krb5_get_credentials_for_user
621 krb5_auth_con_set_req_cksumtype''',
622 headers
='krb5.h', always
=True)
623 conf
.CHECK_VARIABLE('AP_OPTS_USE_SUBKEY', headers
='krb5.h')
624 conf
.CHECK_VARIABLE('KV5M_KEYTAB', headers
='krb5.h')
625 conf
.CHECK_VARIABLE('KRB5_KU_OTHER_CKSUM', headers
='krb5.h')
626 conf
.CHECK_VARIABLE('KRB5_KEYUSAGE_APP_DATA_CKSUM', headers
='krb5.h')
627 conf
.CHECK_STRUCTURE_MEMBER('krb5_keytab_entry', 'key', headers
='krb5.h',
628 define
='HAVE_KRB5_KEYTAB_ENTRY_KEY')
629 conf
.CHECK_STRUCTURE_MEMBER('krb5_keytab_entry', 'keyblock', headers
='krb5.h',
630 define
='HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK')
631 conf
.CHECK_STRUCTURE_MEMBER('krb5_address', 'magic', headers
='krb5.h',
632 define
='HAVE_MAGIC_IN_KRB5_ADDRESS')
633 conf
.CHECK_STRUCTURE_MEMBER('krb5_address', 'addrtype', headers
='krb5.h',
634 define
='HAVE_ADDRTYPE_IN_KRB5_ADDRESS')
635 conf
.CHECK_STRUCTURE_MEMBER('krb5_ticket', 'enc_part2', headers
='krb5.h',
636 define
='HAVE_KRB5_TKT_ENC_PART2')
637 conf
.CHECK_STRUCTURE_MEMBER('krb5_creds', 'keyblock', headers
='krb5.h',
638 define
='HAVE_KRB5_KEYBLOCK_IN_CREDS')
639 conf
.CHECK_STRUCTURE_MEMBER('krb5_creds', 'session', headers
='krb5.h',
640 define
='HAVE_KRB5_SESSION_IN_CREDS')
641 conf
.CHECK_STRUCTURE_MEMBER('krb5_ap_req', 'ticket', headers
='krb5.h',
642 define
='HAVE_TICKET_POINTER_IN_KRB5_AP_REQ')
644 conf
.CHECK_TYPE('krb5_encrypt_block', headers
='krb5.h')
649 krb5_enctype enctype;
650 enctype = ticket.enc_part.enctype;
651 kvno = ticket.enc_part.kvno;
653 'KRB5_TICKET_HAS_KEYINFO',
654 headers
='krb5.h', link
=False,
655 msg
="Checking whether the krb5_ticket structure contains the kvno and enctype")
658 krb5_get_init_creds_opt *opt = NULL;
659 krb5_get_init_creds_opt_free(ctx, opt);
661 'KRB5_CREDS_OPT_FREE_REQUIRES_CONTEXT',
662 headers
='krb5.h', link
=False,
663 msg
="Checking whether krb5_get_init_creds_opt_free takes a context argument")
664 conf
.CHECK_CODE('krb5_mk_error(0,0,0)',
665 'HAVE_SHORT_KRB5_MK_ERROR_INTERFACE',
666 headers
='krb5.h', link
=False,
667 msg
="Checking whether krb5_mk_error takes 3 arguments MIT or 9 Heimdal")
669 const krb5_data *pkdata;
670 krb5_context context;
671 krb5_principal principal;
672 pkdata = krb5_princ_component(context, principal, 0);
674 'HAVE_KRB5_PRINC_COMPONENT',
675 headers
='krb5.h', lib
='krb5',
676 msg
="Checking whether krb5_princ_component is available")
681 krb5_enctype_to_string(1, buf, 256);
684 'HAVE_KRB5_ENCTYPE_TO_STRING_WITH_SIZE_T_ARG',
685 headers
='krb5.h', lib
='krb5',
686 addmain
=False, cflags
='-Werror',
687 msg
="Checking whether krb5_enctype_to_string takes size_t argument")
691 krb5_context context = NULL;
693 krb5_enctype_to_string(context, 1, &str);
697 'HAVE_KRB5_ENCTYPE_TO_STRING_WITH_KRB5_CONTEXT_ARG',
698 headers
='krb5.h stdlib.h', lib
='krb5',
699 addmain
=False, cflags
='-Werror',
700 msg
="Checking whether krb5_enctype_to_string takes krb5_context argument")
703 krb5_context ctx = NULL;
704 krb5_principal princ = NULL;
705 const char *str = krb5_princ_realm(ctx, princ)->data;
708 'HAVE_KRB5_PRINC_REALM',
709 headers
='krb5.h', lib
='krb5',
711 msg
="Checking whether the macro krb5_princ_realm is defined")
712 if conf
.CHECK_CODE('''krb5_verify_checksum(0, 0, 0, 0, 0, 0, 0);''',
713 'KRB5_VERIFY_CHECKSUM_ARGS',
714 headers
='krb5.h', lib
='krb5',
715 msg
="Checking whether krb5_verify_checksum takes 7 arguments"):
716 conf
.DEFINE('KRB5_VERIFY_CHECKSUM_ARGS', '7')
718 conf
.DEFINE('KRB5_VERIFY_CHECKSUM_ARGS', '6')
721 krb5_enctype enctype;
722 enctype = ENCTYPE_ARCFOUR_HMAC_MD5;
724 '_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5',
725 headers
='krb5.h', lib
='krb5',
726 msg
="Checking whether the ENCTYPE_ARCFOUR_HMAC_MD5 key type definition is available");
728 krb5_keytype keytype;
729 keytype = KEYTYPE_ARCFOUR_56;
731 '_HAVE_KEYTYPE_ARCFOUR_56',
732 headers
='krb5.h', lib
='krb5',
733 msg
="Checking whether the HAVE_KEYTYPE_ARCFOUR_56 key type definition is available");
734 if conf
.CONFIG_SET('_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5') and conf
.CONFIG_SET('_HAVE_KEYTYPE_ARCFOUR_56'):
735 conf
.DEFINE('HAVE_ENCTYPE_ARCFOUR_HMAC_MD5', '1')
738 krb5_enctype enctype;
739 enctype = ENCTYPE_ARCFOUR_HMAC;
741 'HAVE_ENCTYPE_ARCFOUR_HMAC',
742 headers
='krb5.h', lib
='krb5',
743 msg
="Checking whether the ENCTYPE_ARCFOUR_HMAC key type definition is available");
746 krb5_context context;
748 krb5_init_context(&context);
749 return krb5_kt_resolve(context, "WRFILE:api", &keytab);
751 'HAVE_WRFILE_KEYTAB',
752 headers
='krb5.h', lib
='krb5', execute
=True,
753 msg
="Checking whether the WRFILE:-keytab is supported");
755 conf
.DEFINE('HAVE_KRB5', '1')
758 conf
.SET_TARGET_TYPE('krb5', 'EMPTY')
759 conf
.SET_TARGET_TYPE('gssapi', 'EMPTY')
760 conf
.SET_TARGET_TYPE('gssapi_krb5', 'EMPTY')
761 conf
.SET_TARGET_TYPE('com_err', 'EMPTY')
762 conf
.SET_TARGET_TYPE('k5crypto', 'EMPTY')
764 if Options
.options
.with_utmp
:
765 conf
.CHECK_FUNCS('pututline pututxline updwtmp updwtmpx getutmpx getutxent')
766 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_name', headers
='utmp.h',
767 define
='HAVE_UT_UT_NAME')
768 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_user', headers
='utmp.h',
769 define
='HAVE_UT_UT_USER')
770 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_id', headers
='utmp.h',
771 define
='HAVE_UT_UT_ID')
772 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_host', headers
='utmp.h',
773 define
='HAVE_UT_UT_HOST')
774 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_time', headers
='utmp.h',
775 define
='HAVE_UT_UT_TIME')
776 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_tv', headers
='utmp.h',
777 define
='HAVE_UT_UT_TV')
778 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_type', headers
='utmp.h',
779 define
='HAVE_UT_UT_TYPE')
780 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_pid', headers
='utmp.h',
781 define
='HAVE_UT_UT_PID')
782 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_exit.e_exit', headers
='utmp.h',
783 define
='HAVE_UT_UT_EXIT')
784 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_addr_v6', headers
='utmp.h',
785 define
='HAVE_UT_UT_ADDR_V6')
786 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_addr', headers
='utmp.h',
787 define
='HAVE_UT_UT_ADDR')
788 conf
.CHECK_STRUCTURE_MEMBER('struct utmpx', 'ut_syslen', headers
='utmpx.h',
789 define
='HAVE_UX_UT_SYSLEN')
790 conf
.CHECK_CODE('struct utmp utarg; struct utmp *utreturn; utreturn = pututline(&utarg);',
791 'PUTUTLINE_RETURNS_UTMP', headers
='utmp.h',
792 msg
="Checking whether pututline returns pointer")
793 conf
.DEFINE('WITH_UTMP', 1)
795 if Options
.options
.with_avahi
:
796 conf
.env
.with_avahi
= True
797 if not conf
.CHECK_HEADERS('avahi-common/watch.h avahi-client/client.h'): conf
.env
.with_avahi
= False
798 if not conf
.CHECK_FUNCS_IN('avahi_client_new', 'avahi-client'): conf
.env
.with_avahi
= False
799 if not conf
.CHECK_FUNCS_IN('avahi_strerror', 'avahi-common'): conf
.env
.with_avahi
= False
800 if conf
.env
.with_avahi
:
801 conf
.DEFINE('WITH_AVAHI_SUPPORT', 1)
803 conf
.SET_TARGET_TYPE('avahi-common', 'EMPTY')
804 conf
.SET_TARGET_TYPE('avahi-client', 'EMPTY')
806 if Options
.options
.with_iconv
:
807 conf
.env
.with_iconv
= True
808 if not conf
.CHECK_FUNCS_IN('iconv_open', 'iconv', headers
='iconv.h'):
809 conf
.env
.with_iconv
= False
810 if conf
.env
.with_iconv
:
811 conf
.DEFINE('HAVE_ICONV', 1)
813 if Options
.options
.with_pam
:
814 conf
.CHECK_HEADERS('security/pam_appl.h pam/pam_appl.h')
815 if not conf
.CONFIG_SET('HAVE_SECURITY_PAM_APPL_H') and not conf
.CONFIG_SET('HAVE_PAM_PAM_APPL_H'):
816 print "--with-pam=yes but pam_appl.h not found"
818 conf
.CHECK_FUNCS_IN('pam_get_data', 'pam', mandatory
=True)
819 conf
.CHECK_HEADERS('security/pam_modules.h pam/pam_modules.h')
820 if not conf
.CONFIG_SET('HAVE_SECURITY_PAM_MODULES_H') and not conf
.CONFIG_SET('HAVE_PAM_PAM_MODULES_H'):
821 print "--with-pam=yes but pam_modules.h not found"
823 conf
.CHECK_HEADERS('security/pam_ext.h security/_pam_macros.h')
824 conf
.CHECK_HEADERS('pam/pam_ext.h pam/_pam_macros.h')
825 conf
.CHECK_FUNCS_IN('pam_vsyslog', 'pam')
827 #if defined(HAVE_SECURITY_PAM_APPL_H)
828 #include <security/pam_appl.h>
829 #elif defined(HAVE_PAM_PAM_APPL_H)
830 #include <pam/pam_appl.h>
832 pam_set_item(0, PAM_RHOST, 0);
836 msg
="Checking whether PAM_RHOST is available");
838 #if defined(HAVE_SECURITY_PAM_APPL_H)
839 #include <security/pam_appl.h>
840 #elif defined(HAVE_PAM_PAM_APPL_H)
841 #include <pam/pam_appl.h>
843 pam_set_item(0, PAM_TTY, 0);
847 msg
="Checking whether PAM_TTY is available");
849 #if (!defined(LINUX))
851 #define PAM_EXTERN extern
852 #if defined(HAVE_SECURITY_PAM_APPL_H)
853 #include <security/pam_appl.h>
854 #elif defined(HAVE_PAM_PAM_APPL_H)
855 #include <pam/pam_appl.h>
860 #if defined(HAVE_SECURITY_PAM_MODULES_H)
861 #include <security/pam_modules.h>
862 #elif defined(HAVE_PAM_PAM_MODULES_H)
863 #include <pam/pam_modules.h>
866 #if defined(HAVE_SECURITY__PAM_MACROS_H)
867 #include <security/_pam_macros.h>
868 #elif defined(HAVE_PAM__PAM_MACROS_H)
869 #include <pam/_pam_macros.h>
872 #ifdef HAVE_SECURITY_PAM_EXT_H
873 #include <security/pam_ext.h>
876 int i; i = PAM_RADIO_TYPE;
878 'HAVE_PAM_RADIO_TYPE',
880 msg
="Checking whether PAM_RADIO_TYPE is available");
881 conf
.DEFINE('WITH_PAM', 1)
882 conf
.DEFINE('WITH_PAM_MODULES', 1)
886 seteuid
= conf
.CHECK_CODE('''
887 #define AUTOCONF_TEST 1
888 #define USE_SETREUID 1
889 #include "./lib/util_sec.c"
894 msg
="Checking whether setreuid is available")
896 seteuid
= conf
.CHECK_CODE('''
897 #define AUTOCONF_TEST 1
898 #define USE_SETRESUID 1
899 #include "./lib/util_sec.c"
904 msg
="Checking whether setresuid is available")
906 seteuid
= conf
.CHECK_CODE('''
907 #define AUTOCONF_TEST 1
908 #define USE_SETEUID 1
909 #include "./lib/util_sec.c"
914 msg
="Checking whether seteuid is available")
916 seteuid
= conf
.CHECK_CODE('''
917 #define AUTOCONF_TEST 1
918 #define USE_SETUIDX 1
919 #include "./lib/util_sec.c"
925 msg
="Checking whether setuidx is available")
926 if Options
.options
.with_dnsupdate
:
927 conf
.CHECK_HEADERS('uuid/uuid.h')
928 conf
.CHECK_FUNCS_IN('uuid_generate', 'uuid')
929 if not conf
.CONFIG_SET('HAVE_UUID_UUID_H') and not conf
.CONFIG_SET('HAVE_UUID_GENERATE'):
930 print "--with-dnsupdate=yes but uuid support not sufficient"
932 conf
.DEFINE('WITH_DNS_UPDATES', 1)
934 conf
.SET_TARGET_TYPE('uuid', 'EMPTY')
935 conf
.CHECK_HEADERS('valgrind.h valgrind/valgrind.h valgrind/memcheck.h')
936 if Options
.options
.developer
:
937 if conf
.CONFIG_SET('HAVE_VALGRIND_H') or conf
.CONFIG_SET('HAVE_VALGRIND_VALGRIND_H'):
938 conf
.DEFINE('VALGRIND', '1')
940 conf
.SAMBA_CONFIG_H('include/config.h')
943 "build 'tags' file using ctags"
945 source_root
= os
.path
.dirname(Utils
.g_module
.root_path
)
946 cmd
= 'ctags $(find %s/.. -name "*.[ch]" | grep -v "*_proto\.h")' % source_root
947 print("Running: %s" % cmd
)