2 # Copyright (C) 2013-2021 all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
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);
13 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);
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}};
23 $html =~ s/\.txt\z/.html/ or $html .= '.html';
24 $t->{"$html : $txt"} = [ "\$(txt2pre) <$txt" ];
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];
36 my $x = (split('/'))[-1];
37 my $pod = "Documentation/$x.pod";
41 warn "W: $pod missing\n";
47 lei-add-external lei-blob lei-config lei-daemon-kill lei-daemon-pid
48 lei-forget-external lei-import lei-init lei-ls-external lei-ls-label
49 lei-tag lei-p2q lei-q)];
50 $v->{-m5} = [ qw(public-inbox-config public-inbox-v1-format
51 public-inbox-v2-format public-inbox-extindex-format
54 $v->{-m7} = [ qw(lei-overview public-inbox-overview public-inbox-tuning
55 public-inbox-glossary) ];
56 $v->{-m8} = [ qw(public-inbox-daemon) ];
57 my @sections = (1, 5, 7, 8);
61 for my $i (@sections) {
62 my $ary = $v->{"-m$i"};
65 my $pod = "Documentation/$m.pod";
66 my $txt = "Documentation/$m.txt";
67 $t->{"$m.$i : $pod"} = [ "\$(podman) -s$i $pod \$@" ];
68 $t->{"$txt : $pod"} = [ "\$(podtext) $pod \$\@+",
69 "touch -r $pod \$\@+",
71 $t->{"Documentation/$m.html : $txt"} = [ "\$(txt2pre) <$txt" ];
72 $t->{".$m.cols : $m.$i"} = [
73 "\@echo CHECK80 $m.$i;".
74 "COLUMNS=80 \$(MAN) ./$m.$i | \$(check_man)" ];
75 $t->{".$m.lexgrog: $m.$i"} = [
76 "\@echo LEXGROG $m.$i;" .
77 "\$(LEXGROG) ./$m.$i >\$\@+ && mv \$\@+ \$@" ];
79 push @{$v->{check_80}}, map { ".$_.cols" } @$ary;
80 push @{$v->{check_lexgrog}}, map { ".$_.lexgrog" } @$ary;
81 my $manuals = $v->{"man$i"} = [ map { "$_.$i" } @$ary ];
82 push @{$v->{manuals}}, @$manuals;
83 push @{$v->{mantxt}}, map { "Documentation/$_.txt" } @$ary;
85 push @dtxt, @{$v->{mantxt}};
86 $v->{docs} = [ @dtxt, 'NEWS' ];
87 $v->{docs_html} = [ map {;
92 $v->{gz_docs} = [ map { "$_.gz" } (@{$v->{docs}},@{$v->{docs_html}}) ];
93 $v->{rsync_docs} = [ @{$v->{gz_docs}}, @{$v->{docs}},
94 @{$v->{docs_html}}, qw(NEWS.atom NEWS.atom.gz)];
96 # external manpages which we host ourselves, since some packages
97 # (currently just Xapian) doesn't host manpages themselves.
98 my @xman = qw(copydatabase.1 xapian-compact.1);
99 $v->{xdocs} = [ map { "Documentation/.$_.txt" } @xman ];
100 $v->{xdocs_html} = [ map { "Documentation/.$_.html" } @xman ];
101 for (@{$v->{xdocs}}) {
103 '$(PERL) -w Documentation/extman.perl $@ >$@+',
107 $html =~ s/\.txt\z/.html/;
108 $t->{"$html : $_"} = [ "\$(txt2pre) <$_" ];
110 $v->{gz_xdocs} = [ map { "$_.gz" } (@{$v->{xdocs_html}}, @{$v->{xdocs}}) ];
111 $v->{rsync_xdocs} = [ @{$v->{gz_xdocs}}, @{$v->{xdocs_html}}, @{$v->{xdocs}} ];
113 my $TGTS = join("\n", map {;
116 "$tgt_prereq\n".join('', map { "\t$_\n" } @$cmds);
119 my $VARS = join("\n", map {;
121 join('', map { "$varname += $_\n" } sort @{$v->{$varname}});
122 } grep(!/^-/, sort keys %$v));
123 $VARS .= "\nRELEASES = ".join(' ', @RELEASES)."\n";
125 # Don't waste user's disk space by installing some pods from
126 # imported code or internal use only
127 my %man3 = map {; # semi-colon tells Perl this is a BLOCK (and not EXPR)
132 "lib/PublicInbox/$_" => "blib/man3/PublicInbox::$mod.\$(MAN3EXT)"
133 } qw(Git.pm Import.pm WWW.pod SaPlugin/ListMirror.pod);
134 my $warn_no_pod = @no_pod ? "\n\t\@echo W: missing .pod: @no_pod\n" : '';
135 chomp(my $lexgrog = `which lexgrog 2>/dev/null`);
136 my $check_lexgrog = $lexgrog ? 'check-lexgrog' : '';
139 NAME => 'PublicInbox', # n.b. camel-case is not our choice
141 # XXX drop "PENDING" in .pod before updating this!
144 AUTHOR => 'Eric Wong <e@80x24.org>',
145 ABSTRACT => 'public-inbox server infrastructure',
146 EXE_FILES => \@EXE_FILES,
148 # note: we use spamc(1), NOT the Perl modules
149 # We also depend on git.
150 # Keep this sorted and synced to the INSTALL document
152 # perl-modules-5.xx or libperl5.xx in Debian-based
153 # part of "perl5" on FreeBSD
154 'Compress::Raw::Zlib' => 0,
155 'Compress::Zlib' => 0,
157 'Digest::SHA' => 0, # rpm: perl-Digest-SHA
158 'Encode' => 2.35, # 2.35 shipped with 5.10.1
159 'IO::Compress::Gzip' => 0,
160 'IO::Uncompress::Gunzip' => 0,
161 'Storable' => 0, # rpm: perl-Storable
162 'Text::ParseWords' => 0, # rpm: perl-Text-ParseWords
164 # Plack is needed for public-inbox-httpd and PublicInbox::WWW
169 # We have more test dependencies, but do not force
170 # users to install them. See INSTALL
172 # All Perl installs I know about have these, but RH-based
173 # distros make them separate even though 'perl' pulls them in
175 'File::Temp' => '0.19', # for ->tmpdir support
178 # ExtUtils::MakeMaker # this file won't run w/o it...
182 FILES => 't/home*/setup* t/home*/t* t/home*/.public-inbox '.
188 my $N = (`{ getconf _NPROCESSORS_ONLN || nproc; } 2>/dev/null` || 1);
189 $N += 1; # account for sleeps in some tests (and makes an IV)
192 # support using eatmydata to speed up tests (apt-get install eatmydata):
193 # https://www.flamingspork.com/projects/libeatmydata/
198 -include Documentation/include.mk
201 check-man :: $check_lexgrog$warn_no_pod
203 # syntax checks are currently GNU make only:
205 @\$(PERL) -w -I lib -c \$<
207 syntax:: \$(my_syntax)
209 changed = \$(shell git ls-files -m)
210 dsyn :: \$(addsuffix .syntax, \$(filter \$(changed), \$(syn_files)))
212 check_manifest := if test -e .git && git ls-files >MANIFEST.gen 2>&1; then \\
213 diff -u MANIFEST MANIFEST.gen; fi
215 check-manifest : MANIFEST
218 # the traditional way running per-*.t processes:
219 check-each :: pure_all
220 \$(EATMYDATA) \$(PROVE) --state=save -bvw -j\$(N)
223 # lightly-tested way to run tests, relies "--state=save" in check-each
224 # for best performance
225 check-run :: pure_all check-man
226 \$(EATMYDATA) \$(PROVE) -bvw t/run.perl :: -j\$(N)
231 lib/PublicInbox/UserContent.pm :: contrib/css/216dark.css
232 \$(PERL) -I lib \$@ \$?
234 # Ensure new .pm files will always be installed by updating
235 # the timestamp of Makefile.PL which forces Makefile to be remade
236 Makefile.PL : MANIFEST
237 touch -r MANIFEST \$@
240 # Install symlinks to ~/bin (which is hopefuly in PATH) which point to
242 # prefix + bindir matches git.git Makefile:
244 bindir = \$(prefix)/bin
247 lei=\$\$(realpath lei.sh) && cd \$(bindir) && \\
248 for x in \$(EXE_FILES); do \\
249 ln -sf "\$\$lei" \$\$(basename "\$\$x"); \\
253 \@case '\$(GNULIB_PATH)' in '') echo >&2 GNULIB_PATH unset; false;; esac
254 git ls-files | UPDATE_COPYRIGHT_HOLDER='all contributors' \\
255 UPDATE_COPYRIGHT_USE_INTERVALS=2 \\
256 xargs \$(GNULIB_PATH)/build-aux/update-copyright