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 push @manifest, 'lib/PublicInbox.pm'; # generated
9 my @EXE_FILES = grep(m!^script/!, @manifest);
14 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);
16 $v->{news_deps} = [ map { "Documentation/RelNotes/$_.eml" } @RELEASES ];
17 $v->{txt} = [ qw(INSTALL README COPYING TODO HACKING) ];
18 my @dtxt = grep(m!\ADocumentation/[^/]+\.txt\z!, @manifest);
19 push @dtxt, 'Documentation/standards.txt';
20 push @dtxt, 'Documentation/flow.txt';
21 push @dtxt, @{$v->{txt}};
24 $html =~ s/\.txt\z/.html/ or $html .= '.html';
25 $t->{"$html : $txt"} = [ "\$(txt2pre) <$txt" ];
27 $v->{t_slash_star_dot_t} = [ grep(m!\At/.*\.t\z!, @manifest) ];
28 my @scripts = qw(scripts/ssoma-replay); # legacy
29 my @syn = (@EXE_FILES, grep(m!^lib/.*\.pm$!, @manifest), @scripts);
30 @syn = grep(!/DSKQXS\.pm/, @syn) if !eval { require IO::KQueue };
31 @syn = grep(!/Unsubscribe\.pm/, @syn) if !eval { require Crypt::CBC };
32 @syn = grep(!/SaPlugin/, @syn) if !eval { require Mail::SpamAssasin };
33 $v->{syn_files} = \@syn;
34 $v->{my_syntax} = [map { "$_.syntax" } @syn];
37 my $x = (split('/'))[-1];
38 my $pod = "Documentation/$x.pod";
42 warn "W: $pod missing\n";
48 lei-add-external lei-blob lei-config lei-convert lei-edit-search
49 lei-daemon-kill lei-daemon-pid lei-forget-external lei-forget-search
50 lei-import lei-index lei-init lei-lcat lei-ls-external lei-ls-label
51 lei-ls-mail-sync lei-ls-search lei-p2q lei-q lei-rediff lei-rm lei-tag
53 $v->{-m5} = [ qw(public-inbox-config public-inbox-v1-format
54 public-inbox-v2-format public-inbox-extindex-format
55 lei-mail-formats lei-store-format
57 $v->{-m7} = [ qw(lei-overview lei-security
58 public-inbox-overview public-inbox-tuning
59 public-inbox-glossary) ];
60 $v->{-m8} = [ qw(public-inbox-daemon) ];
61 my @sections = (1, 5, 7, 8);
65 for my $i (@sections) {
66 my $ary = $v->{"-m$i"};
69 my $pod = "Documentation/$m.pod";
70 my $txt = "Documentation/$m.txt";
71 $t->{"$m.$i : $pod"} = [ "\$(podman) -s$i $pod \$@" ];
72 $t->{"$txt : $pod"} = [ "\$(podtext) $pod \$\@+",
73 "touch -r $pod \$\@+",
75 $t->{"Documentation/$m.html : $txt"} = [ "\$(txt2pre) <$txt" ];
76 $t->{".$m.cols : $m.$i"} = [
77 "\@echo CHECK80 $m.$i;".
78 "COLUMNS=80 \$(MAN) ./$m.$i | \$(check_man)",
80 $t->{".$m.lexgrog: $m.$i"} = [
81 "\@echo LEXGROG $m.$i;" .
82 "\$(LEXGROG) ./$m.$i >\$\@+ && mv \$\@+ \$@" ];
84 push @{$v->{check_80}}, map { ".$_.cols" } @$ary;
85 push @{$v->{check_lexgrog}}, map { ".$_.lexgrog" } @$ary;
86 my $manuals = $v->{"man$i"} = [ map { "$_.$i" } @$ary ];
87 push @{$v->{manuals}}, @$manuals;
88 push @{$v->{mantxt}}, map { "Documentation/$_.txt" } @$ary;
90 push @dtxt, @{$v->{mantxt}};
91 $v->{docs} = [ @dtxt, 'NEWS' ];
92 $v->{docs_html} = [ map {;
97 $v->{gz_docs} = [ map { "$_.gz" } (@{$v->{docs}},@{$v->{docs_html}}) ];
98 $v->{rsync_docs} = [ @{$v->{gz_docs}}, @{$v->{docs}},
99 @{$v->{docs_html}}, qw(NEWS.atom NEWS.atom.gz)];
101 # external manpages which we host ourselves, since some packages
102 # (currently just Xapian) doesn't host manpages themselves.
103 my @xman = qw(copydatabase.1 xapian-compact.1);
104 $v->{xdocs} = [ map { "Documentation/.$_.txt" } @xman ];
105 $v->{xdocs_html} = [ map { "Documentation/.$_.html" } @xman ];
106 for (@{$v->{xdocs}}) {
108 '$(PERL) -w Documentation/extman.perl $@ >$@+',
112 $html =~ s/\.txt\z/.html/;
113 $t->{"$html : $_"} = [ "\$(txt2pre) <$_" ];
115 $v->{gz_xdocs} = [ map { "$_.gz" } (@{$v->{xdocs_html}}, @{$v->{xdocs}}) ];
116 $v->{rsync_xdocs} = [ @{$v->{gz_xdocs}}, @{$v->{xdocs_html}}, @{$v->{xdocs}} ];
118 my $TGTS = join("\n", map {;
121 "$tgt_prereq\n".join('', map { "\t$_\n" } @$cmds);
124 my $VARS = join("\n", map {;
126 join('', map { "$varname += $_\n" } sort @{$v->{$varname}});
127 } grep(!/^-/, sort keys %$v));
128 $VARS .= "\nRELEASES = ".join(' ', @RELEASES)."\n";
130 # Don't waste user's disk space by installing some pods from
131 # imported code or internal use only
132 my %man3 = map {; # semi-colon tells Perl this is a BLOCK (and not EXPR)
137 "lib/PublicInbox/$_" => "blib/man3/PublicInbox::$mod.\$(MAN3EXT)"
138 } qw(Git.pm Import.pm WWW.pod SaPlugin/ListMirror.pod);
139 my $warn_no_pod = @no_pod ? "\n\t\@echo W: missing .pod: @no_pod\n" : '';
140 chomp(my $lexgrog = `which lexgrog 2>/dev/null`);
141 my $check_lexgrog = $lexgrog ? 'check-lexgrog' : '';
144 NAME => 'PublicInbox', # n.b. camel-case is not our choice
146 # XXX drop "PENDING" in .pod before updating this!
147 VERSION => '1.7.0.PENDING',
149 AUTHOR => 'Eric Wong <e@80x24.org>',
150 ABSTRACT => 'public-inbox server infrastructure',
151 EXE_FILES => \@EXE_FILES,
153 # note: we use spamc(1), NOT the Perl modules
154 # We also depend on git.
155 # Keep this sorted and synced to the INSTALL document
157 # perl-modules-5.xx or libperl5.xx in Debian-based
158 # part of "perl5" on FreeBSD
159 'Compress::Raw::Zlib' => 0,
160 'Compress::Zlib' => 0,
162 'Digest::SHA' => 0, # rpm: perl-Digest-SHA
163 'Encode' => 2.35, # 2.35 shipped with 5.10.1
164 'IO::Compress::Gzip' => 0,
165 'IO::Uncompress::Gunzip' => 0,
166 'Storable' => 0, # rpm: perl-Storable
167 'Text::ParseWords' => 0, # rpm: perl-Text-ParseWords
169 # Plack is needed for public-inbox-httpd and PublicInbox::WWW
174 # We have more test dependencies, but do not force
175 # users to install them. See INSTALL
177 # All Perl installs I know about have these, but RH-based
178 # distros make them separate even though 'perl' pulls them in
180 'File::Temp' => '0.19', # for ->tmpdir support
183 # ExtUtils::MakeMaker # this file won't run w/o it...
187 FILES => 't/home*/setup* t/home*/t* t/home*/.public-inbox '.
193 my $N = (`{ getconf _NPROCESSORS_ONLN || nproc; } 2>/dev/null` || 1);
194 $N += 1; # account for sleeps in some tests (and makes an IV)
197 # support using eatmydata to speed up tests (apt-get install eatmydata):
198 # https://www.flamingspork.com/projects/libeatmydata/
203 -include Documentation/include.mk
206 check-man :: $check_lexgrog$warn_no_pod
208 # syntax checks are currently GNU make only:
210 @\$(PERL) -w -I lib -c \$<
212 syntax:: \$(my_syntax)
214 changed = \$(shell git ls-files -m)
215 dsyn :: \$(addsuffix .syntax, \$(filter \$(changed), \$(syn_files)))
217 check_manifest := if test -e .git && git ls-files >MANIFEST.gen 2>&1; then \\
218 diff -u MANIFEST MANIFEST.gen; fi
220 check-manifest : MANIFEST
223 # the traditional way running per-*.t processes:
224 check-each :: pure_all
225 \$(EATMYDATA) \$(PROVE) --state=save -bvw -j\$(N)
228 # lightly-tested way to run tests, relies "--state=save" in check-each
229 # for best performance
230 check-run :: pure_all check-man
231 \$(EATMYDATA) \$(PROVE) -bvw t/run.perl :: -j\$(N)
236 lib/PublicInbox/UserContent.pm :: contrib/css/216dark.css
237 \$(PERL) -I lib \$@ \$?
239 # Ensure new .pm files will always be installed by updating
240 # the timestamp of Makefile.PL which forces Makefile to be remade
241 Makefile.PL : MANIFEST
242 touch -r MANIFEST \$@
245 # Install symlinks to ~/bin (which is hopefuly in PATH) which point to
247 # prefix + bindir matches git.git Makefile:
249 bindir = \$(prefix)/bin
250 symlink-install : lib/PublicInbox.pm
252 lei=\$\$(realpath lei.sh) && cd \$(bindir) && \\
253 for x in \$(EXE_FILES); do \\
254 ln -sf "\$\$lei" \$\$(basename "\$\$x"); \\
257 pure_all :: lib/PublicInbox.pm
258 lib/PublicInbox.pm : FORCE
259 VERSION=\$(VERSION) \$(PERL) -w ./version-gen.perl
262 \@case '\$(GNULIB_PATH)' in '') echo >&2 GNULIB_PATH unset; false;; esac
263 git ls-files | UPDATE_COPYRIGHT_HOLDER='all contributors' \\
264 UPDATE_COPYRIGHT_USE_INTERVALS=2 \\
265 xargs \$(GNULIB_PATH)/build-aux/update-copyright