From 07b3a048724a6b41282e1f673aea5ce2c1202a5e Mon Sep 17 00:00:00 2001 From: Christian Ambach Date: Thu, 1 Aug 2013 22:28:05 +0200 Subject: waf: consolidate libintl related checks consolidate the dealing with functions from libintl and the handling of checking if libiconv is required or not to a common place in lib/replace also add a new samba_intl subsystem that has dependencies on the appropriate set of libraries (libintl, libintl+libiconv or none) that can be used as a general dependency by code that depends on the internationalization libraries Signed-off-by: Christian Ambach Reviewed-by: Andrew Bartlett --- lib/replace/wscript | 46 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 10 deletions(-) (limited to 'lib/replace') diff --git a/lib/replace/wscript b/lib/replace/wscript index 2117f56e22..b6fb10b9b0 100644 --- a/lib/replace/wscript +++ b/lib/replace/wscript @@ -89,7 +89,7 @@ struct foo bar = { .y = 'X', .x = 1 }; sys/sockio.h sys/un.h''', together=True) conf.CHECK_HEADERS('sys/uio.h ifaddrs.h direct.h dirent.h') conf.CHECK_HEADERS('windows.h winsock2.h ws2tcpip.h') - conf.CHECK_HEADERS('libintl.h errno.h') + conf.CHECK_HEADERS('errno.h') conf.CHECK_HEADERS('gcrypt.h getopt.h iconv.h') conf.CHECK_HEADERS('sys/inotify.h memory.h nss.h sasl/sasl.h') conf.CHECK_HEADERS('security/pam_appl.h zlib.h asm/unistd.h') @@ -363,17 +363,41 @@ removeea setea headers='netinet/in.h arpa/nameser.h resolv.h') - if not conf.CHECK_FUNCS_IN('gettext', 'intl', checklibc=True, headers='libintl.h'): - # Some hosts need lib iconv for linking with lib intl - # So we try with flags just in case it helps. - oldflags = conf.env['LDFLAGS_INTL'] - conf.env['LDFLAGS_INTL'] = "-liconv" - if not conf.CHECK_LIB('intl'): - conf.env['LDFLAGS_INTL'] = oldflags + conf.env.intl_libs='' + if not Options.options.disable_gettext: + conf.CHECK_HEADERS('libintl.h') + conf.CHECK_LIB('intl') + # *textdomain functions are not strictly necessary + conf.CHECK_FUNCS_IN('bindtextdomain textdomain bind_textdomain_codeset', + '', checklibc=True, headers='libintl.h') + # gettext and dgettext must exist + # on some systems (the ones with glibc, those are in libc) + if conf.CHECK_FUNCS_IN('dgettext gettext', '', checklibc=True, headers='libintl.h'): + # save for dependency definitions + conf.env.intl_libs='' + # others (e.g. FreeBSD) have seperate libintl + elif conf.CHECK_FUNCS_IN('dgettext gettext', 'intl', checklibc=False, headers='libintl.h'): + # save for dependency definitions + conf.env.intl_libs='intl' + # recheck with libintl + conf.CHECK_FUNCS_IN('bindtextdomain textdomain bind_textdomain_codeset', + 'intl', checklibc=False, headers='libintl.h') else: - conf.CHECK_FUNCS_IN('gettext', 'intl', checklibc=True, headers='libintl.h') + # Some hosts need lib iconv for linking with lib intl + # So we try with flags just in case it helps. + oldflags = conf.env['EXTRA_LDFLAGS']; + conf.env['EXTRA_LDFLAGS'].extend("-liconv") + conf.CHECK_FUNCS_IN('dgettext gettext bindtextdomain textdomain bind_textdomain_codeset', + 'intl', checklibc=False, headers='libintl.h') + conf.env['EXTRA_LDFLAGS'] = oldflags + if conf.env['HAVE_GETTEXT'] and conf.env['HAVE_DGETTEXT']: + # save for dependency definitions + conf.env.intl_libs='iconv intl' + else: + conf.fatal('library gettext not found, try specifying the path to ' + + 'it with --with-gettext= or ' + + '--without-gettext to build without''') - conf.CHECK_FUNCS_IN('dgettext gettext', 'intl', headers='libintl.h') conf.CHECK_FUNCS_IN('pthread_create', 'pthread', checklibc=True, headers='pthread.h') conf.CHECK_FUNCS_IN('crypt', 'crypt', checklibc=True) @@ -627,6 +651,8 @@ def build(bld): target='stdbool.h', enabled = not bld.CONFIG_SET('HAVE_STDBOOL_H')) + bld.SAMBA_SUBSYSTEM('samba_intl', source='', use_global_deps=False,deps=bld.env.intl_libs) + def dist(): '''makes a tarball for distribution''' samba_dist.dist() -- cgit