From 8cab514b4499b99f3c2ae07fa345b54c4ecc5823 Mon Sep 17 00:00:00 2001 From: Gregory Heytings Date: Sat, 17 Sep 2022 10:39:03 +0000 Subject: [PATCH] Display a help message when building Emacs failed. * Makefile.in (actual-all): New target, replacing the former all target. (advice-on-failure, sanity-check): New targets. (all): Use the new targets. --- Makefile.in | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/Makefile.in b/Makefile.in index 3f811ea60f..2e518de348 100644 --- a/Makefile.in +++ b/Makefile.in @@ -366,7 +366,47 @@ ELN_DESTDIR = gsettings_SCHEMAS = etc/org.gnu.emacs.defaults.gschema.xml -all: ${SUBDIR} info $(gsettings_SCHEMAS:.xml=.valid) src-depending-on-lisp +all: + $(MAKE) actual-all || $(MAKE) advice-on-failure exit-status=$$? + $(MAKE) sanity-check + +.PHONY: actual-all advice-on-failure sanity-check + +actual-all: ${SUBDIR} info $(gsettings_SCHEMAS:.xml=.valid) src-depending-on-lisp + +advice-on-failure: + @echo + @echo " Make failed with exit status ${exit-status}." + @cat Makefile | \ + sed -n '/^# ADVICE-ON-FAILURE-BEGIN/,$${p;/^# ADVICE-ON-FAILURE-END/q};' | \ + sed 's/^# //' | grep -v '^ADVICE-ON-FAILURE-' + @echo + @exit ${exit-status} + +# ADVICE-ON-FAILURE-BEGIN +# You might consider to: +# - run "make bootstrap", which might fix the problem +# - run "git clean -fdx" and run "make" again, which might fix +# the problem if it was not fixed by "make bootstrap" +# !BEWARE! "git clean -fdx" restores the local repository in its +# !BEWARE! pristine state, it deletes all local changes and all +# !BEWARE! untracked files +# - run "make V=1", which displays the full commandes invoked by +# make, to further investigate the problem +# ADVICE-ON-FAILURE-END + +sanity-check: + @v=$$(src/emacs${EXEEXT} --batch --eval \ + '(progn (defun f (n) (if (= 0 n) 1 (* n (f (- n 1))))) (princ (f 10)))' \ + 2> /dev/null); \ + [ "X$$v" == "X3628800" ] && exit 0; \ + echo; \ + echo " Make succeeded, but Emacs is not functional."; \ + cat Makefile | \ + sed -n '/^# ADVICE-ON-FAILURE-BEGIN/,$${p;/^# ADVICE-ON-FAILURE-END/q};' | \ + sed 's/^# //' | grep -v '^ADVICE-ON-FAILURE-'; \ + echo; \ + exit 1 .PHONY: all ${SUBDIR} blessmail epaths-force epaths-force-w32 epaths-force-ns-self-contained etc-emacsver -- 2.35.1