+ set_var ("gnulib_commit", $gnulib_commit);
+
+ # If we don't already have that Gnulib commit, update Gnulib.
+ `git rev-parse $gnulib_commit`;
+ if ($? != 0) {
+ start_step ("Updating Gnulib to obtain commit");
+ run ("git fetch gnulib");
+ }
+
+ # Extract gnulib source.
+ start_step ("Extract Gnulib source");
+ run ("git archive --format=tar --prefix=gnulib/ $gnulib_commit | (cd $builddir && tar xf -)");
+
+ # Bootstrap.
+ start_step ("Bootstrap (make -f Smake)");
+ run ("cd $builddir/pspp$build_number && make -f Smake", "bootstrap");
+
+ # Configure.
+ start_step ("Configure source");
+ run ("cd $builddir/pspp$build_number && mkdir _build && cd _build && ../configure", "configure");
+
+ # Distribute.
+ start_step ("Make source tarball");
+ run ("cd $builddir/pspp$build_number/_build && make dist", "dist");
+ my $tarname = "pspp-$version.tar.gz";
+ $tarball = save_result ("$builddir/pspp$build_number/_build/$tarname", 1);
+
+ # Build user manual
+ start_step ("Build user manual");
+ run ("cd $builddir/pspp$build_number && cp _build/doc/*.texi doc/");
+ run ("cd $builddir/pspp$build_number && GENDOCS_TEMPLATE_DIR=$topdir $topdir/gendocs.sh -s doc/pspp.texinfo -o $abs_resultsdir/user-manual --email bug-gnu-pspp\@gnu.org pspp \"GNU PSPP User Manual\"", "user-manual");
+ saved_result ("user-manual");
+
+ # Build developer's guide
+ start_step ("Build developers guide");
+ run ("cd $builddir/pspp$build_number && GENDOCS_TEMPLATE_DIR=$topdir $topdir/gendocs.sh -s doc/pspp-dev.texinfo -o $abs_resultsdir/dev-guide --email bug-gnu-pspp\@gnu.org pspp-dev \"GNU PSPP Developers Guide\"", "dev-guide");
+ saved_result ("dev-guide");
+} else {
+ $tarball = $ARGV[0];
+}
+
+if ($build_binary) {
+ start_step ("Determining $tarball target directory");
+ my $sample_filename = `zcat $tarball | tar tf - | head -1`;
+ my ($tarball_dir) = $sample_filename =~ m%^(?:[./])*([^/]+)/%;
+ set_var ("dist_dir", $tarball_dir);
+
+ start_step ("Extracting $tarball into $builddir/$tarball_dir");
+ run ("zcat $tarball | (cd $builddir && tar xf -)");
+
+ start_step ("Extracting tar version");
+ my ($version) = `cd $builddir/$tarball_dir && ./configure --version | head -1`
+ =~ /configure (\S+)$/;
+ set_var ("dist_version", $version);
+ my ($binary_version) = "$version-$builder-build$build_number";
+ set_var ("binary_version", $binary_version);
+
+ start_step ("Configuring");
+ run ("chmod -R a-w $builddir/$tarball_dir");
+ run ("chmod u+w $builddir/$tarball_dir");
+ run ("mkdir $builddir/$tarball_dir/_build");
+ run ("chmod a-w $builddir/$tarball_dir");
+ my $ok = try_run ("cd $builddir/$tarball_dir/_build && ../configure --enable-relocatable --prefix=''", "bin-configure");
+ for my $basename ("config.h", "config.log") {
+ save_result_if_exists ("$builddir/$tarball_dir/_build/$basename");
+ }
+ fail () if !$ok;
+
+ start_step ("Build");
+ run ("cd $builddir/$tarball_dir/_build && make", "build");
+
+ start_step ("Install");
+ run ("cd $builddir/$tarball_dir/_build && make install DESTDIR=\$PWD/pspp-$binary_version", "install");
+
+ start_step ("Make binary distribution");
+ run ("cd $builddir/$tarball_dir/_build && tar cfz pspp-$binary_version.tar.gz pspp-$binary_version");
+ save_result ("$builddir/$tarball_dir/_build/pspp-$binary_version.tar.gz", 1);
+
+ start_step ("Check");
+ $ok = try_run ("cd $builddir/$tarball_dir/_build && make check", "check");
+ for my $basename ("tests/testsuite.log", "tests/testsuite.dir") {
+ save_result_if_exists ("$builddir/$tarball_dir/_build/$basename");
+ }
+ fail () if !$ok;
+
+ start_step ("Uninstall");
+ run ("cd $builddir/$tarball_dir/_build && make uninstall DESTDIR=\$PWD/pspp-$binary_version", "uninstall");
+
+ start_step ("Check uninstall");
+ run ("cd $builddir/$tarball_dir/_build && make distuninstallcheck distuninstallcheck_dir=\$PWD/pspp-$binary_version", "distuninstallcheck");
+
+ # distcleancheck