diff options
Diffstat (limited to '')
-rw-r--r-- | lib/util/wscript | 32 | ||||
-rw-r--r-- | lib/util/wscript_build | 402 | ||||
-rw-r--r-- | lib/util/wscript_configure | 177 |
3 files changed, 611 insertions, 0 deletions
diff --git a/lib/util/wscript b/lib/util/wscript new file mode 100644 index 0000000..425f659 --- /dev/null +++ b/lib/util/wscript @@ -0,0 +1,32 @@ +def options(opt): + ''' This is a bit strange, but disable is the flag, not enable. ''' + opt.add_option('--disable-fault-handling', action='store_true', dest='disable_fault_handling', help=('disable the fault handlers'), default=False) + + # We do not want libunwind by default (backtrace_symbols() in + # glibc is better) but allow (eg) IA-64 to build with it where it + # might be better (per old comment in fault.c) + opt.samba_add_onoff_option('libunwind', + default=None, + help='''Use libunwind instead of the default backtrace_symbols() + from libc, for example on IA-64 where it might give a better + backtrace.''') + + opt.add_option('--with-systemd', + help=("Enable systemd integration"), + action='store_true', dest='enable_systemd') + + opt.add_option('--without-systemd', + help=("Disable systemd integration"), + action='store_false', dest='enable_systemd') + + opt.add_option('--with-lttng', + help=("Enable lttng integration"), + action='store_true', dest='enable_lttng') + + opt.add_option('--without-lttng', + help=("Disable lttng integration"), + action='store_false', dest='enable_lttng') + + opt.add_option('--with-gpfs', + help=("Directory under which gpfs headers are installed"), + action="store", dest='gpfs_headers_dir') diff --git a/lib/util/wscript_build b/lib/util/wscript_build new file mode 100644 index 0000000..d26aa4e --- /dev/null +++ b/lib/util/wscript_build @@ -0,0 +1,402 @@ +#!/usr/bin/env python + +# Please add any new SAMBA_SUBSYSTEM/SAMBA_LIBRARY to the bottom of the file +# unless they are also required to build standalone ctdb. + +bld.SAMBA_LIBRARY('time-basic', + source='time_basic.c', + deps='replace', + private_library=True, + local_include=False) + +bld.SAMBA_SUBSYSTEM('tini', + source='tini.c', + provide_builtin_linking=True, + local_include=False) + +bld.SAMBA_SUBSYSTEM('tiniparser', + source='tiniparser.c', + deps='tini', + provide_builtin_linking=True, + local_include=False) + +bld.SAMBA_SUBSYSTEM('strv', + source='strv.c', + deps='talloc', + local_include=False) + +bld.SAMBA_SUBSYSTEM('close-low-fd', + source='close_low_fd.c', + deps='replace', + local_include=False) + +bld.SAMBA_LIBRARY('sys_rw', + source='sys_rw.c sys_rw_data.c', + deps='replace iov_buf', + local_include=False, + private_library=True) + +samba_debug_add_deps = '' +samba_debug_add_inc = '' + +if bld.CONFIG_SET('HAVE_GPFS'): + bld.SAMBA_SUBSYSTEM('gpfswrap', + source='gpfswrap.c', + deps='replace', + local_include=False, + includes=bld.CONFIG_GET('CPPPATH_GPFS')) + samba_debug_add_deps += ' gpfswrap' + samba_debug_add_inc += bld.CONFIG_GET('CPPPATH_GPFS') + +bld.SAMBA_LIBRARY('samba-debug', + source='debug.c', + deps='replace time-basic close-low-fd talloc socket-blocking' + samba_debug_add_deps, + public_deps='systemd systemd-journal lttng-ust', + local_include=False, + includes='lib/util/debug-classes ' + samba_debug_add_inc, + private_library=True) + +bld.SAMBA_LIBRARY('socket-blocking', + source='blocking.c', + local_include=False, + private_library=True) + +bld.SAMBA_LIBRARY('talloc_report', + source='talloc_report.c', + local_include=False, + public_deps='talloc', + private_library=True + ) + +bld.SAMBA_LIBRARY('talloc_report_printf', + source='talloc_report_printf.c', + local_include=False, + public_deps='talloc', + private_library=True + ) + +bld.SAMBA_SUBSYSTEM('smb-panic', + source=''' + fault.c + signal.c + ''', + deps=''' + replace + samba-debug + LIBUNWIND + execinfo + ''', + local_include=False) + +bld.SAMBA_SUBSYSTEM('samba-util-core', + source=''' + data_blob.c + util_file.c + sys_popen.c + time.c + util.c + idtree.c + substitute.c + util_process.c + util_strlist.c + strv_util.c + bitmap.c + select.c + pidfile.c + become_daemon.c + mkdir_p.c + ''', + deps=''' + time-basic + samba-debug + socket-blocking + talloc + tevent + execinfo + pthread + strv + tini + smb_strtox + smb-panic + gnutls + ''', + public_deps='systemd systemd-daemon sys_rw', + local_include=False) + +bld.SAMBA_SUBSYSTEM('smb_strtox', + source='smb_strtox.c', + provide_builtin_linking=True, + local_include=False) + + +bld.SAMBA_LIBRARY('iov_buf', + source='iov_buf.c', + deps='talloc', + local_include=False, + private_library=True) + +bld.SAMBA_LIBRARY('msghdr', + source='msghdr.c', + deps='replace iov_buf', + local_include=False, + private_library=True) + +bld.SAMBA_LIBRARY('genrand', + source='genrand.c', + deps='replace gnutls smb-panic', + local_include=False, + private_library=True) + +if bld.env.SAMBA_UTIL_CORE_ONLY: + + bld.SAMBA_LIBRARY('tevent-util', + source='tevent_unix.c', + local_include=False, + deps='tevent', + private_library=True) + +else: + + bld.env.public_headers_skip.append('charset_compat.h') + + bld.SAMBA_BINARY('genrandperf', + source='tests/genrandperf.c', + deps='genrand replace', + local_include=False, + install=False) + + # TODO: Rewrite ms_fnmatch_core() for a better API. + ms_fnmatch_cflags='' + if bld.CONFIG_SET('HAVE_WNO_ERROR_ARRAY_BOUNDS'): + ms_fnmatch_cflags='-Wno-error=array-bounds' + bld.SAMBA_SUBSYSTEM('SAMBA_UTIL_MS_FNMATCH', + source='ms_fnmatch.c', + deps='talloc', + cflags=ms_fnmatch_cflags, + local_include=False) + + bld.SAMBA_LIBRARY('samba-util', + source=''' + base64.c + dprintf.c + fsusage.c + genrand_util.c + getpass.c + idtree_random.c + memcache.c + params.c + rbtree.c + rfc1738.c + server_id.c + smb_threads.c + system.c + talloc_keep_secret.c + talloc_stack.c + tevent_debug.c + tfork.c + tftw.c + unix_match.c + util_id.c + util_net.c + util_paths.c + util_str.c + util_str_common.c + util_strlist_v3.c + ''', + deps=''' + samba-util-core + DYNCONFIG + close-low-fd + tiniparser + genrand + util_str_hex + SAMBA_UTIL_MS_FNMATCH + ''', + public_deps='talloc tevent execinfo pthread LIBCRYPTO charset util_setid', + public_headers=''' + attr.h + data_blob.h + debug.h + discard.h + time.h + idtree.h + idtree_random.h + blocking.h + signal.h + substitute.h + fault.h + genrand.h + tfork.h + ''', + header_path= [ ('dlinklist.h samba_util.h', '.'), ('*', 'util') ], + local_include=False, + vnum='0.0.1', + pc_files='samba-util.pc' + ) + + bld.SAMBA_LIBRARY('samba-modules', + source='modules.c', + deps='samba-errors samba-util', + local_include=False, + private_library=True) + + bld.SAMBA_LIBRARY('asn1util', + source='asn1.c', + deps='talloc samba-util', + private_library=True, + local_include=False) + + + bld.SAMBA_SUBSYSTEM('UNIX_PRIVS', + source='unix_privs.c', + autoproto='unix_privs.h', + deps='replace talloc', + local_include=False, + ) + + + bld.SAMBA_LIBRARY('util_tdb', + source='util_tdb.c', + local_include=False, + public_deps='tdb talloc', + private_library=True + ) + + bld.SAMBA_LIBRARY('tevent-util', + source=''' + tevent_unix.c + tevent_ntstatus.c + tevent_werror.c + tevent_req_profile.c + ''', + local_include=False, + public_deps='tevent samba-errors', + public_headers='tevent_ntstatus.h tevent_unix.h tevent_werror.h', + header_path=[ ('*', 'util') ], + pc_files=[], + vnum='0.0.1' + ) + + bld.SAMBA_LIBRARY('util_setid', + source='setid.c', + local_include=False, + private_library=True + ) + + bld.SAMBA_SUBSYSTEM('util_ldb', + source='util_ldb.c', + local_include=False, + public_deps='ldb', + public_headers='util_ldb.h' + ) + + + bld.SAMBA_SUBSYSTEM('UTIL_RUNCMD', + source='util_runcmd.c', + local_include=False, + public_deps='tevent' + ) + + bld.SAMBA_SUBSYSTEM('UTIL_PW', + source='util_pw.c', + local_include=False, + public_deps='talloc' + ) + + bld.SAMBA_LIBRARY('server_id_db', + source='server_id_db.c', + deps='talloc tdb strv util_tdb tdb-wrap samba-util', + local_include=False, + private_library=True) + + bld.SAMBA_SUBSYSTEM('access', + source='access.c', + deps='interfaces samba-util', + local_include=False) + + bld.SAMBA_SUBSYSTEM('util_str_escape', + source='util_str_escape.c', + deps='talloc', + local_include=False) + + bld.SAMBA_SUBSYSTEM('util_str_hex', + source='util_str_hex.c', + deps='talloc', + local_include=False) + + bld.SAMBA_BINARY('test_rfc1738', + source='tests/rfc1738.c', + deps='cmocka replace samba-util', + local_include=False, + for_selftest=True) + + bld.SAMBA_BINARY('test_ms_fnmatch', + source='tests/test_ms_fnmatch.c', + deps='cmocka replace samba-util', + local_include=False, + for_selftest=True) + + bld.SAMBA_BINARY('test_talloc_keep_secret', + source='tests/test_talloc_keep_secret.c', + deps='cmocka replace samba-util', + local_include=False, + for_selftest=True) + + bld.SAMBA_BINARY('test_byteorder', + source='tests/test_byteorder.c', + deps='cmocka replace samba-util', + local_include=False, + for_selftest=True) + + bld.SAMBA_BINARY('test_bytearray', + source='tests/test_bytearray.c', + deps='cmocka replace samba-util', + local_include=False, + for_selftest=True) + + bld.SAMBA_BINARY('test_byteorder_verify', + source='tests/test_byteorder_verify.c', + deps='cmocka replace samba-util', + local_include=False, + for_selftest=True) + + bld.SAMBA_BINARY('test_util_paths', + source='tests/test_util_paths.c', + deps='cmocka replace talloc samba-util', + local_include=False, + for_selftest=True) + + bld.SAMBA_BINARY('test_util', + source='tests/test_util.c', + deps='cmocka replace talloc samba-util', + local_include=False, + for_selftest=True) + + bld.SAMBA_BINARY('test_memcache', + source='tests/test_memcache.c', + deps='cmocka replace talloc samba-util', + local_include=False, + for_selftest=True) + + bld.SAMBA_BINARY('test_sys_rw', + source='tests/test_sys_rw.c', + deps='cmocka replace samba-util', + local_include=False, + for_selftest=True) + + bld.SAMBA_BINARY('test_s4_logging', + source='tests/test_logging.c', + deps=' '.join(['CMDLINE_S4', + 'samba-util', + 'popt']), + local_include=False, + for_selftest=True) + + bld.SAMBA_BINARY('test_s3_logging', + source='tests/test_logging.c', + deps=' '.join(['CMDLINE_S3', + 'samba-util', + 'popt']), + cflags="-D USING_CMDLINE_S3", + local_include=False, + for_selftest=True) diff --git a/lib/util/wscript_configure b/lib/util/wscript_configure new file mode 100644 index 0000000..fbaeb09 --- /dev/null +++ b/lib/util/wscript_configure @@ -0,0 +1,177 @@ +#!/usr/bin/env python +from waflib import Logs, Options, Errors + +import os, sys + +if Options.options.disable_fault_handling: + conf.DEFINE('HAVE_DISABLE_FAULT_HANDLING',1) + +# backtrace could be in libexecinfo or in libc. +# This is our preferred backtrace handler (more useful output than libunwind as at Ubuntu 20.04 x86_64) +conf.CHECK_FUNCS_IN('backtrace backtrace_symbols', 'execinfo', checklibc=True, headers='execinfo.h') +conf.CHECK_HEADERS('execinfo.h') + +conf.SET_TARGET_TYPE('LIBUNWIND', 'EMPTY') +if Options.options.with_libunwind: + if conf.check_cfg(package='libunwind-generic', + args='--cflags --libs', + msg='Checking for libunwind', + uselib_store='LIBUNWIND', + mandatory=False): + if conf.CHECK_HEADERS('libunwind.h'): + conf.SET_TARGET_TYPE('LIBUNWIND', 'SYSLIB') + else: + raise Errors.WafError('--with-libunwind specified but libunwind not found') +elif Options.options.with_libunwind == None: + if not conf.CONFIG_SET('HAVE_BACKTRACE_SYMBOLS') \ + and not Options.options.disable_fault_handling: + raise Errors.WafError( +'''backtrace_symbols() not found but +--with-libunwind not specified. +Use --without-libunwind to build without internal backtrace support or +--disable-fault-handling to totally defer fault handling to the OS.''') + +conf.CHECK_STRUCTURE_MEMBER('struct statvfs', 'f_frsize', define='HAVE_FRSIZE', headers='sys/statvfs.h') + +# all the different ways of doing statfs +statfs_types = [ + ( 'STAT_STATVFS', + 'statvfs (SVR4)', + 'struct statvfs fsd; exit(statvfs(0, &fsd))', + 'sys/statvfs.h' ), + + ( 'STAT_STATFS3_OSF1', + '3-argument statfs function (DEC OSF/1)', + 'struct statfs fsd; fsd.f_fsize = 0; exit(statfs(".", &fsd, sizeof(struct statfs)))', + 'sys/param.h sys/mount.h' ), + + ( 'STAT_STATFS2_BSIZE', + 'two-argument statfs with statfs.bsize', + 'struct statfs fsd; fsd.f_bsize = 0; exit(statfs(".", &fsd))', + 'sys/param.h sys/mount.h sys/vfs.h' ), + + ( 'STAT_STATFS4', + 'four-argument statfs (AIX-3.2.5, SVR3)', + 'struct statfs fsd; exit(statfs(".", &fsd, sizeof fsd, 0))', + 'sys/statfs.h' ), + + ( 'STAT_STATFS2_FSIZE', + 'two-argument statfs with statfs.fsize', + 'struct statfs fsd; fsd.f_fsize = 0; exit(statfs(".", &fsd))', + 'sys/param.h sys/mount.h' ), + + ( 'STAT_STATFS2_FS_DATA', + 'two-argument statfs with struct fs_data (Ultrix)', + 'struct fs_data fsd; exit(statfs(".", &fsd) != 1)', + 'sys/param.h sys/mount.h sys/fs_types.h' ) +] + +found_statfs=False +for (define, msg, code, headers) in statfs_types: + if conf.CHECK_CODE(code, + define=define, + headers=headers, + msg='Checking for %s' % msg, + local_include=False): + found_statfs=True + break + +if not found_statfs: + print("FATAL: Failed to find a statfs method") + raise + +conf.CHECK_CODE("""struct statfs fsd; + fsd.f_bsize = 0; + fsd.f_iosize = 0; + return (statfs (".", &fsd)); + """, + headers='sys/param.h sys/mount.h sys/vfs.h', + define='BSD_STYLE_STATVFS', + msg='Checking for *bsd style statfs with statfs.f_iosize', + execute=True, + local_include=False) + +conf.CHECK_CODE('struct statvfs buf; buf.f_fsid = 0', + define='HAVE_FSID_INT', + msg='Checking if f_fsid is an integer', + execute=False, + local_include=False, + headers='sys/statvfs.h') + +# fsusage.c assumes that statvfs has an f_frsize entry. Some weird +# systems use f_bsize. +conf.CHECK_CODE('struct statvfs buf; buf.f_frsize = 0', + define='HAVE_FRSIZE', + msg='Checking that statvfs.f_frsize works', + headers='sys/statvfs.h', + execute=False, + local_include=False) + +# Some systems use f_flag in struct statvfs while others use f_flags +conf.CHECK_CODE('struct statvfs buf; buf.f_flag = 0', + define='HAVE_STATVFS_F_FLAG', + msg='Checking whether statvfs.f_flag exists', + headers='sys/statvfs.h', + local_include=False, + execute=False) + +conf.CHECK_CODE('struct statvfs buf; buf.f_flags = 0', + define='HAVE_STATVFS_F_FLAGS', + msg='Checking whether statvfs.f_flags exists', + headers='sys/statvfs.h', + local_include=False, + execute=False) + +# +# systemd removed the libsystemd-daemon and libsystemd-journal libraries. In newer +# versions it is only libsystemd. As waf pkg-config handling does not provide +# targets which could be used as a dependency based on the package name we need +# to look for them on our own. This enabled one of the library targets based on +# which version we detect. +# +conf.SET_TARGET_TYPE('systemd-daemon', 'EMPTY') +conf.SET_TARGET_TYPE('systemd-journal', 'EMPTY') +conf.SET_TARGET_TYPE('systemd', 'EMPTY') + +if Options.options.enable_systemd != False: + r_daemon = conf.CHECK_CFG(package='libsystemd-daemon', args='--cflags --libs', + msg='Checking for libsystemd-daemon') + r_journal = conf.CHECK_CFG(package='libsystemd-journal', args='--cflags --libs', + msg='Checking for libsystemd-journal') + if r_daemon is None and r_journal is None: + conf.CHECK_CFG(package='libsystemd', args='--cflags --libs', + msg='Checking for libsystemd') + conf.CHECK_LIB('systemd', shlib=True) + else: + conf.CHECK_LIB('systemd-daemon', shlib=True) + conf.CHECK_LIB('systemd-journal', shlib=True) + +conf.SET_TARGET_TYPE('lttng-ust', 'EMPTY') + +if Options.options.enable_lttng != False: + conf.CHECK_CFG(package='lttng-ust', args='--cflags --libs', + msg='Checking for lttng-ust', uselib_store="LTTNG-UST") + conf.CHECK_HEADERS('lttng/tracef.h', lib='lttng-st') + conf.CHECK_LIB('lttng-ust', shlib=True) + +if (conf.CONFIG_SET('HAVE_LTTNG_TRACEF_H') and + conf.CONFIG_SET('HAVE_LTTNG_UST')): + conf.DEFINE('HAVE_LTTNG_TRACEF', '1') + conf.env['HAVE_LTTNG_TRACEF'] = True + +if Options.options.gpfs_headers_dir: + conf.env['CPPPATH_GPFS'] = Options.options.gpfs_headers_dir + if conf.CHECK_HEADERS('gpfs.h', False, False, "gpfs"): + Logs.info('Using gpfs.h from %s' % Options.options.gpfs_headers_dir) + conf.DEFINE('HAVE_GPFS', '1') +else: + conf.env['CPPPATH_GPFS'] = "/usr/lpp/mmfs/include/" + if conf.CHECK_HEADERS('gpfs.h', False, False, "gpfs"): + Logs.info('Using gpfs.h from installed gpfs package.') + conf.DEFINE('HAVE_GPFS', '1') + else: + if sys.platform.startswith('linux'): + conf.env['CPPPATH_GPFS'] = os.path.abspath("third_party/gpfs") + if conf.CHECK_HEADERS('gpfs.h', False, False, "gpfs"): + Logs.info('Using gpfs.h from third_party directory.') + conf.DEFINE('HAVE_GPFS', '1') |