Makefile
author Oleksandr Gavenko <gavenkoa@gmail.com>
Wed, 27 Jan 2010 23:48:53 +0200
changeset 260 437507e141b4
parent 165 9f5dd505a4cf
child 261 16b1f9a3ee99
permissions -rw-r--r--
Write .PHONY exactly before target.

# Copyright (C) 2008 by Oleksandr Gavenko <gavenkoa@gmail.com>

ifeq '' '$(HOME)'
  $(error Home env var not set!)
endif

.PHONY: all
all: install

.PHONY: install
install: preinstall update-dot-emacs-pre update-dot-emacs-post

.PHONY: preinstall
preinstall: .emacs .emacs-my .emacs-pre .emacs-post
	for file in .emacs-pre .emacs-post; do \
		if [ ! -f $(HOME)/$$file ]; then cp $$file $(HOME)/$$file; fi; \
	done
	cp .emacs $(HOME)/.emacs
	cp .emacs-my $(HOME)/.emacs-my

.PHONY: install-all
install-all: preinstall-all update-dot-emacs-pre update-dot-emacs-post

.PHONY: preinstall-all
preinstall-all: .emacs .emacs-my .emacs-pre .emacs-post
	for file in $^; do \
		cp $$file $(HOME)/$$file; \
	done

.PHONY: update-dot-emacs-pre
update-dot-emacs-pre:
	for file in `cd template-pre; ls *.el`; do \
		tag=$${file%.el}; \
		if grep "DO NOT EDIT COMMENT! TAG: $$tag" $(HOME)/.emacs-pre; then \
			:; \
		else \
			cat template-pre/$$file >>$(HOME)/.emacs-pre; \
		fi; \
	done

.PHONY: update-dot-emacs-post
update-dot-emacs-post:
	for file in `cd template-post; ls *.el`; do \
		tag=$${file%.el}; \
		if grep "DO NOT EDIT COMMENT! TAG: $$tag" $(HOME)/.emacs-post; then \
			:; \
		else \
			cat template-post/$$file >>$(HOME)/.emacs-post; \
		fi; \
	done

.PHONY: tar
tar:
	tar cf dot-emacs.tar .emacs .emacs-my

.PHONY: distclean
distclean: clean

.PHONY: clean
clean:
	rm -f dot-emacs.tar