build: Bail out early if m4 or lex don't exist.
authorAndre Noll <maan@tuebingen.mpg.de>
Sun, 25 Apr 2021 22:04:05 +0000 (00:04 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Wed, 28 Apr 2021 21:04:10 +0000 (23:04 +0200)
This gives a decent error message on the attempt to run make(1) on a
system where one or both of these essential programs are not installed.

A previous version of the patch used .SHELLSTATUS instead of the
dummy variable, but this did not work with make-4.1 which ships
with Ubuntu-18.04.

Suggested-by: Alex Gietz <oss@mcdinner.de>
Makefile

index 200a7c0d411b5e8cc90c354576d36759a9c63028..c0057a38b89119897044caa0a1eaa705877989ca 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -21,6 +21,15 @@ INSTALL := install
 GZIP := gzip -fn9
 ZCAT := zcat
 
+dummy != $(M4) /dev/null || printf 'failed'
+ifeq ($(dummy), failed)
+$(error m4 is required to build this package)
+endif
+dummy != printf '%%%%\n' | $(LEX) -o /dev/null || printf 'failed'
+ifeq ($(dummy), failed)
+$(error (f)lex is required to build this package)
+endif
+
 DATE_FMT := +%B %Y
 # To get a reproducible build, we use $(SOURCE_DATE_EPOCH) instead of the
 # current time if this variable is set.