Add a $(MAKE_RESTARTS) check to ghc.mk
[ghc-hetmet.git] / ghc.mk
diff --git a/ghc.mk b/ghc.mk
index 719949b..ab3351d 100644 (file)
--- a/ghc.mk
+++ b/ghc.mk
 
 default : all
 
+# Catch make if it runs away into an infinite loop
+ifeq      "$(MAKE_RESTARTS)" ""
+else ifeq "$(MAKE_RESTARTS)" "1"
+else ifeq "$(MAKE_RESTARTS)" "2"
+else
+$(error Make has restarted itself $(MAKE_RESTARTS) times; is there a makefile bug?)
+endif
+
 # Just bring makefiles up to date:
 .PHONY: just-makefiles
 just-makefiles: