Skip to content

Commit

Permalink
Revamp NLS support. Drop intltool, code po/Makefile.am manually
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
David Woodhouse authored and David Woodhouse committed Nov 3, 2011
1 parent 655eb0b commit b976ecb
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 23 deletions.
4 changes: 2 additions & 2 deletions Makefile.am
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions autogen.sh
@@ -1,8 +1,5 @@
#!/bin/sh

intltoolize --force --copy --automake || \
echo "*** Continuing without NLS support..."

aclocal && \
libtoolize --automake --copy --force && \
automake --foreign --add-missing && \
Expand Down
46 changes: 29 additions & 17 deletions configure.ac
Expand Up @@ -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
Expand Down Expand Up @@ -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)
1 change: 1 addition & 0 deletions openconnect.pc.in
Expand Up @@ -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}
34 changes: 34 additions & 0 deletions po/Makefile.am
@@ -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
1 change: 0 additions & 1 deletion po/POTFILES.in
@@ -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
Expand Down

0 comments on commit b976ecb

Please sign in to comment.