diff options
-rw-r--r-- | Makefile.am | 9 | ||||
-rw-r--r-- | acinclude.m4 | 47 | ||||
-rw-r--r-- | configure.ac | 19 | ||||
-rw-r--r-- | xfd.c | 14 |
4 files changed, 86 insertions, 3 deletions
diff --git a/Makefile.am b/Makefile.am index e8a16a3..26b8a83 100644 --- a/Makefile.am +++ b/Makefile.am @@ -85,3 +85,12 @@ ChangeLog: $(CHANGELOG_CMD) dist-hook: ChangeLog INSTALL + +if USE_GETTEXT +noinst_DATA = xfd.po + +xfd.po: $(xfd_SOURCES:%=$(srcdir)/%) + $(AM_V_GEN)xgettext -d xfd -n $(xfd_SOURCES:%=$(srcdir)/%) + +CLEANFILES += xfd.po +endif diff --git a/acinclude.m4 b/acinclude.m4 new file mode 100644 index 0000000..8e80584 --- /dev/null +++ b/acinclude.m4 @@ -0,0 +1,47 @@ +# =========================================================================== +# http://www.nongnu.org/autoconf-archive/ax_define_dir.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_DEFINE_DIR(VARNAME, DIR [, DESCRIPTION]) +# +# DESCRIPTION +# +# This macro sets VARNAME to the expansion of the DIR variable, taking +# care of fixing up ${prefix} and such. +# +# VARNAME is then offered as both an output variable and a C preprocessor +# symbol. +# +# Example: +# +# AX_DEFINE_DIR([DATADIR], [datadir], [Where data are placed to.]) +# +# LICENSE +# +# Copyright (c) 2008 Stepan Kasal <kasal@ucw.cz> +# Copyright (c) 2008 Andreas Schwab <schwab@suse.de> +# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de> +# Copyright (c) 2008 Alexandre Oliva +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +AU_ALIAS([AC_DEFINE_DIR], [AX_DEFINE_DIR]) +AC_DEFUN([AX_DEFINE_DIR], [ + prefix_NONE= + exec_prefix_NONE= + test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix + test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix +dnl In Autoconf 2.60, ${datadir} refers to ${datarootdir}, which in turn +dnl refers to ${prefix}. Thus we have to use `eval' twice. + eval ax_define_dir="\"[$]$2\"" + eval ax_define_dir="\"$ax_define_dir\"" + AC_SUBST($1, "$ax_define_dir") + AC_DEFINE_UNQUOTED($1, "$ax_define_dir", [$3]) + test "$prefix_NONE" && prefix=NONE + test "$exec_prefix_NONE" && exec_prefix=NONE +]) diff --git a/configure.ac b/configure.ac index 21c5d7c..173d881 100644 --- a/configure.ac +++ b/configure.ac @@ -38,6 +38,25 @@ AC_PROG_CC AM_PROG_CC_C_O AC_PROG_INSTALL +# Internationalization & localization support +AC_SEARCH_LIBS([gettext], [intl], [USE_GETTEXT="yes"], [USE_GETTEXT="no"]) +AC_MSG_CHECKING([where to install localized messages]) +AC_ARG_WITH([localedir], AS_HELP_STRING([--with-localedir=<path>], + [Path to install message files in (default: datadir/locale)]), + [LOCALEDIR=${withval}], [LOCALEDIR=${datadir}/locale]) +AX_DEFINE_DIR([LOCALEDIR], [LOCALEDIR], [Location of translated messages]) +if test "x$LOCALEDIR" = "xno" -o "x$USE_GETTEXT" = "xno" ; then + AC_MSG_RESULT([nowhere]) + USE_GETTEXT="no" +else + AC_MSG_RESULT([$LOCALEDIR]) +fi + +if test "x$USE_GETTEXT" = "xyes" ; then + AC_DEFINE([USE_GETTEXT], 1, + [Define to 1 if you want to use the gettext() function.]) +fi +AM_CONDITIONAL(USE_GETTEXT, test "x$USE_GETTEXT" = "xyes") # Checks for pkg-config packages PKG_CHECK_MODULES(XAW, xaw7) @@ -28,6 +28,10 @@ in this Software without prior written authorization from The Open Group. */ /* $XFree86: xc/programs/xfd/xfd.c,v 1.8 2003/02/20 02:56:40 dawes Exp $ */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include <X11/Intrinsic.h> #include <X11/StringDefs.h> #include <X11/Xos.h> @@ -40,8 +44,12 @@ in this Software without prior written authorization from The Open Group. #include <X11/Xaw/Command.h> #include <stdio.h> #include <stdlib.h> -#include <libintl.h> -#include <locale.h> +#ifdef USE_GETTEXT +# include <X11/Xlocale.h> +# include <libintl.h> +#else +# define gettext(a) (a) +#endif #include "grid.h" #ifdef XRENDER #include <X11/Xft/Xft.h> @@ -192,7 +200,7 @@ main(int argc, char *argv[]) /* mainly for debugging */ if ((domaindir = getenv ("TEXTDOMAINDIR")) == NULL) { - domaindir = "/usr/share/locale"; + domaindir = LOCALEDIR; } bindtextdomain ("xfd", domaindir); |