On Sun, Sep 04, 2011 at 07:03:29PM +0200, Josselin Mouette wrote:
> Package: dh-autoreconf
> Version: 4
> Severity: wishlist
> 
> Hi,
> 
> as it stands, autoreconf will not update gtk-doc.make whenever needed. 
> When the version in the tarball gets out of sync with the version in the 
> system, the documentation build will fail.
> 
> Simple fix:
>  cp /usr/share/gtk-doc/data/gtk-doc.make .
> before the autoreconf invocation.

You might want to run dh_autoreconf with autogen.sh or similar instead
of autoreconf (but probably not have autogen.sh run ./configure) --
Simply replacing gtk-doc makefiles in dh_autoreconf does not
seem like a good solution. Although we could probably do this if
dh_autoreconf is run without a command (i.e. if it runs autoreconf
-f -i).

The attached patch runs gtkdocize under the following circumstances:

        (1) It is installed
        (2) GTK_DOC_CHECK is called in configure.ac or configure.in
        (3) No command to run has been given to dh_autoreconf

Especially (3) is important, as users not wanting to run autoreconf
-f -i likely do not want to run gtkdocize either.

-- 
Julian Andres Klode  - Debian Developer, Ubuntu Member

See http://wiki.debian.org/JulianAndresKlode and http://jak-linux.org/.
diff --git a/dh_autoreconf b/dh_autoreconf
index f863aa2..679064e 100755
--- a/dh_autoreconf
+++ b/dh_autoreconf
@@ -83,8 +83,28 @@ shall not be run:
     export AUTOMAKE = automake1.10
     export LIBTOOLIZE = true
 
+=head1 BEHAVIOR IF NO COMMAND IS GIVEN
+
+If no command is given to dh_autoreconf, it will run the following commands
+in order:
+
+    autoreconf -f -i
+    gtkdocize  --copy         # if GTK_DOC_CHECK is called in configure.{ac,in}
+
+If you have directories listed in debian/autoreconf, autoreconf will be run
+on all of them, whereas gtkdocize may be run only on the top-level build
+directory.
 =cut
 
+# Read a file, return an array of lines.
+sub readfile ($) {
+    my $file = shift;
+    open(DAT, $file) || error("Could not read file: " . $file);
+    my @data=<DAT>;
+    close(DAT);
+    return @data;
+}
+
 init(options => { "mode=s" => \$dh{MODE},
                   "as-needed" => \$dh{AS_NEEDED}});
 
@@ -123,6 +143,16 @@ my $find = $modes{$dh{MODE} || "md5"} ||
 
 complex_doit("$find > debian/autoreconf.before");
 
+
+# Run gtkdocize automatically
+if (-f "/usr/bin/gtkdocize" and not @ARGV) {
+    my $configure = (-e "configure.ac") ? "configure.ac" : "configure.in";
+
+    if (-e $configure && grep(/^GTK_DOC_CHECK/, readfile($configure))) {
+        doit("gtkdocize", "--copy");
+    }
+}
+
 # Run autoreconf to recreate the needed files.
 @ARGV ? doit(@ARGV, @{$dh{U_PARAMS}}) : doit('autoreconf', '-f', '-i', @directories);
 

Attachment: pgpRs7twdOpOJ.pgp
Description: PGP signature

Reply via email to