1 # geda-desktop-i18n.m4 -*-Autoconf-*-
4 dnl Carry out configuration tasks needed by desktop-i18n tool
5 dnl Copyright (C) 2009 Peter Brett <peter@peter-b.co.uk>
7 dnl This program is free software; you can redistribute it and/or modify
8 dnl it under the terms of the GNU General Public License as published by
9 dnl the Free Software Foundation; either version 2 of the License, or
10 dnl (at your option) any later version.
12 dnl This program is distributed in the hope that it will be useful,
13 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
14 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 dnl GNU General Public License for more details.
17 dnl You should have received a copy of the GNU General Public License
18 dnl along with this program; if not, write to the Free Software
19 dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 AC_DEFUN([AX_DESKTOP_I18N],
24 AC_REQUIRE([AM_NLS])dnl
25 AC_REQUIRE([AM_PO_SUBDIRS])dnl
26 dnl Complain if desktop-i18n is missing
27 AC_REQUIRE_AUX_FILE([desktop-i18n])
29 # We need to check that GNU gettext is available
30 AM_PATH_PROG_WITH_TEST([GETTEXT], [gettext],
31 [$ac_dir/$ac_word --version | grep GNU > /dev/null], :)
32 if test "x$GETTEXT" = x; then
33 AC_MSG_ERROR([The GNU gettext program could not be found. Please ensure that GNU
34 gettext is correctly installed, and rerun configure.])
38 # How should desktop-i18n be run?
39 DESKTOP_I18N_SCRIPT="$am_aux_dir/desktop-i18n"
40 DESKTOP_I18N="\${SHELL} $DESKTOP_I18N_SCRIPT"
41 AC_SUBST([DESKTOP_I18N_SCRIPT])
42 AC_SUBST([DESKTOP_I18N])
44 # We have a private directory to temporarily install locale data
46 DESKTOP_I18N_LOCALE_DIR='$(top_builddir)/.desktop-i18n'
47 AC_SUBST([DESKTOP_I18N_LOCALE_DIR])
49 # Substitute our own evil, corrupted version of xgettext.
51 XGETTEXT="$DESKTOP_I18N --extract --xgettext=$XGETTEXT --"
53 # Define some rules for substitution into Makefiles
54 DESKTOP_I18N_CREATE='$(DESKTOP_I18N) --create --gettext=$(GETTEXT) --domain=$(DOMAIN) \
55 --localedir=$(DESKTOP_I18N_LOCALE_DIR)/share/locale $(DESKTOP_I18N_LANGS)'
57 DESKTOP_I18N_LANGS_RULE='DESKTOP_I18N_LANGS = $[$](echo "{ printf \"--lang=%s \", \$[$]1 }" \
58 | awk -f - $(DESKTOP_I18N_LOCALE_DIR)/$(DOMAIN).LINGUAS)'
60 DESKTOP_I18N_DESKTOP_RULE='.SUFFIXES: .desktop.in .desktop
61 .desktop.in.desktop: ; $(DESKTOP_I18N_CREATE) $< [$]@'
63 DESKTOP_I18N_XML_RULE='.SUFFIXES: .xml.in .xml
64 .xml.in.xml: ; $(DESKTOP_I18N_CREATE) $< [$]@'
66 AC_SUBST([DESKTOP_I18N_CREATE])
67 _IT_SUBST([DESKTOP_I18N_LANGS_RULE])
68 _IT_SUBST([DESKTOP_I18N_DESKTOP_RULE])
69 _IT_SUBST([DESKTOP_I18N_XML_RULE])
74 # Abstract macro to do either _AM_SUBST_NOTMAKE or AC_SUBST
75 # Stolen from intltool.m4 (GPL v2)
79 m4_ifdef([_AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE([$1])])