From d18b440a72407fc371ec17a2a983976b813e5d97 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Sun, 31 Oct 2021 09:02:20 +0100 Subject: Require gettext >= 0.18.3; remove GP_GETTEXT_HACK This requires gettext version 0.18.3 or later, and it removes the GP_GETTEXT_HACK which used to generate a po/Makevars file from the po/Makevers.template. gettext 0.18.3 is the same gettext version requirement as libexif uses. gettext 0.18.3 has been released 2013-07-07, which is a similar timeframe of the autoconf, automake and libtool releases we require. If you ever need to build a post 2021 libgphoto2 from git on a system with pre 0.18.3 gettext, you can can always prepare a tarball using "make dist" on a system with gettext 0.18.3 or later, and build that tarball on the older machine. Not generating the po/Makevars file any more means that we need additional consistency checks for the parts of po/Makevars which cannot be derived from the Autoconf standard set of AC_SUBST()ed Makefile.in variables. --- .gitignore | 2 - Makefile.am | 10 +++ configure.ac | 13 ++-- libgphoto2_port/Makefile.am | 10 +++ libgphoto2_port/configure.ac | 13 ++-- libgphoto2_port/gphoto-m4/Makefile-files | 2 +- libgphoto2_port/gphoto-m4/gp-gettext-hack.m4 | 82 --------------------- libgphoto2_port/gphoto-m4/gp-gettext-setup.m4 | 101 ++++++++++++++++++++++++++ libgphoto2_port/po/Makevars | 53 ++++++++++++++ po/Makevars | 53 ++++++++++++++ 10 files changed, 240 insertions(+), 99 deletions(-) delete mode 100644 libgphoto2_port/gphoto-m4/gp-gettext-hack.m4 create mode 100644 libgphoto2_port/gphoto-m4/gp-gettext-setup.m4 create mode 100644 libgphoto2_port/po/Makevars create mode 100644 po/Makevars diff --git a/.gitignore b/.gitignore index 4fc4cb57e..9b0b49feb 100644 --- a/.gitignore +++ b/.gitignore @@ -93,7 +93,6 @@ Makefile.in /libgphoto2_port/po/insert-header.sin /libgphoto2_port/po/libgphoto2_port-12.pot /libgphoto2_port/po/Makefile.in.in -/libgphoto2_port/po/Makevars /libgphoto2_port/po/Makevars.template /libgphoto2_port/po/POTFILES /libgphoto2_port/po/quot.sed @@ -120,7 +119,6 @@ Makefile.in /po/insert-header.sin /po/libgphoto2-6.pot /po/Makefile.in.in -/po/Makevars /po/Makevars.template /po/POTFILES /po/quot.sed diff --git a/Makefile.am b/Makefile.am index 52050e2c5..322491115 100644 --- a/Makefile.am +++ b/Makefile.am @@ -103,6 +103,16 @@ git-checkout-po: update-po: @for d in $(PO_SUBDIRS); do (cd "$$d" && $(MAKE) $(AM_MAKEFLAGS) update-po) || exit 1; done +@GP_GETTEXT_SETUP_MK@ + +# Dummy target to force Automake to make the all target depend on it +all-local: + @: + +# Dummy target to force Automake to make the distclean target depend on it +distclean-local: + @: + ######################################################################## # The following default options for aclocal and automake diff --git a/configure.ac b/configure.ac index e3b1aa48b..3a613c892 100644 --- a/configure.ac +++ b/configure.ac @@ -273,17 +273,16 @@ dnl --------------------------------------------------------------------------- dnl i18n support (including some hacks) dnl --------------------------------------------------------------------------- -GP_GETTEXT_HACK([GETTEXT_PACKAGE_LIBGPHOTO2], - [${PACKAGE}-${LIBGPHOTO2_CURRENT_MIN}], - [The gPhoto Team], - [${MAIL_GPHOTO_TRANSLATION}]) +GP_GETTEXT_SETUP([GETTEXT_PACKAGE_LIBGPHOTO2], + [${PACKAGE}-${LIBGPHOTO2_CURRENT_MIN}], + [po]) AM_PO_SUBDIRS() -AM_GNU_GETTEXT_VERSION([0.14.1]) +AM_GNU_GETTEXT_VERSION([0.18.3]) AM_GNU_GETTEXT([external]) AM_ICONV() -GP_GETTEXT_FLAGS() -AM_CPPFLAGS="$AM_CPPFLAGS -DLOCALEDIR=\\\"${localedir}\\\"" +GP_CONFIG_MSG([Use translations], + [${USE_NLS}]) dnl FIXME: We have to make sure this works first dnl AC_CHECK_FUNC(gettext, gettext_without_libintl=true) diff --git a/libgphoto2_port/Makefile.am b/libgphoto2_port/Makefile.am index 35e1302c8..69720ca2c 100644 --- a/libgphoto2_port/Makefile.am +++ b/libgphoto2_port/Makefile.am @@ -30,6 +30,16 @@ SUBDIRS = po libgphoto2_port . tests doc include gphoto-m4/Makefile-files +@GP_GETTEXT_SETUP_MK@ + +# Dummy target to force Automake to make the all target depend on it +all-local: + @: + +# Dummy target to force Automake to make the distclean target depend on it +distclean-local: + @: + ######################################################################## # All iolibs are defined as EXTRA_LTLIBRARIES. This requires that diff --git a/libgphoto2_port/configure.ac b/libgphoto2_port/configure.ac index ca56478a0..674a3145c 100644 --- a/libgphoto2_port/configure.ac +++ b/libgphoto2_port/configure.ac @@ -118,17 +118,16 @@ dnl --------------------------------------------------------------------------- dnl i18n support dnl --------------------------------------------------------------------------- -GP_GETTEXT_HACK([GETTEXT_PACKAGE_LIBGPHOTO2_PORT], - [${PACKAGE}-${LIBGPHOTO2_PORT_CURRENT_MIN}], - [Lutz Mueller and others], - [${MAIL_GPHOTO_TRANSLATION}]) +GP_GETTEXT_SETUP([GETTEXT_PACKAGE_LIBGPHOTO2_PORT], + [${PACKAGE}-${LIBGPHOTO2_PORT_CURRENT_MIN}], + [po]) AM_PO_SUBDIRS() -AM_GNU_GETTEXT_VERSION([0.14.1]) +AM_GNU_GETTEXT_VERSION([0.18.3]) AM_GNU_GETTEXT([external]) AM_ICONV() -GP_GETTEXT_FLAGS() -AM_CPPFLAGS="$AM_CPPFLAGS -DLOCALEDIR=\\\"${localedir}\\\"" +GP_CONFIG_MSG([Use translations], + [${USE_NLS}]) AC_CHECK_FUNC([gettext], [gettext_without_libintl=true]) # same trick as with libdl in libgphoto2: diff --git a/libgphoto2_port/gphoto-m4/Makefile-files b/libgphoto2_port/gphoto-m4/Makefile-files index 6bc234866..a623da9c3 100644 --- a/libgphoto2_port/gphoto-m4/Makefile-files +++ b/libgphoto2_port/gphoto-m4/Makefile-files @@ -14,7 +14,7 @@ EXTRA_DIST += %reldir%/gp-check-shell-environment.m4 EXTRA_DIST += %reldir%/gp-config-msg.m4 EXTRA_DIST += %reldir%/gp-documentation.m4 EXTRA_DIST += %reldir%/gp-driverdir.m4 -EXTRA_DIST += %reldir%/gp-gettext-hack.m4 +EXTRA_DIST += %reldir%/gp-gettext-setup.m4 EXTRA_DIST += %reldir%/gp-internal-docs.m4 EXTRA_DIST += %reldir%/gp-libjpeg.m4 EXTRA_DIST += %reldir%/gp-libltdl.m4 diff --git a/libgphoto2_port/gphoto-m4/gp-gettext-hack.m4 b/libgphoto2_port/gphoto-m4/gp-gettext-hack.m4 deleted file mode 100644 index 01ca92742..000000000 --- a/libgphoto2_port/gphoto-m4/gp-gettext-hack.m4 +++ /dev/null @@ -1,82 +0,0 @@ -dnl -dnl GP_GETTEXT_HACK -dnl -dnl gettext hack, originally designed for libexif, libgphoto2, and Co. -dnl This creates a po/Makevars file with adequate values if the -dnl po/Makevars.template is present. -dnl -dnl Example usage: -dnl GP_GETTEXT_HACK([${PACKAGE_TARNAME}-${LIBFOO_CURRENT}], -dnl [Copyright Holder], -dnl [foo-translation@example.org]) -dnl ALL_LINGUAS="de es fr" -dnl AM_GNU_GETTEXT_VERSION([0.14.1]) -dnl AM_GNU_GETTEXT([external]) -dnl AM_PO_SUBDIRS() -dnl AM_ICONV() -dnl GP_GETTEXT_FLAGS -dnl -dnl You can leave out the GP_GETTEXT_HACK parameters if you want to, -dnl GP_GETTEXT_HACK will try fall back to sensible values in that case: -dnl -dnl -AC_DEFUN([GP_GETTEXT_HACK], [dnl -AC_BEFORE([$0], [AM_GNU_GETTEXT])dnl -AC_BEFORE([$0], [AM_GNU_GETTEXT_VERSION])dnl -m4_if([$2],[],[$1="${PACKAGE_TARNAME}"],[$1="$2"]) -AC_DEFINE_UNQUOTED([$1], ["${$1}"], - [The gettext domain we're using]) -AC_SUBST([$1]) -sed_cmds="s|^DOMAIN.*|DOMAIN = ${$1}|" -m4_if([$3],[],[],[sed_cmds="${sed_cmds};s|^COPYRIGHT_HOLDER.*|COPYRIGHT_HOLDER = $3|"]) -m4_ifval([$4],[ -if test -n "$PACKAGE_BUGREPORT"; then - sed_mb="${PACKAGE_BUGREPORT}" -else - m4_pattern_allow([GP_GETTEXT_HACK])dnl - AC_MSG_ERROR([ -*** Your configure.{ac,in} is wrong. -*** Either define PACKAGE_BUGREPORT (by using the 4-parameter AC INIT syntax) -*** or give [GP_GETTEXT_HACK] the third parameter. -*** -]) -fi -],[ -sed_mb="$4" -]) -sed_cmds="${sed_cmds};s|^MSGID_BUGS_ADDRESS.*|MSGID_BUGS_ADDRESS = ${sed_mb}|" -# Not so sure whether this hack is all *that* evil... -AC_MSG_CHECKING([for po/Makevars requiring hack]) -if test -f "${srcdir}/po/Makevars.template"; then - sed "$sed_cmds" < "${srcdir}/po/Makevars.template" > "${srcdir}/po/Makevars" - AC_MSG_RESULT([yes, done.]) -else - AC_MSG_RESULT([no]) -fi -])dnl -dnl -dnl -dnl -AC_DEFUN([GP_GETTEXT_FLAGS], -[ -AC_REQUIRE([AM_GNU_GETTEXT]) -AC_REQUIRE([GP_CONFIG_INIT]) -if test "x${BUILD_INCLUDED_LIBINTL}" = "xyes"; then - AM_CFLAGS="${AM_CFLAGS} -I\$(top_srcdir)/intl" -fi -GP_CONFIG_MSG([Use translations],[${USE_NLS}]) -if test "x$USE_NLS" = "xyes" && test "${BUILD_INCLUDED_LIBINTL}"; then - GP_CONFIG_MSG([Use included libintl],[${BUILD_INCLUDED_LIBINTL}]) -fi -])dnl -dnl -dnl - -dnl Please do not remove this: -dnl filetype: 71ff3941-a5ae-4677-a369-d7cb01f92c81 -dnl I use this to find all the different instances of this file which -dnl are supposed to be synchronized. - -dnl Local Variables: -dnl mode: autoconf -dnl End: diff --git a/libgphoto2_port/gphoto-m4/gp-gettext-setup.m4 b/libgphoto2_port/gphoto-m4/gp-gettext-setup.m4 new file mode 100644 index 000000000..a73341437 --- /dev/null +++ b/libgphoto2_port/gphoto-m4/gp-gettext-setup.m4 @@ -0,0 +1,101 @@ +dnl #################################################################### +dnl GP_GETTEXT_SETUP(...) +dnl Gettext setup with e.g. consistency checks for value of DOMAIN. +dnl #################################################################### +dnl +dnl Usage: +dnl GP_GETTEXT_SETUP([DOMAIN_LIBGPHOTO2], +dnl [libgphoto2-${LIBGPHOTO2_CURRENT_MIN}], +dnl [po]) +dnl GP_GETTEXT_SETUP([DOMAIN_LIBGPHOTO2_PORT], +dnl [libgphoto2_port-${LIBGPHOTO2_PORT_CURRENT_MIN}], +dnl [libgphoto2_port/po]) +dnl +dnl with the corresponding top level Makefile.am containing +dnl +dnl @GP_GETTEXT_SETUP_MK@ +dnl +dnl # Dummy target to force Automake to make the "all" target depend on it +dnl all-local: +dnl @: +dnl +dnl # Dummy target to force Automake to make the "distclean" target depend on it +dnl distclean-local: +dnl @: +dnl +dnl #################################################################### +dnl +AC_DEFUN([GP_GETTEXT_SETUP], [dnl +AC_REQUIRE([AC_PROG_GREP])dnl +AC_REQUIRE([GP_GETTEXT_SETUP_INIT])dnl +dnl +AC_MSG_CHECKING([translation text domain symbol]) +AC_MSG_RESULT([$1]) +AC_MSG_CHECKING([translation text domain value]) +AC_MSG_RESULT([$2]) +AC_MSG_CHECKING([translation subdirectory]) +AC_MSG_RESULT([$3]) +dnl +dnl The text domain can be evaluated as a shell variable, no need for +dnl recursive make variable evaluation, so we can put the text domain +dnl into the include file and do not need to define it from a make +dnl rule on the compiler command line. +AC_DEFINE_UNQUOTED([$1], ["$2"], [text domain for string translations]) +dnl AM_CPPFLAGS="$AM_CPPFLAGS -D$1=\\\""'$2'"\\\"" +dnl AC_SUBST([$1], [$2]) +dnl +dnl +dnl The following check will have "make all" print something like +dnl DOMAIN = libgphoto2-6 +dnl if the consistency check has been successful, and have "make all" abort +dnl Error: Inconsistent values for GETTEXT_PACKAGE_LIBGPHOTO2 and po/Makevars DOMAIN. +dnl if the consistency check has failed. +dnl +cat >>${GP_GETTEXT_SETUP_MK} <${GP_GETTEXT_SETUP_MK} <