Makefile
changeset 1665 3685e2321a9b
parent 1664 72275301c19d
child 1666 06937ff1ec5f
equal deleted inserted replaced
1664:72275301c19d 1665:3685e2321a9b
   105 	hg push ssh://$(SF_USER)@hg.code.sf.net/u/$(SF_USER)/dot-emacs || [ $$? = 1 ]
   105 	hg push ssh://$(SF_USER)@hg.code.sf.net/u/$(SF_USER)/dot-emacs || [ $$? = 1 ]
   106 
   106 
   107 ################################################################
   107 ################################################################
   108 # Install/uninstall targets.
   108 # Install/uninstall targets.
   109 
   109 
   110 .PHONY: check-install-comapt
   110 ifneq '' '$(filter upgrade,$(MAKECMDGOALS))'
   111 check-install-comapt:
   111   ifeq '' '$(filter install%,$(MAKECMDGOALS))'
   112 	\
   112     $(error "upgrade" should be invoked from "install")
   113 if [ -f ~/.emacs ]; then \
   113   endif
   114   echo Old style install detected, run '"$(MAKE) upgrade"' first; \
   114 endif
       
   115 
       
   116 .PHONY: upgrade
       
   117 upgrade:
       
   118 	\
       
   119 if [[ -f ~/.emacs ]]; then \
       
   120   echo An old style install detected, delete ~/.emacs first.; \
   115   false; \
   121   false; \
   116 fi
   122 fi
   117 	\
       
   118 if [ -f $(emacsdir)/init.el ]; then \
       
   119   if [ ! -f $(COMPAT_FILE) ]; then \
       
   120     echo $(COMPAT_FILE) missing, run '"$(MAKE) upgrade"' first; \
       
   121     exit 1; \
       
   122   fi; \
       
   123 fi
       
   124 	read ver <$(COMPAT_FILE); if [ "$$ver" -ne $(COMPAT_VER) ]; then echo "*** "Run '"$(MAKE) upgrade"' first" ***"; exit 1; fi
       
   125 
       
   126 .PHONY: upgrade
       
   127 upgrade:
       
   128 	\
   123 	\
   129 [[ -f $(COMPAT_FILE) ]] || exit 0; \
   124 [[ -f $(COMPAT_FILE) ]] || exit 0; \
   130 read ver <$(COMPAT_FILE); \
   125 read ver <$(COMPAT_FILE); \
   131 if [[ "$$ver" -gt $(COMPAT_VER) ]]; then \
   126 if [[ "$$ver" -gt $(COMPAT_VER) ]]; then \
   132   echo "*** "Project is too old, downgrade is not possible..." ***"; \
   127   echo "*** "Project is too old, downgrade is not possible..." ***"; \
   133   exit 1; \
   128   exit 1; \
   134 fi; \
   129 fi; \
   135 for ((i=ver+1; i <= $(COMPAT_VER); i++)); do \
   130 for ((i=ver+1; i <= $(COMPAT_VER); i++)); do \
   136   $(SHELL) upgrade/$$i.bash; \
   131   $(SHELL) upgrade/$$i.bash; \
   137 done
   132 done
   138 	$(MAKE) install
       
   139 
   133 
   140 .PHONY: install-all
   134 .PHONY: install-all
   141 install-all: install
   135 install-all: install
   142 	cp .emacs-pre $(emacsdir)/.emacs-pre
   136 	cp .emacs-pre $(emacsdir)/.emacs-pre
   143 	cp .emacs-post $(emacsdir)/.emacs-post
   137 	cp .emacs-post $(emacsdir)/.emacs-post
   145 define cleanup_mylispdir
   139 define cleanup_mylispdir
   146   find $(mylispdir) -type f '(' -name '*.el' -o -name '*.elc' -o -name '*~' ')' -exec rm {} ';'
   140   find $(mylispdir) -type f '(' -name '*.el' -o -name '*.elc' -o -name '*~' ')' -exec rm {} ';'
   147 endef
   141 endef
   148 
   142 
   149 .PHONY: install
   143 .PHONY: install
   150 install: check-install-comapt
   144 install: upgrade
   151 	mkdir -p $(mylispdir)
   145 	mkdir -p $(mylispdir)
   152 	echo $(COMPAT_VER) >$(COMPAT_FILE)
   146 	echo $(COMPAT_VER) >$(COMPAT_FILE)
   153 	$(cleanup_mylispdir)
   147 	$(cleanup_mylispdir)
   154 	for file in .emacs-pre .emacs-post; do \
   148 	for file in .emacs-pre .emacs-post; do \
   155 		[ -f $(emacsdir)/$$file ] || cp $$file $(emacsdir)/$$file; \
   149 		[ -f $(emacsdir)/$$file ] || cp $$file $(emacsdir)/$$file; \