Index: /trunk/psconfig/psdist
===================================================================
--- /trunk/psconfig/psdist	(revision 12866)
+++ /trunk/psconfig/psdist	(revision 12867)
@@ -57,4 +57,8 @@
 	    shift; next
 	}
+	if ($ARGV[0] eq "autogen") {
+	    $mkdist_mode = "autogen";
+	    shift; next
+	}
 	if ($ARGV[0] eq "tarball") {
 	    $mkdist_mode = "tarball";
@@ -177,5 +181,5 @@
 # XXX probably need to force CVSROOT here
 sub make_distribution {
-    # package distribution into a tarball
+    # extract source tree and optionally package the distribution into a tarball
     print STDERR "making distribution\n";
     if ($mkdist_mode eq "") { die "-dist mode is not set\n"; }
@@ -202,7 +206,29 @@
     if ($mkdist_mode eq "cvs") { exit 0; }
 
+    # remove the CVS directories
     &vsystem ("rm -r `find $distribution -name CVS`");
     if ($mkdist_mode eq "tree") { exit 0; }
 
+    # run autogen.sh, if present, to build a configure script
+    chdir $distribution;
+    for ($i = 0; $i < @cvsname; $i++) {
+	if (($module ne "") && ($module ne $cvsname[$i])) { next; }
+	($do_tag, $do_build, $do_dist, $do_update) = $mode[$i] =~ m|(\S)(\S)(\S)(\S)|;
+	if ($do_dist eq "N") { next; }
+
+	if (! -e "$cvsname[$i]/autogen.sh") { next; }
+	chdir $cvsname[$i];
+
+	vsystem ("./autogen.sh");
+	if ($status) { die "error running autogen.sh"; }
+
+	vsystem ("make distclean");
+	if ($status) { die "error running make distclean"; }
+	chdir "..";
+    }
+    chdir "..";
+    if ($mkdist_mode eq "autogen") { exit 0; }
+
+    # build a tarball from the full tree
     if (! -e tarballs) { mkdir "tarballs"; }
     &vsystem ("tar cvzf tarballs/$distribution.tgz  $distribution");
