summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordefanor <defanor@uberspace.net>2021-09-19 22:58:59 +0300
committerdefanor <defanor@uberspace.net>2021-09-19 23:03:16 +0300
commit859b5e90c3c99ce5adcc6cb4a296dde3a97000c9 (patch)
tree41c95e87d43992d93c13a1c7745a4470372cb18b
parentc84f9e76d8e93c37b974c0fc64a6afdf432595cc (diff)
Allow to build without ICU (and JID checks)
-rw-r--r--README4
-rw-r--r--configure.ac26
-rw-r--r--src/rexmpp_jid.c7
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 <stddef.h>
#include <string.h>
#include <stdio.h>
+#ifdef HAVE_ICU
#include <unicode/ustring.h>
#include <unicode/uset.h>
#include <unicode/uspoof.h>
+#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) {
/* <https://tools.ietf.org/html/rfc7622#section-3>,
<https://tools.ietf.org/html/rfc8265#section-3.3> */
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;
}