Compatibility with recent: automake-1.10-5
[macros.git] / AutoGen.pm
index 652ac7b..861177e 100644 (file)
@@ -296,6 +296,7 @@ my($class,%args)=@_;
                @subdirs=glob $glob;
                confess "Invalid glob $glob: ".join(",",@subdirs) if 1!=@subdirs;
                }
+       $base||=$subdirs[0];
        rename $subdirs[0],$base or confess "$!";
        _system(join(" ","cd ".$base.";dpkg-buildpackage",
                        "-rfakeroot",
@@ -334,6 +335,7 @@ sub _cleanfiles
                                                .deps .libs
                                                *.[oa] *.l[oa] *.l[oa]T
                                                .cvsignore
+                                               pod2htm[di].tmp
 
                                                ./errs*
                                                ./intl
@@ -399,7 +401,7 @@ sub _cleanfiles
 
 sub _cleanfilesfordir
 {
-my($dir)=@_;
+my($dir,@cleanfiles)=@_;
 
        return map({
                           if (m#^\Q$dir\E/([^/]+)$#) { # this-dir: "./this-dir/file-name.c"
@@ -417,7 +419,7 @@ my($dir)=@_;
                        else {
                                        ();
                                        }
-                       } _cleanfiles());
+                       } @cleanfiles);
 }
 
 sub _cvsdirs
@@ -490,13 +492,12 @@ my($class,%options)=@_;
                          "rpmtest"  ,sub { $class->_rpmbuild("sign"=>0); },
                          "deb"      ,sub { $class->_debbuild("sign"=>1); },
                          "debtest"  ,sub { $class->_debbuild("sign"=>0); },
-                         "cleanfilesfordir=s",sub { print "$_\n" for (_cleanfilesfordir $_[1]); exit 0; },
+                         "cleanfilesfordir=s",sub { print "$_\n" for (_cleanfilesfordir($_[1],_cleanfiles())); exit 0; },
                          "dist"     ,\$Options{"ARGV_dist"},
                          "copy!"    ,\$Options{"ARGV_copy"},
                          "clean"    ,\$Options{"ARGV_clean"},
                          "fullclean",\$Options{"ARGV_fullclean"},
                        "h|help"     ,sub { print _help(); exit 0; },
-                       $Options{"GetOptions_args"},
                        ) || @ARGV;
 
        for my $subdir (map((!$_ ? () : @$_),$Options{"subdirs"})) {
@@ -505,7 +506,7 @@ my($class,%options)=@_;
                }
 
        for my $dir (_cvsdirs(".")) {
-               my @cleanfilesfordir=_cleanfilesfordir $dir;
+               my @cleanfilesfordir=_cleanfilesfordir $dir,_cleanfiles();
                _writefile $dir."/.cvsignore",map("$_\n",@cleanfilesfordir) if !$Options{"ARGV_fullclean"};
                _remove "nocheck",\1,map({ _expandclass("$dir/$_"); } grep({
                                $Options{"ARGV_fullclean"} or $_ ne ".cvsignore";
@@ -585,9 +586,29 @@ my($class,%options)=@_;
        # "ChangeLog" is reqd by automake(1)
        # Don't remove it afterwards as it may still be needed during automatic automake Makefile rebuilds
        File::Touch->new("atime_only"=>1)->touch("ChangeLog") if !$Options{"ChangeLog"};
-       _system qw(automake --add-missing),@copy_arg;
+       _system qw(automake --add-missing -Wno-portability),@copy_arg;
        _system qw(autoconf);
-       _writefile "| patch configure",<<'CONFIGURE_SUBST_X_EOF';
+       for my $patch (
+                       <<'CONFIGURE_SUBST_X_EOF',
+--- configure-orig     2007-03-27 01:13:44.000000000 +0200
++++ configure  2007-03-27 01:17:07.000000000 +0200
+@@ -3749,7 +3749,13 @@
+   rm -f "$tmp/stdin"
+   case $ac_file in
+   -) cat "$tmp/out"; rm -f "$tmp/out";;
+-  *) rm -f "$ac_file"; mv "$tmp/out" $ac_file;;
++  *) rm -f "$ac_file"; mv "$tmp/out" $ac_file
++     for f in $ac_file_inputs; do
++       if test -x $f; then
++         chmod +x $ac_file
++       fi
++     done
++     ;;
+   esac
+  ;;
+CONFIGURE_SUBST_X_EOF
+                       <<'CONFIGURE_SUBST_X_EOF',
 --- configure-orig     Wed Aug 20 12:10:37 2003
 +++ configure  Wed Aug 20 13:22:51 2003
 @@ -21590,6 +21590,11 @@
@@ -603,6 +624,15 @@ my($class,%options)=@_;
      cat $tmp/out
      rm -f $tmp/out
 CONFIGURE_SUBST_X_EOF
+                       undef(),
+                       ) {
+               confess if !$patch;
+               last if eval {
+                       _writefile "| patch configure",$patch;
+                       1;
+                       };
+               _remove "nocheck","./configure.rej";
+               }
        _remove "nocheck","./configure.orig";   # It is usually produced by 'CONFIGURE_SUBST_X'.
        # Why it is left there after RedHat autoconf-2.53-8 ?
        _remove "nocheck",\1,"autom4te-*.cache";
@@ -645,20 +675,12 @@ B<automake>(1) and similiar tools. This project has some additional features:
 
 =over
 
-=item
-
 Clean the checkout directory without B<Makefile>s for 'make clean'.
 
-=item
-
 Maintain B<.cvsignore> files containing the files being cleaned.
 
-=item
-
 Single-command package building of B<.rpm>/B<.deb> out of CVS checkout.
 
-=item
-
 Supports: B<gettext>, B<glib-gettext>, B<libtool>, B<autoconf>, B<automake>.
 
 =back
@@ -756,9 +778,7 @@ B<DISTCLEANFILES> or B<MAINTAINERCLEANFILES> variables of B<Makefile.am>s.
 
 There are several formats of B<clean> field possible entries:
 
-=over
-
-=item B<./path/to/file.c>
+=item B<clean> entry: B<./path/to/file.c>
 
 Full project-basedir relative path to the deleted file. Rule applies only to
 the one specified directory. Although B<path/to/file.c> would be also possible
@@ -766,18 +786,16 @@ it is not recommended to have unified format with B<./only_basedir.c> entries
 to delete file just in the root directory (as B<only_basedir.c> would delete
 it in ALL subdirectories incl. the root one).
 
-=item B<basename.c>
+=item B<clean> entry: B<basename.c>
 
 Delete B<basename_generated.c> found in any subdirectory of the project.
 It has the same effect as B<./*/basename_generated.c> entry.
 
-=item B<./subdir/*/name.c>
+=item B<clean> entry: B<./subdir/*/name.c>
 
 Delete B<name.c> in B<./subdir> and all of its subdirector descendants.
 Entry B<subdir/*/name.c> would have the same effect.
 
-=back
-
 
 =item B<prep>
 
@@ -824,7 +842,7 @@ This section applies to projects where you patch foreign existing packages.
 
 =over
 
-=item
+=item Prolog
 
 Use the following alternate B<autogen.pl> prolog if your branch does not belong
 to the B<MAIN> CVS branch:
@@ -837,12 +855,12 @@ to the B<MAIN> CVS branch:
  use lib "./macros/";
  use AutoGen;
 
-=item
+=item Original archive
 
 Put B<fooproject-1.2.3.tar.gz> archive to the project root directory
 as B<orig-fooproject-1.2.3.tar.gz>.
 
-=item
+=item Versioning
 
 Set B<$VERSION> in B<configure.ac> file with you vendor prefix such as
 B<1.2.3joe1>. Set B<$VERSION_BASE> to B<1.2.3> and B<$VERSION_EXT> to B<joe1>.
@@ -850,55 +868,31 @@ B<AC_SUBST>() them both.
 
 =item B<.spec> file changes
 
-=over
-
-=item
-
 Change B<Version: @VERSION@> to B<Version: @VERSION_BASE@>.
 
-=item
-
 Change (expected) line B<Release: 1> to B<Release: 1@VERSION_EXT@>.
 
-=item
-
 Change B<Source: ...@VERSION@.tar.gz> to B<Source: ...@VERSION_BASE@.tar.gz>.
 
-=item
-
 Add line B<Patch1: @PACKAGE@-@VERSION_BASE@-@VERSION_EXT@.patch>.
 This patch file name is not mandatory.
 
-=item
-
 Remember to call B<autotools> commands manually in the B<%build>
 section if their source files were modified in your vendor branch.
 
-=back
-
 =item B<debian>-specific changes
 
-=over
-
-=item
-
 Include both B<debian/changelog.in> and B<debian/changelog> to B<Makefile.am>.
 
-=item
-
 Include B<debian/changelog> to B<clean> field in B<autogen.pl>.
 
-=item
-
 Use B<@VERSION@> in B<debian/changelog.in>. Package will be built as
 Debian-native package (no I<.diff> file) as the patches are not just for Debian
 packages, it is a new package (read: dpkg does not support branch patches).
 
 =back
 
-=back
-
 =head1 AUTHOR
 
 Jan Kratochvil <B<project-macros@jankratochvil.net>>,
-               I<http://www.jankratochvil.net/>
+I<http://www.jankratochvil.net/>