Revamp NLS support. Drop intltool, code po/Makefile.am manually
authorDavid Woodhouse <David.Woodhouse@intel.com>
Thu, 3 Nov 2011 00:59:00 +0000 (00:59 +0000)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Thu, 3 Nov 2011 01:09:24 +0000 (01:09 +0000)
Using $(shell ...) probably isn't portable, so may need to be expanded by
the configure script. But this is a start...

Using gettextize seemed to pull in a bunch of other crap; I'd rather just
disable NLS support on crappy platforms where the msgfmt tool doesn't exist,
or where dgettext() isn't even available in -lintl.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Makefile.am
autogen.sh
configure.ac
openconnect.pc.in
po/Makefile.am [new file with mode: 0644]
po/POTFILES.in

index ce50b33..e6a2c31 100644 (file)
@@ -14,11 +14,11 @@ man8_MANS = openconnect.8
 openconnect_SOURCES = xml.c main.c dtls.c cstp.c mainloop.c tun.c
 
 openconnect_CFLAGS = $(OPENSSL_CFLAGS) $(LIBXML2_CFLAGS) $(LIBPROXY_CFLAGS) $(ZLIB_CFLAGS)
-openconnect_LDADD = libopenconnect.la $(OPENSSL_LIBS) $(LIBXML2_LIBS) $(LIBPROXY_LIBS) $(ZLIB_LIBS)
+openconnect_LDADD = libopenconnect.la $(OPENSSL_LIBS) $(LIBXML2_LIBS) $(LIBPROXY_LIBS) $(ZLIB_LIBS) $(LIBINTL)
 
 libopenconnect_la_SOURCES = ssl.c http.c version.c auth.c library.c
 libopenconnect_la_CFLAGS = $(OPENSSL_CFLAGS) $(LIBXML2_CFLAGS) $(LIBPROXY_CFLAGS)
-libopenconnect_la_LIBADD = $(OPENSSL_LIBS) $(LIBXML2_LIBS) $(LIBPROXY_LIBS)
+libopenconnect_la_LIBADD = $(OPENSSL_LIBS) $(LIBXML2_LIBS) $(LIBPROXY_LIBS) $(LIBINTL)
 libopenconnect_la_LDFLAGS = -version-number 1:2
 noinst_HEADERS = openconnect-internal.h openconnect.h
 include_HEADERS = openconnect.h
index 17470c9..61984ce 100755 (executable)
@@ -1,8 +1,5 @@
 #!/bin/sh
 
-intltoolize --force --copy --automake || \
-    echo "*** Continuing without NLS support..."
-
     aclocal && \
         libtoolize --automake --copy --force && \
             automake --foreign --add-missing && \
index 9b0fdea..90c438b 100644 (file)
@@ -6,29 +6,41 @@ AM_MAINTAINER_MODE([enable])
 AM_INIT_AUTOMAKE([foreign])
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 
-# Black magic: putting this before the conditional IT_PROG_LIBTOOL below
+# Black magic: putting this before the conditional NLS bits below
 # seems to avoid complaints about AMDEP being conditionally defined.
 AC_PROG_LIBTOOL
 
-# Ick. IT_PROG_INTLTOOL isn't capable of doing this for itself? And hell,
-# we don't even *need* intltool for a build-from-tarball on most systems,
-# do we? But to avoid a whole chain of dependencies, we need it to be
-# optional.
-AC_PATH_PROG(INTLTOOL_UPDATE, [intltool-update])
-AC_PATH_PROG(INTLTOOL_MERGE, [intltool-merge])
-AC_PATH_PROG(INTLTOOL_EXTRACT, [intltool-extract])
-if test -z "$INTLTOOL_UPDATE" -o -z "$INTLTOOL_MERGE" -o -z "$INTLTOOL_EXTRACT"; then
-    AC_MSG_NOTICE([The intltool scripts were not found. Disabling NLS.])
-    USE_NLS=no
-else
-    IT_PROG_INTLTOOL
+AC_ARG_ENABLE([nls],
+       [ --disable-nls           do not use Native Language Support],
+       [USE_NLS=$enableval], [USE_NLS=yes])
+LIBINTL=
+if test "$USE_NLS" = "yes"; then
+   AC_PATH_PROG(MSGFMT, msgfmt)
+   if test "$MSGFMT" = ""; then
+      AC_ERROR([msgfmt could not be found. Try configuring with --disable-nls])
+   fi
+fi
+if test "$USE_NLS" = "yes"; then
+   AC_CHECK_DECL([dgettext(char *, char *)], [],
+      AC_ERROR([dgettext() is not declared in libintl.h. Try configuring with --disable-nls]),
+                 [#include <libintl.h>])
+fi
+if test "$USE_NLS" = "yes"; then
+   AC_SEARCH_LIBS(dgettext, intl,
+                 [if test "$ac_cv_search_dgettext" != "none required"; then
+                       LIBINTL="$ac_cv_search_dgettext"; fi],
+                 AC_ERROR([dgettext() could not be found. Try configuring with --disable-nls]))
+fi
+if test "$USE_NLS" = "absent"; then
+   AC_MSG_NOTICE([Native Language Support will not be supported in this build])
 fi
 
-AC_SUBST(GETTEXT_PACKAGE, [openconnect])
-AM_CONDITIONAL(USE_NLS, [test "$USE_NLS" = "yes"])
-if (test "$USE_NLS" = "yes"); then
+if test "$USE_NLS" = "yes"; then
+   AC_SUBST(LIBINTL)
+   AC_SUBST(GETTEXT_PACKAGE, [openconnect])
    AC_DEFINE(ENABLE_NLS, 1)
 fi
+AM_CONDITIONAL(USE_NLS, [test "$USE_NLS" = "yes"])
 
 AS_COMPILER_FLAGS(CFLAGS,
         "-Wall
@@ -108,5 +120,5 @@ else
 fi
 AM_CONDITIONAL(BUILD_WWW, [test -n "${ac_cv_path_PYTHON}"])
                   
-AC_OUTPUT(Makefile openconnect.pc po/Makefile.in www/Makefile \
+AC_OUTPUT(Makefile openconnect.pc po/Makefile www/Makefile \
          www/styles/Makefile www/inc/Makefile www/images/Makefile)
index 28772dd..a8644c8 100644 (file)
@@ -9,4 +9,5 @@ Description: OpenConnect VPN client
 Version: @VERSION@
 Requires: @LIBPROXY_PC@ zlib openssl libxml-2.0
 Libs: -L${libdir} -lopenconnect
+Libs.private: @LIBINTL@
 Cflags: -I${includedir}
diff --git a/po/Makefile.am b/po/Makefile.am
new file mode 100644 (file)
index 0000000..a32584a
--- /dev/null
@@ -0,0 +1,34 @@
+POTFILESIN = $(shell grep -v '^\#' $(srcdir)/POTFILES.in)
+POTFILES = $(POTFILESIN:%=$(top_srcdir)/%)
+LINGUAS = $(shell cat $(srcdir)/LINGUAS)
+MOFILES = $(LINGUAS:=.mo)
+POFILES = $(LINGUAS:=.po)
+
+noinst_DATA = $(MOFILES)
+
+SUFFIXES = .mo
+
+.po.mo:
+       rm -f  && $(MSGFMT) -o $@ $<
+
+clean-local:
+       rm -f $(MOFILES)
+
+install-data-hook: all
+       linguas="$(LINGUAS)"; \
+       for l in $$linguas; do \
+         dir="$(DESTDIR)$(datadir)/locale/$$l/LC_MESSAGES"; \
+         $(mkdir_p) $$dir; \
+         echo Installing $$l.mo to $$dir/$(PACKAGE).mo ; \
+         $(INSTALL_DATA) $$l.mo $$dir/$(PACKAGE).mo; \
+       done
+
+$(GETTEXT_PACKAGE).pot: $(POTFILES) Makefile
+       rm -f $@ && \
+       xgettext --directory=$(top_srcdir) \
+         --add-comments --keyword=_ --keyword=N_ \
+         --files-from=$(srcdir)/POTFILES.in --from-code=UTF-8 \
+         --package-name="@PACKAGE@" --package-version="@VERSION@" \
+         --msgid-bugs-address=openconnect-devel@lists.infradead.org -o $@
+
+EXTRA_DIST = $(POFILES) LINGUAS POTFILES.in
index 5196ad9..5c70d4c 100644 (file)
@@ -1,6 +1,5 @@
 # List of source files containing translatable strings.
 # Please keep this list in alphabetic order.
-[encoding: UTF-8]
 auth.c
 cstp.c
 dtls.c