Commit Graph

23 Commits

Author SHA1 Message Date
Alejandro Colomar 336ae0d258 Makefile, README: Break installation into a target for each mandir
Instead of having a monolithic 'make install', break it into
multiple targets such as 'make install-man3'.  This simplifies
packaging, for example in Debian, where they break this project
into several packages: 'manpages' and 'manpages-dev', each
containing different mandirs.

The above allows for multithread installation: 'make -j'

Also, don't overwrite files that don't need to be overwritten, by
having a target for files, which makes use of make's timestamp
comparison.

This allows for much faster installation times.

For comparison, on my laptop (i7-8850H; 6C/12T):

Old Makefile:
	~/src/linux/man-pages$ time sudo make >/dev/null

	real	0m7.509s
	user	0m5.269s
	sys	0m2.614s

	The times with the old makefile, varied a lot, between
	5 and 10 seconds.  The times after applying this patch
	are much more consistent.  BTW, I compared these times to
	the very old Makefile of man-pages-5-09, and those were
	around 3.5 s, so it was a bit of my fault to have such a
	slow Makefile, when I changed the Makefile some weeks ago.

New Makefile (full clean install):
	~/src/linux/man-pages$ time sudo make >/dev/null

	real	0m5.160s
	user	0m4.326s
	sys	0m1.137s
	~/src/linux/man-pages$ time sudo make -j2 >/dev/null

	real	0m1.602s
	user	0m2.529s
	sys	0m0.289s
	~/src/linux/man-pages$ time sudo make -j >/dev/null

	real	0m1.398s
	user	0m2.502s
	sys	0m0.281s

	Here we can see that 'make -j' drops times drastically,
	compared to the old monolithic Makefile.  Not only that,
	but since when we are working with the man pages there
	aren't many pages involved, times will be even better.

	Here are some times with a single page changed (touched):

New Makefile (one page touched):
	~/src/linux/man-pages$ touch man2/membarrier.2
	~/src/linux/man-pages$ time sudo make install
	-	INSTALL	/usr/local/share/man/man2/membarrier.2

	real	0m0.988s
	user	0m0.966s
	sys	0m0.025s
	~/src/linux/man-pages$ touch man2/membarrier.2
	~/src/linux/man-pages$ time sudo make install -j
	-	INSTALL	/usr/local/share/man/man2/membarrier.2

	real	0m0.989s
	user	0m0.943s
	sys	0m0.049s

Also, modify the output of the make install and uninstall commands
so that a line is output for each file or directory that is
installed, similarly to the kernel's Makefile.  This doesn't apply
to html targets, which haven't been changed in this commit.

Also, make sure that for each invocation of $(INSTALL_DIR), no
parents are created, (i.e., avoid `mkdir -p` behavior).  The GNU
make manual states that it can create race conditions.  Instead,
declare as a prerequisite for each directory its parent directory,
and let make resolve the order of creation.

Also, use ':=' instead of '=' to improve performance, by
evaluating each assignment only once.

Ensure than the shell is not called when not needed, by removing
all ";" and quotes in the commands.

See also: <https://stackoverflow.com/q/67862417/6872717>

Specify conventions and rationales used in the Makefile in a comment.

Add copyright.

Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10 10:32:59 +12:00
Michael Kerrisk e43e45b477 Makefile: Remove shebang line
On 5/10/21 7:13 PM, Alejandro Colomar (man-pages) wrote:
> Hi Michael,
>
> On 5/10/21 1:39 AM, Michael Kerrisk (man-pages) wrote:
>>> - Specify shebang
>>
>> Why? It's not quite obvious to me, and the commit message
>> should really explain...
>
> Hmmm.  I have some minor reasons to add it, but not a really good one.
>
> * Some editors don't recognize 'Makefile' as a special name, so the
> shebang helps detecting which language the file is using (e.g., for
> coloring).
>
> * I tend to subdivide a big Makefile into a small Makefile and many
> submakefiles stored in <./libexec/>.  Those obviously need different
> names, and given that the makefile extension is not very standard (I use
> .mk), having a shebang helps knowing what the file is.  After that, I
> also have it on the main Makefile for consistency.   But here we only
> have one Makefile, so it doesn apply very much.

I think I'll remove it. It is kind of idiosyncratic, leaves the
reader asking "why?".

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11 04:34:03 +12:00
Alejandro Colomar 881f51062f Makefile: Fix bug when running in parallel
Prerequisites can run in parallel.  This wouldn't make any sense
when uninstalling and installing again.

For that, use consecutive commands, which run one after the other
even with multiple cores.

Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-10 13:05:42 +12:00
Alejandro Colomar e4b890cdb8 Makefile: Use standard features (IMPORTANT: default prefix changed)
IMPORTANT for distributions:
This changes prefix to be '/usr/local' as is expected by default,
instead of the old '/usr' value.

- Use standard variables:
    - prefix should be '/usr/local'
    - mandir (instead of MANDIR)
    - htmldir (instead of HTDIR)
    - ...
    see <https://www.gnu.org/software/make/manual/html_node/Directory-Variables.html>

- Use standard targets:
    - html (build html files; don't install them)
    - install-html (instead of html)
    - installdirs (instead of 'mkdir -p'/'install -d' inside other targets)
    - ...
    see <https://www.gnu.org/software/make/manual/html_node/Standard-Targets.html#Standard-Targets>

- Use .PHONY

- ?= is not needed.  User input overrides any assignment.  Use =

- Use standard command variables, instead of directly calling commands.
    - $(INSTALL_DATA) (instead of install -m 644)
    - $(INSTALL_DIR) (instead of install -d -m 755 or mkdir -p)
    see <https://www.gnu.org/software/make/manual/html_node/Command-Variables.html#Command-Variables>

- Specify SHELL = /bin/bash

- Specify shebang

- Allow variable html extension (or no extension at all)

Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-10 13:05:36 +12:00
Alejandro Colomar 5f9596780c Makefile: html: Simplify target
mkdir -p doesn't fail if the directory already exists.
Remove redundant checks.

Use .html as default HTDIR.
Remove checks for undefined HTDIR.

Show what the target does, as with other targets (remove '@').

Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-10 11:35:11 +12:00
Michael Kerrisk 86e7d29168 Makefile: Fix html target bug
Switching into the man? subdirectories when running man2html(1)
caused a bug where ".so dir/page.n" links were misinterpreted
(because the directory prefix was interpreted with respect to
the current directory)i, and consequently, the link files
were not correctly rendered. There's no need to switch into the
subdirectories.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-02-16 11:07:36 +01:00
Michael Kerrisk b32a693559 Makefile: Fix lintian.debian.org URL in comment
From the email conversation:

    From: Jakub Wilk <jwilk@jwilk.net>
    Subject: Re: [bug] Makefile: Broken link

    * Alejandro Colomar <colomar.6.4.3@gmail.com>, 2020-08-25, 12:51:
    >Line 32 on the Makefile has a broken link in a comment:
    >
    >https://lintian.debian.org/tags/manpage-has-errors-from-man.html

    This Lintian tag was renamed recently:
    https://salsa.debian.org/lintian/lintian/commit/844278682aafa1da

    The current URL is:
    https://lintian.debian.org/tags/groff-message.html

Reported-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Reported-by: Jakub Wilk <jwilk@jwilk.net>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-08-25 13:55:07 +02:00
Michael Kerrisk bcfa608f87 Makefile: Remove a redundant comment
Reported-by: Дилян Палаузов <dilyan.palauzov@aegee.org>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-11-20 10:38:10 +01:00
Alexander Miller c1a2e851a1 Makefile: Drop compression support and 'screen' target
Compression is already handled properly by distros and
explicit support from the package is not desired nowadays.
The 'screen' target doesn't handle compressed files.
Removal suggested by Mike Frysinger.

Signed-off-by: Alexander Miller <alex.miller@gmx.de>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2016-04-20 14:06:00 +02:00
Alexander Miller 4221001c82 Makefile: Remove line continuation at end of "install" recipe
Signed-off-by: Alexander Miller <alex.miller@gmx.de>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2016-04-18 13:49:54 +01:00
Alexander Miller 6c60c0965f Makefile: tfix
Signed-off-by: Alexander Miller <alex.miller@gmx.de>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2016-04-18 13:49:32 +01:00
Alexander Miller 851124df28 Makefile: Improve recipe for "check-groff-warnings" target
* Fix race condition (don't remove and re-create $GROFF_LOG repeatedly),
* check for failure to create $GROFF_LOG,
* use $TMPDIR if set instead of hardcoded "/tmp",
* quote variables,
* use clobbering redirection (just in case),
* don't create unnecessary subshells,
* add a semicolon for consistency.

Signed-off-by: Alexander Miller <alex.miller@gmx.de>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2016-04-18 13:46:42 +01:00
Alexander Miller 23509e5201 Makefile: Don't leave $(GROFF_LOG) files behind
Convert "GROFF_LOG" into a shell variable local to the
recipe for "check-groff-warnings" target such that the
temporary file is only created when needed.

Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Alexander Miller <alex.miller@gmx.de>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2016-04-18 13:45:58 +01:00
Jakub Wilk cee6023d64 Makefile: tfix
Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-12-07 08:08:56 +01:00
Christoph Thompson 7e8f0b728c Makefile: Add support for compressing manual pages with 'xz'
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-05-11 12:23:56 +02:00
Simon Paillard 251da60bbb Makefile: Add 'check-groff-warnings' target
Add a 'check-groff-warnings' target to check if groff
reports warnings (the underlying problem may be causing
words or sentences not to be displayed) from
http://lintian.debian.org/tags/manpage-has-errors-from-man.html
Some edits by mtk.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2012-10-24 14:53:48 +02:00
Michael Kerrisk 6f92d1d707 Makefile: use "mkdir -p" instead of "-make"
For some casual readers of the Makefile, "mkdir -p" is
probably a little easier to read than the equivalent "-make".

Reported-by: Reuben Thomas <rrt@sc3d.org>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2012-04-17 23:09:08 +12:00
Reuben Thomas 5ee63e782f Makefile: Add "uninstall" as a synonym for "remove" target
"uninstall" is the GNU standard name for the target,
so it'll be the one most users are used to.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2012-04-17 23:09:04 +12:00
Michael Kerrisk 980d08c0d9 POSIX man pages are now in a separate package.
Other minor updates.
2008-06-05 09:52:50 +00:00
Michael Kerrisk 8960f1e41c Remove code relating to man1/README, which no longer exists. 2008-02-22 07:40:09 +00:00
Michael Kerrisk 8636e34a66 Make the install target of man-pages respect the standard
"DESTDIR" variable as well as check the exit status of the
install command so errors aren't ignored.
2007-07-12 16:47:37 +00:00
Michael Kerrisk c7b4971bab Fix setting of 'prefix' macro. 2007-06-10 18:28:39 +00:00
Michael Kerrisk fea681dafb Import of man-pages 1.70 2004-11-03 13:51:07 +00:00