7 from optparse
import SUPPRESS_HELP
8 sys
.path
.insert(0, srcdir
+"/buildtools/wafsamba")
9 import wafsamba
, Options
11 from samba_utils
import *
15 opt
.BUILTIN_DEFAULT('NONE')
16 opt
.BUNDLED_EXTENSION_DEFAULT('s3')
17 opt
.RECURSE('../lib/replace')
19 opt
.RECURSE('../lib/nss_wrapper')
20 opt
.RECURSE('../lib/socket_wrapper')
21 opt
.RECURSE('../lib/tevent')
22 opt
.RECURSE('../lib/tdb')
24 opt
.add_option('--with-static-modules',
25 help=("Comma-separated list of names of modules to statically link in"),
26 action
="store", dest
='static_modules', default
='')
27 opt
.add_option('--with-shared-modules',
28 help=("Comma-separated list of names of modules to build shared"),
29 action
="store", dest
='shared_modules', default
='')
31 opt
.SAMBA3_ADD_OPTION('winbind')
32 opt
.SAMBA3_ADD_OPTION('ads')
33 opt
.SAMBA3_ADD_OPTION('krb5')
34 opt
.SAMBA3_ADD_OPTION('ldap')
35 opt
.SAMBA3_ADD_OPTION('cups', with_name
="enable", without_name
="disable")
39 conf
.define('PACKAGE_NAME', 'Samba')
40 conf
.define('PACKAGE_STRING', 'Samba 3')
41 conf
.define('PACKAGE_TARNAME', 'samba')
42 conf
.define('PACKAGE_URL', '')
43 conf
.define('PACKAGE_VERSION', '3')
44 conf
.define('PACKAGE_BUGREPORT', 'samba-technical@samba.org')
46 conf
.DEFINE('CONFIG_H_IS_FROM_SAMBA', 1)
47 conf
.DEFINE('_SAMBA_BUILD_', 3, add_to_cflags
=True)
48 conf
.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags
=True)
49 if Options
.options
.developer
:
50 conf
.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
52 # set a limit on recursing in the waf preprocessor
53 conf
.env
.preprocessor_recursion_limit
= 10
55 conf
.ADD_EXTRA_INCLUDES('#source3 #source3/include #lib/replace #lib/talloc #lib/tevent #source3/libaddns #source3/librpc')
57 conf
.RECURSE('../lib/replace')
59 conf
.RECURSE('../lib/tdb')
60 conf
.RECURSE('../lib/talloc')
61 conf
.RECURSE('../lib/tevent')
62 conf
.RECURSE('../lib/popt')
63 conf
.RECURSE('../lib/nss_wrapper')
64 conf
.RECURSE('../lib/socket_wrapper')
65 conf
.RECURSE('../lib/zlib')
66 conf
.RECURSE('../lib/tsocket')
68 conf
.CHECK_HEADERS('execinfo.h libexc.h libunwind.h')
70 conf
.CHECK_FUNCS('getcwd fchown chmod fchmod mknod mknod64')
71 conf
.CHECK_FUNCS('strtol strchr strupr chflags')
72 conf
.CHECK_FUNCS('getrlimit fsync fdatasync setpgid')
73 conf
.CHECK_FUNCS('setsid glob strpbrk crypt16 getauthuid')
74 conf
.CHECK_FUNCS('sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent')
75 conf
.CHECK_FUNCS('initgroups select poll rdchk getgrnam getgrent pathconf')
76 conf
.CHECK_FUNCS('setpriv setgidx setuidx setgroups sysconf stat64 fstat64')
77 conf
.CHECK_FUNCS('lstat64 fopen64 atexit grantpt lseek64 ftruncate64 posix_fallocate posix_fallocate64')
78 conf
.CHECK_FUNCS('fseek64 fseeko64 ftell64 ftello64 setluid')
79 conf
.CHECK_FUNCS('getpwnam', headers
='sys/types.h pwd.h')
80 conf
.CHECK_FUNCS('opendir64 readdir64 seekdir64 telldir64 rewinddir64 closedir64')
81 conf
.CHECK_FUNCS('getpwent_r getdents64 setenv strcasecmp fcvt fcvtl')
82 conf
.CHECK_FUNCS('syslog vsyslog timegm setlocale nl_langinfo')
83 conf
.CHECK_FUNCS_IN('nanosleep', 'rt')
84 conf
.CHECK_FUNCS('lutimes futimes utimensat futimens')
85 conf
.CHECK_FUNCS('mlock munlock mlockall munlockall')
86 conf
.CHECK_FUNCS('memalign posix_memalign hstrerror')
87 conf
.CHECK_FUNCS('shmget')
88 conf
.CHECK_FUNCS_IN('shm_open', 'rt', checklibc
=True)
89 conf
.CHECK_FUNCS('gettext dgettext bindtextdomain textdomain')
90 #FIXME: for some reason this one still fails
91 conf
.CHECK_FUNCS_IN('yp_get_default_domain', 'nsl')
92 conf
.CHECK_FUNCS_IN('dn_expand _dn_expand __dn_expand', 'resolv')
94 # Check for inotify support
95 conf
.CHECK_HEADERS('linux/inotify.h asm/unistd.h sys/inotify.h')
96 conf
.CHECK_FUNCS('inotify_init')
97 if "HAVE_LINUX_INOTIFY_H" in conf
.env
and "HAVE_INOTIFY_INIT" in conf
.env
:
98 conf
.DEFINE('HAVE_INOTIFY', 1)
100 # Check for kernel change notify support
103 #define F_NOTIFY 1026
106 exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ? 1 : 0);
107 }''', 'HAVE_KERNEL_CHANGE_NOTIFY', addmain
=False, execute
=True,
108 headers
='fcntl.h signal.h',
109 msg
="Checking for kernel change notify support")
111 # Check for Linux kernel oplocks
113 #include <sys/types.h>
117 #define F_NOTIFY 1026
120 exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ? 1 : 0);
121 }''', 'HAVE_KERNEL_OPLOCKS_LINUX', addmain
=False, execute
=True,
122 msg
="Checking for Linux kernel oplocks")
124 # Check for IRIX kernel oplock types
125 conf
.CHECK_CODE('oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;',
126 'HAVE_KERNEL_OPLOCKS_IRIX', headers
='fcntl.h',
127 msg
="Checking for IRIX kernel oplock types")
129 # Check for krenel share modes
131 #include <sys/types.h>
134 #include <sys/file.h>
140 exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
141 }''', 'HAVE_KERNEL_SHARE_MODES', addmain
=False, execute
=True,
142 msg
="Checking for krenel share modes")
144 # Check for various members of the stat structure
145 conf
.CHECK_TYPES('blksize_t blkcnt_t')
146 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_blocks', define
='HAVE_STAT_ST_BLOCKS',
147 headers
='sys/stat.h')
148 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_blksize', define
='HAVE_STAT_ST_BLKSIZE',
149 headers
='sys/stat.h')
151 # Check for POSIX capability support
152 conf
.CHECK_FUNCS_IN('cap_get_proc', 'cap', headers
='sys/capability.h')
154 if "HAVE_SYS_CAPABILITY_H" in conf
.env
:
158 if (!(cap = cap_get_proc())) exit(1);
160 cap_set_flag(cap, CAP_INHERITABLE, 1, vals, CAP_CLEAR);
161 cap_set_proc(cap);''',
162 'HAVE_POSIX_CAPABILITIES', execute
=True, lib
="cap",
163 headers
='sys/capability.h',
164 msg
="Checking whether POSIX capabilities are available")
166 # Check for int16, uint16, int32 and uint32 in rpc/types.h included from
167 # rpc/rpc.h. This is *really* broken but some systems (DEC OSF1) do this.
169 if conf
.CONFIG_SET("HAVE_RPC_RPC_H"):
170 conf
.CHECK_TYPE('int16', headers
='rpc/rpc.h',
171 define
='HAVE_INT16_FROM_RPC_RPC_H',
172 msg
="Checking for int16 typedef included by rpc/rpc.h")
173 conf
.CHECK_CODE('uint16 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
174 headers
='sys/types.h rpc/rpc.h',
175 msg
="Checking for uint16 typedef included by rpc/rpc.h")
176 conf
.CHECK_CODE('int32 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
177 headers
='sys/types.h rpc/rpc.h',
178 msg
="Checking for int32 typedef included by rpc/rpc.h")
179 conf
.CHECK_CODE('uint32 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
180 headers
='sys/types.h rpc/rpc.h',
181 msg
="Checking for uint32 typedef included by rpc/rpc.h")
183 # Check if the compiler will optimize out functions
186 this_function_does_not_exist();
189 }''', 'HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS',
190 msg
="Checking if the compiler will optimize out functions")
193 _acl __acl add_proplist_entry atexit attr_getf attr_list attr_listf
194 attropen attr_remove attr_removef attr_set attr_setf backtrace_symbols
195 bindtextdomain _chdir __chdir chflags chmod _close __close _closedir
196 __closedir closedir64 creat64 crypt16 delproplist devnm dgettext dirfd
197 DNSServiceRegister _dup __dup _dup2 __dup2 endmntent endnetgrent execl
198 extattr_delete_fd extattr_delete_link extattr_get_fd extattr_get_file
199 extattr_get_link extattr_list_fd extattr_list_file extattr_list_link
200 extattr_set_fd extattr_set_file extattr_set_link _facl __facl _fchdir
201 __fchdir fchmod fchown _fcntl __fcntl fcvt fcvtl fdatasync
202 fdelproplist fgetea fgetproplist fgetxattr flistea flistxattr fopen64
203 _fork __fork fremoveea fremovexattr fseek64 fseeko64 fsetea
204 fsetproplist fsetxattr _fstat __fstat fstat64 _fstat64 __fstat64 fsync
205 ftell64 ftello64 ftruncate64 futimens futimes __fxstat getauthuid
206 getcwd _getcwd __getcwd getdents __getdents getdents64 getdirentries
207 getgrent getgrnam getgrouplist getmntent getnetgrent getpagesize
208 getproplist get_proplist_entry getpwanam getpwent_r getrlimit gettext
209 getutmpx getutxent glob grantpt hstrerror initgroups innetgr
210 inotify_init lgetea lgetxattr listea listxattr llistea llistxattr
211 llseek _llseek __llseek lremoveea lremovexattr _lseek __lseek lseek64
212 lsetea lsetxattr _lstat __lstat lstat64 _lstat64 __lstat64 lutimes
213 __lxstat memalign mknod mknod64 mlock mlockall munlock munlockall
214 nl_langinfo _open __open open64 _open64 __open64 _opendir __opendir
215 opendir64 pathconf poll posix_fallocate posix_fallocate64
216 posix_memalign prctl pread _pread __pread pread64 _pread64 __pread64
217 pututline pututxline pwrite _pwrite __pwrite pwrite64 _pwrite64
218 __pwrite64 rdchk _read __read _readdir __readdir readdir64 _readdir64
219 __readdir64 removeea removexattr rewinddir64 _seekdir __seekdir
220 seekdir64 select setea setenv setgidx setgroups setlocale setluid
221 setmntent setnetgrent setpgid setpriv setproplist setsid setuidx
222 setxattr shmget shm_open sigaction sigblock sigprocmask sigset
223 sizeof_proplist_entry _stat __stat stat64 _stat64 __stat64 statvfs
224 strcasecmp strchr strpbrk strsignal strtol strupr sysconf sysctlbyname
225 __sys_llseek syslog _telldir __telldir telldir64 textdomain timegm
226 updwtmp updwtmpx utimensat vsyslog _write __write __xstat
229 conf
.CHECK_TYPE('struct timespec', headers
='sys/time.h time.h')
231 conf
.CHECK_SAMBA3_CHARSET() # see build/charset.py
234 default_static_modules
=TO_LIST('''pdb_smbpasswd pdb_tdbsam pdb_wbc_sam rpc_lsarpc rpc_samr
235 rpc_winreg rpc_initshutdown rpc_dssetup rpc_wkssvc rpc_svcctl
236 rpc_ntsvcs rpc_netlogon rpc_netdfs rpc_srvsvc rpc_spoolss
237 rpc_eventlog auth_sam auth_unix auth_winbind auth_wbc auth_server
238 auth_domain auth_builtin auth_netlogond vfs_default
239 nss_info_template''')
241 default_shared_modules
=TO_LIST('''vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk
242 vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap
243 vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2 charset_CP850
244 charset_CP437 auth_script vfs_readahead vfs_xattr_tdb
245 vfs_streams_xattr vfs_streams_depot vfs_acl_xattr vfs_acl_tdb
246 vfs_smb_traffic_analyzer vfs_preopen vfs_catia vfs_scannedonly
249 if Options
.options
.developer
:
250 default_static_modules
.extend(TO_LIST('rpc_rpcecho pdb_ads'))
251 default_shared_modules
.extend(TO_LIST('charset_weird perfcount_test'))
253 move_to_shared
= TO_LIST(Options
.options
.shared_modules
)
254 move_to_static
= TO_LIST(Options
.options
.static_modules
)
256 for m
in move_to_static
:
257 if m
in default_shared_modules
:
258 default_shared_modules
.remove(m
)
259 default_static_modules
.append(m
)
260 for m
in move_to_shared
:
261 if m
in default_static_modules
:
262 default_static_modules
.remove(m
)
263 default_shared_modules
.append(m
)
265 conf
.DEFINE('STRING_STATIC_MODULES', ' '.join(default_static_modules
), quote
=True)
269 prefixes
= ['vfs', 'pdb', 'rpc', 'auth', 'nss_info', 'charset', 'idmap']
271 for m
in default_static_modules
:
273 if not p
in static_list
:
275 static_list
[p
].append(m
)
278 conf
.env
['%s_STATIC' % p
.upper()] = ''
279 conf
.env
['%s_SHARED' % p
.upper()] = ''
281 conf
.DEFINE('static_init_%s' % p
, '{ %s_init(); }' % '_init(); '.join(static_list
[p
]))
283 conf
.DEFINE('static_init_%s' % p
, '{}')
285 if Options
.options
.with_winbind
:
286 conf
.DEFINE('WITH_WINBIND', '1')
288 #FIXME: Should just be set when krb5 and ldap requirements are fulfilled
289 if Options
.options
.with_ads
:
290 conf
.DEFINE('WITH_ADS', '1')
293 conf
.find_program('cups-config', var
='CUPS_CONFIG')
294 if conf
.env
.CUPS_CONFIG
and Options
.options
.with_cups
:
295 conf
.check_cfg(path
="cups-config", args
="--cflags --ldflags --libs",
296 package
="", uselib_store
="cups")
297 conf
.CHECK_HEADERS('cups/cups.h cups/language.h', lib
='cups')
298 conf
.CHECK_LIB('cups')
300 # define an empty subsystem for cups, to allow it to be used as an empty dependency
301 conf
.SET_TARGET_TYPE('cups', 'EMPTY')
304 if Options
.options
.with_ldap
:
305 conf
.CHECK_HEADERS('ldap.h lber.h')
306 conf
.CHECK_TYPE('ber_tag_t', 'unsigned int', headers
='ldap.h lber.h')
307 conf
.CHECK_FUNCS_IN('ber_scanf ber_sockbuf_add_io', 'lber')
308 conf
.CHECK_VARIABLE('LDAP_OPT_SOCKBUF', headers
='ldap.h')
309 # if ber_sockbuf_add_io() and LDAP_OPT_SOCKBUF are available, we can add
310 # SASL wrapping hooks
311 if conf
.CONFIG_SET('HAVE_BER_SOCKBUF_ADD_IO') and \
312 conf
.CONFIG_SET('HAVE_LDAP_OPT_SOCKBUF'):
313 conf
.DEFINE('HAVE_LDAP_SASL_WRAPPING', '1')
315 # if we LBER_OPT_LOG_PRINT_FN we can intercept ldap logging and print it out
317 conf
.CHECK_VARIABLE('LBER_OPT_LOG_PRINT_FN',
318 define
='HAVE_LBER_LOG_PRINT_FN', headers
='lber.h')
320 conf
.CHECK_FUNCS_IN('ldap_init ldap_initialize ldap_set_rebind_proc', 'ldap')
321 conf
.CHECK_FUNCS_IN('ldap_add_result_entry', 'ldap')
323 # Check if ldap_set_rebind_proc() takes three arguments
324 if conf
.CHECK_CODE('ldap_set_rebind_proc(0, 0, 0)',
325 'LDAP_SET_REBIND_PROC_ARGS',
326 msg
="Checking whether ldap_set_rebind_proc takes 3 arguments",
327 headers
='ldap.h lber.h', link
=False):
328 conf
.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '3')
330 conf
.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '2')
332 # last but not least, if ldap_init() exists, we want to use ldap
333 if conf
.CONFIG_SET('HAVE_LDAP_INIT'):
334 conf
.DEFINE('HAVE_LDAP', '1')
335 conf
.DEFINE('LDAP_DEPRECATED', '1')
336 conf
.env
['SMBLDAP'] = 'lib/smbldap.c'
337 conf
.env
['SMBLDAPUTIL'] = 'lib/smbldap_util.c'
339 conf
.SET_TARGET_TYPE('ldap', 'EMPTY')
340 conf
.SET_TARGET_TYPE('lber', 'EMPTY')
343 conf
.find_program('krb5-config', var
='KRB5_CONFIG')
344 if conf
.env
.KRB5_CONFIG
and Options
.options
.with_krb5
:
345 conf
.check_cfg(path
="krb5-config", args
="--cflags --libs",
346 package
="gssapi", uselib_store
="krb5")
347 conf
.CHECK_HEADERS('krb5.h krb5/locate_plugin.h', lib
='krb5')
348 conf
.CHECK_HEADERS('gssapi.h gssapi/gssapi_generic.h gssapi/gssapi.h com_err.h', lib
='krb5')
350 if conf
.CONFIG_SET('HAVE_KRB5_LOCATE_PLUGIN_H'):
351 conf
.env
['WINBIND_KRB5_LOCATOR'] = 'bin/winbind_krb5_locator.so'
353 # Check for KRB5_DEPRECATED handling
354 conf
.CHECK_CODE('''#define KRB5_DEPRECATED 1
355 #include <krb5.h>''',
356 'HAVE_KRB5_DEPRECATED_WITH_IDENTIFIER', addmain
=False,
358 msg
="Checking for KRB5_DEPRECATED define taking an identifier")
360 conf
.CHECK_FUNCS_IN('_et_list', 'com_err')
361 conf
.CHECK_FUNCS_IN('krb5_encrypt_data', 'k5crypto')
362 conf
.CHECK_FUNCS_IN('crypto', 'des_set_key')
363 conf
.CHECK_FUNCS_IN('copy_Authenticator', 'asn1')
364 conf
.CHECK_FUNCS_IN('roken_getaddrinfo_hostspec', 'roken')
365 conf
.CHECK_FUNCS_IN('gss_display_status', 'gssapi gssapi_krb5')
366 conf
.CHECK_FUNCS_IN('krb5_mk_req_extended krb5_kt_compare', 'krb5')
368 krb5_set_real_time krb5_set_default_in_tkt_etypes krb5_set_default_tgs_enctypes
369 krb5_set_default_tgs_ktypes krb5_principal2salt krb5_use_enctype
370 krb5_string_to_key krb5_get_pw_salt krb5_string_to_key_salt krb5_auth_con_setkey
371 krb5_auth_con_setuseruserkey krb5_locate_kdc krb5_get_permitted_enctypes
372 krb5_get_default_in_tkt_etypes krb5_free_data_contents
373 krb5_principal_get_comp_string krb5_free_unparsed_name
374 krb5_free_keytab_entry_contents krb5_kt_free_entry krb5_krbhst_init
375 krb5_krbhst_get_addrinfo krb5_c_enctype_compare krb5_enctypes_compatible_keys
376 krb5_crypto_init krb5_crypto_destroy krb5_decode_ap_req free_AP_REQ
377 krb5_verify_checksum krb5_c_verify_checksum krb5_principal_compare_any_realm
378 krb5_parse_name_norealm krb5_princ_size krb5_get_init_creds_opt_set_pac_request
379 krb5_get_renewed_creds krb5_get_kdc_cred krb5_free_error_contents
380 initialize_krb5_error_table krb5_get_init_creds_opt_alloc
381 krb5_get_init_creds_opt_free krb5_get_init_creds_opt_get_error
382 krb5_enctype_to_string krb5_fwd_tgt_creds krb5_auth_con_set_req_cksumtype
383 krb5_get_creds_opt_alloc krb5_get_creds_opt_set_impersonate krb5_get_creds
384 krb5_get_credentials_for_user krb5_get_host_realm krb5_free_host_realm''',
386 conf
.CHECK_DECLS('''krb5_get_credentials_for_user
387 krb5_auth_con_set_req_cksumtype''',
388 headers
='krb5.h', always
=True)
390 conf
.SET_TARGET_TYPE('krb5', 'EMPTY')
391 conf
.SET_TARGET_TYPE('gssapi', 'EMPTY')
392 conf
.SET_TARGET_TYPE('gssapi_krb5', 'EMPTY')
394 conf
.SAMBA_CONFIG_H('include/config.h')
397 "build 'tags' file using ctags"
399 source_root
= os
.path
.dirname(Utils
.g_module
.root_path
)
400 cmd
= 'ctags $(find %s/.. -name "*.[ch]" | grep -v "*_proto\.h")' % source_root
401 print("Running: %s" % cmd
)