Makefile: Use standard variables and locations
Hi Michael,
There are a few points I think we should fix in the Makefile:
- Use standard variables:
* mandir (instead of MANDIR)
* htmldir (instead of HTDIR)
(see
<https://www.gnu.org/software/make/manual/html_node/Directory-Variables.html>)
- Use standard targets:
* separate html into html and install-html
* installdirs (instead of having 'mkdir -p'/'install -d' embedded in
targets)
(see
<https://www.gnu.org/software/make/manual/html_node/Standard-Targets.html#Standard-Targets>)
- '?=' is not needed, I think. When a user defines a variable in the command line, that overwrites any definition in the Makefile.
- Is '|| exit $$?' really needed? AFAIK, make exits on error. Maybe there's a corner case that make doesn't handle well and exit does, though. I don't know.
- Use $(INSTALL_DATA) instead of using install directly.
- Specify SHELL = /bin/sh
Any thoughts?
Cheers,
Alex
Signature · 3 lines
Alejandro Colomar Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/ http://www.alejandro-colomar.es/
* Alejandro Colomar <[email protected]>, 2021-03-20, 22:03:
Quoted 1 line
- Is '|| exit $$?' really needed? AFAIK, make exits on error.
Make catches errors, but shell doesn't by default. So if a recipe contains more than a simple command, you need to care of error handling yourself. For example:
$ printf 'all:\n\tfalse; echo moo\n' > Makefile
$ make false; echo moo moo
$ echo $? 0
Quoted 1 line
- Specify SHELL =
/bin/sh
This is the default on Unix-like systems.
Signature · 1 line
Jakub Wilk
Hi Jakub,
Quoted 7 lines · Jakub Wilk
* Alejandro Colomar <[email protected]>, 2021-03-20, 22:03:
Quoted 1 line
- Is '|| exit $$?' really needed? AFAIK, make exits on error.
Make catches errors, but shell doesn't by default. So if a recipe contains more than a simple command, you need to care of error handling yourself. For example:
Quoted 8 lines
$ printf 'all:\n\tfalse; echo moo\n' > Makefile$ make false; echo moo moo$ echo $? 0
Ahh, I see.
Quoted 4 lines
Quoted 2 lines
- Specify SHELL =
/bin/shThis is the default on Unix-like systems.
Humm, yes, it feels better to not specify it. I was just following GNU recommendations, but this one doesn't make much sense. I'll remove it.
Thanks,
Alex
Signature · 3 lines
Alejandro Colomar Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/ http://www.alejandro-colomar.es/