]> Sergey Matveev's repositories - public-inbox.git/blob - Makefile.PL
add gcf2 client and executable script
[public-inbox.git] / Makefile.PL
1 #!/usr/bin/perl -w
2 # Copyright (C) 2013-2020 all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
4 use strict;
5 use ExtUtils::MakeMaker;
6 open my $m, '<', 'MANIFEST' or die "open(MANIFEST): $!\n";
7 chomp(my @manifest = (<$m>));
8 my @EXE_FILES = grep(m!^script/!, @manifest);
9 my $v = {};
10 my $t = {};
11
12 # do not sort
13 my @RELEASES = qw(v1.6.0 v1.5.0 v1.4.0 v1.3.0 v1.2.0 v1.1.0-pre1 v1.0.0);
14
15 $v->{news_deps} = [ map { "Documentation/RelNotes/$_.eml" } @RELEASES ];
16 $v->{txt} = [ qw(INSTALL README COPYING TODO HACKING) ];
17 my @dtxt = grep(m!\ADocumentation/[^/]+\.txt\z!, @manifest);
18 push @dtxt, 'Documentation/standards.txt';
19 push @dtxt, 'Documentation/flow.txt';
20 push @dtxt, @{$v->{txt}};
21 for my $txt (@dtxt) {
22         my $html = $txt;
23         $html =~ s/\.txt\z/.html/ or $html .= '.html';
24         $t->{"$html : $txt"} = [ "\$(txt2pre) <$txt" ];
25 }
26 $v->{t_slash_star_dot_t} = [ grep(m!\At/.*\.t\z!, @manifest) ];
27 my @scripts = qw(scripts/ssoma-replay); # legacy
28 my @syn = (@EXE_FILES, grep(m!^lib/.*\.pm$!, @manifest), @scripts);
29 @syn = grep(!/DSKQXS\.pm/, @syn) if !eval { require IO::KQueue };
30 @syn = grep(!/Unsubscribe\.pm/, @syn) if !eval { require Crypt::CBC };
31 @syn = grep(!/SaPlugin/, @syn) if !eval { require Mail::SpamAssasin };
32 $v->{syn_files} = \@syn;
33 $v->{my_syntax} = [map { "$_.syntax" } @syn];
34 $v->{-m1} = [ map { (split('/'))[-1] } @EXE_FILES ];
35 $v->{-m5} = [ qw(public-inbox-config public-inbox-v1-format
36                 public-inbox-v2-format) ];
37 $v->{-m7} = [ qw(public-inbox-overview public-inbox-tuning) ];
38 $v->{-m8} = [ qw(public-inbox-daemon) ];
39 my @sections = (1, 5, 7, 8);
40 $v->{check_80} = [];
41 $v->{manuals} = [];
42 $v->{mantxt} = [];
43 for my $i (@sections) {
44         my $ary = $v->{"-m$i"};
45         $v->{"m$i"} = $ary;
46         for my $m (@$ary) {
47                 my $pod = "Documentation/$m.pod";
48                 my $txt = "Documentation/$m.txt";
49                 $t->{"$m.$i : $pod"} = [ "\$(podman) -s$i $pod \$@" ];
50                 $t->{"$txt : $pod"} = [ "\$(podtext) $pod \$\@+",
51                                         "touch -r $pod \$\@+",
52                                         "mv \$\@+ \$@" ];
53                 $t->{"Documentation/$m.html : $txt"} = [ "\$(txt2pre) <$txt" ];
54                 $t->{".$m.cols : $m.$i"} = [
55                         "\@echo CHECK80 $m.$i;".
56                         "COLUMNS=80 \$(MAN) ./$m.$i | \$(check_man)" ];
57         }
58         push @{$v->{check_80}}, map { ".$_.cols" } @$ary;
59         my $manuals = $v->{"man$i"} = [ map { "$_.$i" } @$ary ];
60         push @{$v->{manuals}}, @$manuals;
61         push @{$v->{mantxt}}, map { "Documentation/$_.txt" } @$ary;
62 }
63 push @dtxt, @{$v->{mantxt}};
64 $v->{docs} = [ @dtxt, 'NEWS' ];
65 $v->{docs_html} = [ map {;
66                 my $x = $_;
67                 $x =~ s/\.txt\z//;
68                 "$x.html"
69         } @{$v->{docs}} ];
70 $v->{gz_docs} = [ map { "$_.gz" } (@{$v->{docs}},@{$v->{docs_html}}) ];
71 $v->{rsync_docs} = [ @{$v->{gz_docs}}, @{$v->{docs}},
72         @{$v->{docs_html}}, qw(NEWS.atom NEWS.atom.gz)];
73
74 # filter out public-inbox-gcf2 from the website, it's an internal command
75 for my $var (qw(gz_docs rsync_docs)) {
76         @{$v->{$var}} = grep(!/-gcf2/, @{$v->{$var}});
77 }
78
79 # external manpages which we host ourselves, since some packages
80 # (currently just Xapian) doesn't host manpages themselves.
81 my @xman = qw(copydatabase.1 xapian-compact.1);
82 $v->{xdocs} = [ map { "Documentation/.$_.txt" } @xman ];
83 $v->{xdocs_html} = [ map { "Documentation/.$_.html" } @xman ];
84 for (@{$v->{xdocs}}) {
85         $t->{"$_:"} = [
86                 '$(PERL) -w Documentation/extman.perl $@ >$@+',
87                 'mv $@+ $@'
88         ];
89         my $html = $_;
90         $html =~ s/\.txt\z/.html/;
91         $t->{"$html : $_"} = [ "\$(txt2pre) <$_" ];
92 }
93 $v->{gz_xdocs} = [ map { "$_.gz" } (@{$v->{xdocs_html}}, @{$v->{xdocs}}) ];
94 $v->{rsync_xdocs} = [ @{$v->{gz_xdocs}}, @{$v->{xdocs_html}}, @{$v->{xdocs}} ];
95
96 my $TGTS = join("\n", map {;
97         my $tgt_prereq = $_;
98         my $cmds = $t->{$_};
99         "$tgt_prereq\n".join('', map { "\t$_\n" } @$cmds);
100 } sort keys %$t);
101
102 my $VARS = join("\n", map {;
103         my $varname = $_;
104         join('', map { "$varname += $_\n" } sort @{$v->{$varname}});
105 } grep(!/^-/, sort keys %$v));
106 $VARS .= "\nRELEASES = ".join(' ', @RELEASES)."\n";
107
108 # Don't waste user's disk space by installing some pods from
109 # imported code or internal use only
110 my %man3 = map {; # semi-colon tells Perl this is a BLOCK (and not EXPR)
111         my $base = $_;
112         my $mod = $base;
113         $mod =~ s!/!::!g;
114         $mod =~ s/\.\w+\z//;
115         "lib/PublicInbox/$_" => "blib/man3/PublicInbox::$mod.3"
116 } qw(Git.pm Import.pm WWW.pod SaPlugin/ListMirror.pod);
117
118 WriteMakefile(
119         NAME => 'PublicInbox',
120         VERSION => '1.6.0',
121         AUTHOR => 'Eric Wong <e@80x24.org>',
122         ABSTRACT => 'public-inbox server infrastructure',
123         EXE_FILES => \@EXE_FILES,
124         PREREQ_PM => {
125                 # note: we use spamc(1), NOT the Perl modules
126                 # We also depend on git.
127                 # Keep this sorted and synced to the INSTALL document
128
129                 # libperl$PERL_VERSION,
130                 # `perl5' on FreeBSD
131                 # perl-Digest-SHA on RH-based
132                 'Digest::SHA' => 0,
133
134                 # libperl$PERL_VERSION or libencode-perl on Debian,
135                 # `perl5' on FreeBSD
136                 'Encode' => 2.35, # 2.35 shipped with 5.10.1
137
138                 # libperl$PERL_VERSION + perl-modules-$PERL_VERSION
139                 'Compress::Raw::Zlib' => 0,
140                 'Compress::Zlib' => 0,
141                 'IO::Compress::Gzip' => 0,
142
143                 # Plack is needed for public-inbox-httpd and PublicInbox::WWW
144                 # 'Plack' => 0,
145
146                 # TODO: this should really be made optional...
147                 'URI::Escape' => 0,
148
149                 # We have more test dependencies, but do not force
150                 # users to install them.  See INSTALL
151
152                 # All Perl installs I know about have these, but RH-based
153                 # distros make them separate even though 'perl' pulls them in
154                 'File::Path' => 0,
155                 'File::Temp' => '0.19', # for ->tmpdir support
156                 'Getopt::Long' => 0,
157                 'Exporter' => 0,
158                 # ExtUtils::MakeMaker # this file won't run w/o it...
159         },
160         MAN3PODS => \%man3,
161 );
162
163 sub MY::postamble {
164         my $N = (`{ getconf _NPROCESSORS_ONLN || nproc; } 2>/dev/null` || 1);
165         $N += 1; # account for sleeps in some tests (and makes an IV)
166         <<EOF;
167 PROVE = prove
168 # support using eatmydata to speed up tests (apt-get install eatmydata):
169 # https://www.flamingspork.com/projects/libeatmydata/
170 EATMYDATA =
171 N = $N
172 -include config.mak
173 $VARS
174 -include Documentation/include.mk
175 $TGTS
176
177 # syntax checks are currently GNU make only:
178 %.syntax :: %
179         @\$(PERL) -w -I lib -c \$<
180
181 syntax:: \$(my_syntax)
182
183 changed = \$(shell git ls-files -m)
184 dsyn :: \$(addsuffix .syntax, \$(filter \$(changed), \$(syn_files)))
185
186 check_manifest := if test -e .git && git ls-files >MANIFEST.gen 2>&1; then \\
187                 diff -u MANIFEST MANIFEST.gen; fi
188
189 check-manifest : MANIFEST
190         \$(check_manifest)
191
192 # the traditional way running per-*.t processes:
193 check-each :: pure_all
194         \$(EATMYDATA) \$(PROVE) --state=save -bvw -j\$(N)
195         -@\$(check_manifest)
196
197 # lightly-tested way to run tests, relies "--state=save" in check-each
198 # for best performance
199 check-run :: pure_all check-man
200         \$(EATMYDATA) \$(PROVE) -bvw t/run.perl :: -j\$(N)
201         -@\$(check_manifest)
202
203 check :: check-each
204
205 lib/PublicInbox/UserContent.pm :: contrib/css/216dark.css
206         \$(PERL) -I lib \$@ \$?
207
208 # Ensure new .pm files will always be installed by updating
209 # the timestamp of Makefile.PL which forces Makefile to be remade
210 Makefile.PL : MANIFEST
211         touch -r MANIFEST \$@
212         \$(PERLRUN) \$@
213
214 EOF
215 }