• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1dnl
2dnl GP_GETTEXT_HACK
3dnl
4dnl gettext hack, originally designed for libexif, libgphoto2, and Co.
5dnl This creates a po/Makevars file with adequate values if the
6dnl po/Makevars.template is present.
7dnl
8dnl Example usage:
9dnl    GP_GETTEXT_HACK([${PACKAGE_TARNAME}-${LIBFOO_CURRENT}],
10dnl                    [Copyright Holder],
11dnl                    [foo-translation@example.org])
12dnl    ALL_LINGUAS="de es fr"
13dnl    AM_GNU_GETTEXT_VERSION([0.14.1])
14dnl    AM_GNU_GETTEXT([external])
15dnl    AM_PO_SUBDIRS()
16dnl    AM_ICONV()
17dnl    GP_GETTEXT_FLAGS
18dnl
19dnl You can leave out the GP_GETTEXT_HACK parameters if you want to,
20dnl GP_GETTEXT_HACK will try fall back to sensible values in that case:
21dnl
22dnl SPDX-License-Identifier: LGPL-2.0-or-later
23dnl
24
25AC_DEFUN([GP_GETTEXT_HACK],
26[
27AC_BEFORE([$0], [AM_GNU_GETTEXT])dnl
28AC_BEFORE([$0], [AM_GNU_GETTEXT_VERSION])dnl
29m4_if([$1],[],[GETTEXT_PACKAGE="${PACKAGE_TARNAME}"],[GETTEXT_PACKAGE="$1"])
30# The gettext domain we're using
31AM_CPPFLAGS="$AM_CPPFLAGS -DGETTEXT_PACKAGE=\\\"${GETTEXT_PACKAGE}\\\""
32AC_SUBST([GETTEXT_PACKAGE])
33sed_cmds="s|^DOMAIN.*|DOMAIN = ${GETTEXT_PACKAGE}|"
34m4_if([$2],[],[],[sed_cmds="${sed_cmds};s|^COPYRIGHT_HOLDER.*|COPYRIGHT_HOLDER = $2|"])
35m4_ifval([$3],[
36sed_mb="$3"
37],[
38if test -n "$PACKAGE_BUGREPORT"; then
39   sed_mb="${PACKAGE_BUGREPORT}"
40else
41   AC_MSG_ERROR([
42*** Your configure.{ac,in} is wrong.
43*** Either define PACKAGE_BUGREPORT (by using the 4-parameter AC INIT syntax)
44*** or give [GP_GETTEXT_HACK] the third parameter.
45***
46])
47fi
48])
49sed_cmds="${sed_cmds};s|^MSGID_BUGS_ADDRESS.*|MSGID_BUGS_ADDRESS = ${sed_mb}|"
50# Not so sure whether this hack is all *that* evil...
51AC_MSG_CHECKING([for po/Makevars requiring hack])
52if test -f "${srcdir}/po/Makevars.template"; then
53   sed "$sed_cmds" < "${srcdir}/po/Makevars.template" > "${srcdir}/po/Makevars"
54   AC_MSG_RESULT([yes, done.])
55else
56   AC_MSG_RESULT([no])
57fi
58])
59
60AC_DEFUN([GP_GETTEXT_FLAGS],
61[
62AC_REQUIRE([AM_GNU_GETTEXT])
63AC_REQUIRE([GP_CONFIG_INIT])
64if test "x${BUILD_INCLUDED_LIBINTL}" = "xyes"; then
65   AM_CFLAGS="${AM_CFLAGS} -I\$(top_srcdir)/intl"
66fi
67GP_CONFIG_MSG([Use translations],[${USE_NLS}])
68if test "x$USE_NLS" = "xyes" && test "${BUILD_INCLUDED_LIBINTL}"; then
69   GP_CONFIG_MSG([Use included libintl],[${BUILD_INCLUDED_LIBINTL}])
70fi
71dnl We cannot use AC_DEFINE_UNQUOTED() for these definitions, as
72dnl we require make to do insert the proper $(datadir) value
73AC_SUBST([localedir], ['$(datadir)/locale'])
74AM_CPPFLAGS="$AM_CPPFLAGS -DLOCALEDIR=\\\"${localedir}\\\""
75])
76
77dnl Please do not remove this:
78dnl filetype: 71ff3941-a5ae-4677-a369-d7cb01f92c81
79dnl I use this to find all the different instances of this file which
80dnl are supposed to be synchronized.
81
82dnl Local Variables:
83dnl mode: autoconf
84dnl End:
85