# HG changeset patch # User Oleksandr Gavenko # Date 1609540074 -7200 # Node ID 3685e2321a9bfdcb8ce05a8677ec62445d3c7ff6 # Parent 72275301c19df7f4ac503f55473c7aea2bf955c9 Made "upgrade" target idempotent and added it as dependency to "install". diff -r 72275301c19d -r 3685e2321a9b Makefile --- a/Makefile Fri Jan 01 21:34:09 2021 +0200 +++ b/Makefile Sat Jan 02 00:27:54 2021 +0200 @@ -107,25 +107,20 @@ ################################################################ # Install/uninstall targets. -.PHONY: check-install-comapt -check-install-comapt: - \ -if [ -f ~/.emacs ]; then \ - echo Old style install detected, run '"$(MAKE) upgrade"' first; \ - false; \ -fi - \ -if [ -f $(emacsdir)/init.el ]; then \ - if [ ! -f $(COMPAT_FILE) ]; then \ - echo $(COMPAT_FILE) missing, run '"$(MAKE) upgrade"' first; \ - exit 1; \ - fi; \ -fi - read ver <$(COMPAT_FILE); if [ "$$ver" -ne $(COMPAT_VER) ]; then echo "*** "Run '"$(MAKE) upgrade"' first" ***"; exit 1; fi +ifneq '' '$(filter upgrade,$(MAKECMDGOALS))' + ifeq '' '$(filter install%,$(MAKECMDGOALS))' + $(error "upgrade" should be invoked from "install") + endif +endif .PHONY: upgrade upgrade: \ +if [[ -f ~/.emacs ]]; then \ + echo An old style install detected, delete ~/.emacs first.; \ + false; \ +fi + \ [[ -f $(COMPAT_FILE) ]] || exit 0; \ read ver <$(COMPAT_FILE); \ if [[ "$$ver" -gt $(COMPAT_VER) ]]; then \ @@ -135,7 +130,6 @@ for ((i=ver+1; i <= $(COMPAT_VER); i++)); do \ $(SHELL) upgrade/$$i.bash; \ done - $(MAKE) install .PHONY: install-all install-all: install @@ -147,7 +141,7 @@ endef .PHONY: install -install: check-install-comapt +install: upgrade mkdir -p $(mylispdir) echo $(COMPAT_VER) >$(COMPAT_FILE) $(cleanup_mylispdir)