+my $v = {};
+my $t = {};
+
+# do not sort
+my @RELEASES = qw(v1.6.1 v1.6.0 v1.5.0 v1.4.0 v1.3.0 v1.2.0 v1.1.0-pre1 v1.0.0);
+
+$v->{news_deps} = [ map { "Documentation/RelNotes/$_.eml" } @RELEASES ];
+$v->{txt} = [ qw(INSTALL README COPYING TODO HACKING) ];
+my @dtxt = grep(m!\ADocumentation/[^/]+\.txt\z!, @manifest);
+push @dtxt, 'Documentation/standards.txt';
+push @dtxt, 'Documentation/flow.txt';
+push @dtxt, @{$v->{txt}};
+for my $txt (@dtxt) {
+ my $html = $txt;
+ $html =~ s/\.txt\z/.html/ or $html .= '.html';
+ $t->{"$html : $txt"} = [ "\$(txt2pre) <$txt" ];
+}
+$v->{t_slash_star_dot_t} = [ grep(m!\At/.*\.t\z!, @manifest) ];
+my @scripts = qw(scripts/ssoma-replay); # legacy
+my @syn = (@EXE_FILES, grep(m!^lib/.*\.pm$!, @manifest), @scripts);
+@syn = grep(!/DSKQXS\.pm/, @syn) if !eval { require IO::KQueue };
+@syn = grep(!/Unsubscribe\.pm/, @syn) if !eval { require Crypt::CBC };
+@syn = grep(!/SaPlugin/, @syn) if !eval { require Mail::SpamAssasin };
+$v->{syn_files} = \@syn;
+$v->{my_syntax} = [map { "$_.syntax" } @syn];
+my @no_pod;
+$v->{-m1} = [ map {
+ my $x = (split('/'))[-1];
+ my $pod = "Documentation/$x.pod";
+ if (-f $pod) {
+ $x;
+ } else {
+ warn "W: $pod missing\n";
+ push @no_pod, $x;
+ ();
+ }
+ } @EXE_FILES,
+ qw(
+ lei-add-external lei-add-watch lei-blob lei-config lei-convert
+ lei-daemon-kill lei-daemon-pid lei-edit-search lei-export-kw
+ lei-forget-external lei-forget-mail-sync lei-forget-search
+ lei-import lei-index lei-init lei-inspect lei-lcat
+ lei-ls-external lei-ls-label lei-ls-mail-source lei-ls-mail-sync
+ lei-ls-search lei-ls-watch lei-mail-diff lei-p2q lei-q
+ lei-rediff lei-refresh-mail-sync lei-rm lei-rm-watch lei-tag
+ lei-up)];
+$v->{-m5} = [ qw(public-inbox-config public-inbox-v1-format
+ public-inbox-v2-format public-inbox-extindex-format
+ lei-mail-formats lei-store-format
+ ) ];
+$v->{-m7} = [ qw(lei-mail-sync-overview lei-overview lei-security
+ public-inbox-overview public-inbox-tuning
+ public-inbox-glossary) ];
+$v->{-m8} = [ qw(public-inbox-daemon lei-daemon) ];
+my @sections = (1, 5, 7, 8);
+$v->{check_80} = [];
+$v->{manuals} = [];
+$v->{mantxt} = [];
+for my $i (@sections) {
+ my $ary = $v->{"-m$i"};
+ $v->{"m$i"} = $ary;
+ for my $m (@$ary) {
+ my $pod = "Documentation/$m.pod";
+ my $txt = "Documentation/$m.txt";
+ $t->{"$m.$i : $pod"} = [ "\$(podman) -s$i $pod \$@" ];
+ $t->{"$txt : $m.$i"} = [ "\$(man2text) ./$m.$i >\$\@+",
+ "touch -r $pod \$\@+",
+ "mv \$\@+ \$@" ];
+ $t->{"Documentation/$m.html : $txt"} = [ "\$(txt2pre) <$txt" ];
+ $t->{".$m.cols : $m.$i"} = [
+ "\@echo CHECK80 $m.$i;".
+ "COLUMNS=80 \$(MAN) ./$m.$i | \$(check_man)",
+ '>$@' ];
+ $t->{".$m.lexgrog: $m.$i"} = [
+ "\@echo LEXGROG $m.$i;" .
+ "\$(LEXGROG) ./$m.$i >\$\@+ && mv \$\@+ \$@" ];
+ }
+ push @{$v->{check_80}}, map { ".$_.cols" } @$ary;
+ push @{$v->{check_lexgrog}}, map { ".$_.lexgrog" } @$ary;
+ my $manuals = $v->{"man$i"} = [ map { "$_.$i" } @$ary ];
+ push @{$v->{manuals}}, @$manuals;
+ push @{$v->{mantxt}}, map { "Documentation/$_.txt" } @$ary;
+}
+push @dtxt, @{$v->{mantxt}};
+$v->{docs} = [ @dtxt, 'NEWS' ];
+$v->{docs_html} = [ map {;
+ my $x = $_;
+ $x =~ s/\.txt\z//;
+ "$x.html"
+ } @{$v->{docs}} ];
+$v->{gz_docs} = [ map { "$_.gz" } (@{$v->{docs}},@{$v->{docs_html}}) ];
+$v->{rsync_docs} = [ @{$v->{gz_docs}}, @{$v->{docs}},
+ @{$v->{docs_html}}, qw(NEWS.atom NEWS.atom.gz)];
+
+my $TGTS = join("\n", map {;
+ my $tgt_prereq = $_;
+ my $cmds = $t->{$_};
+ "$tgt_prereq\n".join('', map { "\t$_\n" } @$cmds);
+} sort keys %$t);
+
+my $VARS = join("\n", map {;
+ my $varname = $_;
+ join('', map { "$varname += $_\n" } sort @{$v->{$varname}});
+} grep(!/^-/, sort keys %$v));
+$VARS .= "\nRELEASES = ".join(' ', @RELEASES)."\n";