From 859b5e90c3c99ce5adcc6cb4a296dde3a97000c9 Mon Sep 17 00:00:00 2001 From: defanor Date: Sun, 19 Sep 2021 22:58:59 +0300 Subject: Allow to build without ICU (and JID checks) --- README | 4 ++-- configure.ac | 26 +++++++++++++++++--------- src/rexmpp_jid.c | 7 ++++++- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/README b/README index 02b2d26..4292503 100644 --- a/README +++ b/README @@ -14,8 +14,8 @@ rely on any particular UI, should be flexible and not stay in the way of implementing additional XEPs on top of it, and should try to make it easy to implement a decent client application using it. -Current dependencies: libunbound, libxml2, gnutls with gnutls-dane or -openssl, gsasl, gpgme, libicu, nettle. +Current dependencies: libunbound, libxml2, gsasl, nettle, gpgme. +Optionally gnutls with gnutls-dane or openssl, icu-i18n. A rough roadmap: diff --git a/configure.ac b/configure.ac index f75696b..de90408 100644 --- a/configure.ac +++ b/configure.ac @@ -16,8 +16,19 @@ AM_PROG_AR LT_INIT # Checks for libraries. + +PKG_CHECK_MODULES([UNBOUND], [libunbound]) + PKG_CHECK_MODULES([LIBXML], [libxml-2.0]) +PKG_CHECK_MODULES([GSASL], [libgsasl]) + +PKG_CHECK_MODULES([NETTLE], [nettle]) + +AM_PATH_GPGME + +# TLS: GnuTLS, OpenSSL, or none + AC_ARG_ENABLE([tls], AS_HELP_STRING([--disable-tls], [build without TLS support])) AC_ARG_WITH([openssl], AS_HELP_STRING([--with-openssl], [Use OpenSSL])) @@ -42,16 +53,13 @@ AS_IF([test "x$with_gnutls" == "xyes"], [PKG_CHECK_MODULES([OPENSSL], [openssl], [AC_DEFINE([USE_OPENSSL], [1], [Use OpenSSL])])])])]) +# ICU, optional -PKG_CHECK_MODULES([GSASL], [libgsasl]) - -PKG_CHECK_MODULES([UNBOUND], [libunbound]) - -AM_PATH_GPGME - -PKG_CHECK_MODULES([ICU_I18N], [icu-i18n]) - -PKG_CHECK_MODULES([NETTLE], [nettle]) +AC_ARG_WITH([icu], + AS_HELP_STRING([--without-icu], [Don't use ICU for JID checks])) +AS_IF([test "x$with_icu" != "xno"], + [PKG_CHECK_MODULES([ICU_I18N], [icu-i18n], + AC_DEFINE([HAVE_ICU], [1], [icu-i18n is available]))]) # Checks for header files. diff --git a/src/rexmpp_jid.c b/src/rexmpp_jid.c index ee7b326..659df3e 100644 --- a/src/rexmpp_jid.c +++ b/src/rexmpp_jid.c @@ -9,9 +9,11 @@ #include #include #include +#ifdef HAVE_ICU #include #include #include +#endif #include "rexmpp_jid.h" int rexmpp_jid_parse (const char *str, struct rexmpp_jid *jid) { @@ -71,6 +73,7 @@ int rexmpp_jid_parse (const char *str, struct rexmpp_jid *jid) { /* , */ int rexmpp_jid_check (struct rexmpp_jid *jid) { +#ifdef HAVE_ICU UErrorCode err = U_ZERO_ERROR; UChar local[1023], domain[1023], resource[1023]; int32_t local_len = 0, domain_len = 0, resource_len = 0; @@ -173,6 +176,8 @@ int rexmpp_jid_check (struct rexmpp_jid *jid) { /* TODO: normalization, unorm2_normalize */ /* TODO: directionality */ - +#else + (void)jid; +#endif return 1; } -- cgit v1.2.3