From 04bd645995a94f245b1d0bb0e6fad37982bf8d39 Mon Sep 17 00:00:00 2001
From: Eli Schwartz <eschwartz@archlinux.org>
Date: Sun, 17 Mar 2019 14:58:02 -0400
Subject: [PATCH 2/2] autoreconf: integrate intltoolize into the standard
 configuration tools

In addition to the gtkdocize tool, gtk-related software may utilize the
IT_PROG_INTLTOOL macro in order to require the intltoolize tool. So too
here should the tool be run by autoreconf itself, in order to guarantee
its initialization via the unified frontend for all autotools projects.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
---
 bin/autoreconf.in | 65 +++++++++++++++++++++++++++++++++--------------
 doc/autoconf.texi |  6 ++---
 lib/autom4te.in   |  1 +
 3 files changed, 50 insertions(+), 22 deletions(-)

diff --git a/bin/autoreconf.in b/bin/autoreconf.in
index fe7df300..5d43ef2f 100644
--- a/bin/autoreconf.in
+++ b/bin/autoreconf.in
@@ -106,15 +106,16 @@ Written by David J. MacKenzie and Akim Demaille.
 ";
 
 # Lib files.
-my $autoconf   = $ENV{'AUTOCONF'}   || '@bindir@/@autoconf-name@';
-my $autoheader = $ENV{'AUTOHEADER'} || '@bindir@/@autoheader-name@';
-my $autom4te   = $ENV{'AUTOM4TE'}   || '@bindir@/@autom4te-name@';
-my $automake   = $ENV{'AUTOMAKE'}   || 'automake';
-my $aclocal    = $ENV{'ACLOCAL'}    || 'aclocal';
-my $libtoolize = $ENV{'LIBTOOLIZE'} || 'libtoolize';
-my $gtkdocize  = $ENV{'GTKDOCIZE'}  || 'gtkdocize';
-my $autopoint  = $ENV{'AUTOPOINT'}  || 'autopoint';
-my $make       = $ENV{'MAKE'}       || 'make';
+my $autoconf    = $ENV{'AUTOCONF'}    || '@bindir@/@autoconf-name@';
+my $autoheader  = $ENV{'AUTOHEADER'}  || '@bindir@/@autoheader-name@';
+my $autom4te    = $ENV{'AUTOM4TE'}    || '@bindir@/@autom4te-name@';
+my $automake    = $ENV{'AUTOMAKE'}    || 'automake';
+my $aclocal     = $ENV{'ACLOCAL'}     || 'aclocal';
+my $libtoolize  = $ENV{'LIBTOOLIZE'}  || 'libtoolize';
+my $intltoolize = $ENV{'INTLTOOLIZE'} || 'intltoolize';
+my $gtkdocize   = $ENV{'GTKDOCIZE'}   || 'gtkdocize';
+my $autopoint   = $ENV{'AUTOPOINT'}   || 'autopoint';
+my $make        = $ENV{'MAKE'}        || 'make';
 
 # --install -- as --add-missing in other tools.
 my $install = 0;
@@ -176,6 +177,7 @@ sub parse_args ()
 		    $automake, $aclocal,
 		    $autopoint,
 		    $libtoolize,
+		    $intltoolize,
 		    $gtkdocize)
 	{
 	  xsystem ("$prog --version | sed 1q >&2");
@@ -199,20 +201,22 @@ sub parse_args ()
   # --install and --symlink;
   if ($install)
     {
-      $automake   .= ' --add-missing';
-      $automake   .= ' --copy' unless $symlink;
-      $libtoolize .= ' --copy' unless $symlink;
-      $gtkdocize  .= ' --copy' unless $symlink;
+      $automake    .= ' --add-missing';
+      $automake    .= ' --copy' unless $symlink;
+      $libtoolize  .= ' --copy' unless $symlink;
+      $intltoolize .= ' --copy' unless $symlink;
+      $gtkdocize   .= ' --copy' unless $symlink;
     }
   # --force;
   if ($force)
     {
-      $aclocal    .= ' --force';
-      $autoconf   .= ' --force';
-      $autoheader .= ' --force';
-      $automake   .= ' --force-missing';
-      $autopoint  .= ' --force';
-      $libtoolize .= ' --force';
+      $aclocal     .= ' --force';
+      $autoconf    .= ' --force';
+      $autoheader  .= ' --force';
+      $automake    .= ' --force-missing';
+      $autopoint   .= ' --force';
+      $libtoolize  .= ' --force';
+      $intltoolize .= ' --force';
     }
   else
     {
@@ -385,6 +389,7 @@ sub autoreconf_current_directory ()
   my $aux_dir;
   my $uses_gettext_via_traces;
   my $uses_libtool;
+  my $uses_intltool;
   my $uses_gtkdoc;
   my $uses_libltdl;
   my $uses_autoheader;
@@ -406,6 +411,7 @@ sub autoreconf_current_directory ()
 	     'LT_CONFIG_LTDL_DIR',
 	     'AM_GNU_GETTEXT',
 	     'AM_INIT_AUTOMAKE',
+	     'IT_PROG_INTLTOOL',
 	     'GTK_DOC_CHECK',
 	    )
      . ' |');
@@ -421,6 +427,7 @@ sub autoreconf_current_directory ()
       $uses_libltdl = 1             if $macro eq "LT_CONFIG_LTDL_DIR";
       $uses_autoheader = 1          if $macro eq "AC_CONFIG_HEADERS";
       $uses_automake = 1            if $macro eq "AM_INIT_AUTOMAKE";
+      $uses_intltool = 1            if $macro eq "IT_PROG_INTLTOOL";
       $uses_gtkdoc = 1              if $macro eq "GTK_DOC_CHECK";
       push @subdir, split (' ', $args[0])
                                     if $macro eq "AC_CONFIG_SUBDIRS" && $recursive;
@@ -488,6 +495,26 @@ sub autoreconf_current_directory ()
     }
 
 
+  # --------------------- #
+  # Running intltoolize.  #
+  # --------------------- #
+
+  if (!$uses_intltool)
+    {
+      verb "$configure_ac: not using Intltool";
+    }
+  elsif ($install)
+    {
+      xsystem_hint ("intltoolize is needed because this package uses Intltool", $intltoolize);
+      xsystem ($intltoolize)
+    }
+  else
+    {
+      verb "$configure_ac: not running intltool: --install not given";
+    }
+
+
+
   # ------------------- #
   # Running gtkdocize.  #
   # ------------------- #
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index a1442520..391b4d02 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -1687,13 +1687,13 @@ been updated, or finally, simply in order to install the GNU Build
 System in a fresh tree.
 
 @command{autoreconf} runs @command{autoconf}, @command{autoheader},
-@command{aclocal}, @command{automake}, @command{libtoolize},
+@command{aclocal}, @command{automake}, @command{libtoolize}, @command{intltoolize},
 @command{gtkdocize}, and @command{autopoint} (when appropriate) repeatedly
 to update the GNU Build System in the specified directories and their
 subdirectories (@pxref{Subdirectories}).  By default, it only remakes
 those files that are older than their sources.  The environment variables
-@env{AUTOM4TE}, @env{AUTOCONF}, @env{AUTOHEADER}, @env{AUTOMAKE},
-@env{ACLOCAL}, @env{AUTOPOINT}, @env{LIBTOOLIZE}, @env{GTKDOCIZE}, @env{M4},
+@env{AUTOM4TE}, @env{AUTOCONF}, @env{AUTOHEADER}, @env{AUTOMAKE}, @env{ACLOCAL},
+@env{AUTOPOINT}, @env{LIBTOOLIZE}, @env{INTLTOOLIZE}, @env{GTKDOCIZE}, @env{M4},
 and @env{MAKE} may be used to override the invocation of the respective tools.
 
 If you install a new version of some tool, you can make
diff --git a/lib/autom4te.in b/lib/autom4te.in
index 2acd39cd..4c4d85f7 100644
--- a/lib/autom4te.in
+++ b/lib/autom4te.in
@@ -98,6 +98,7 @@ args: --preselect AC_CONFIG_MACRO_DIR_TRACE
 args: --preselect AC_CONFIG_SUBDIRS
 args: --preselect AC_INIT
 args: --preselect AC_PROG_LIBTOOL
+args: --preselect IT_PROG_INTLTOOL
 args: --preselect GTK_DOC_CHECK
 args: --preselect LT_INIT
 args: --preselect LT_CONFIG_LTDL_DIR
-- 
2.26.0

