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