Cleanup *.elc files also.
# Copyright (C) 2008-2010 by Oleksandr Gavenko <gavenkoa@gmail.com>
#
# You can do anything with this file without any warranty.
################################################################
# Standard Makefile settings.
SHELL = /bin/sh
export PATH := /bin:/usr/bin:${PATH}
# Disable built in pattern rules.
MAKEFLAGS += -r
# Disable built in variables.
MAKEFLAGS += -R
# Disable built in suffix rules.
.SUFFIXES:
# Delete target file if command fails.
.DELETE_ON_ERROR:
# Default target.
.DEFAULT_GOAL = all
################################################################
# Helper definition.
which = $(firstword $(foreach item,$(subst :, ,$(PATH)),$(wildcard $(item)/$1)))
curdir := $(realpath .)
################################################################
# Platform/environment definition.
ifeq '' '$(HOME)'
$(error Home env var not set!)
endif
host_os = unix
ifneq '' '$(COMSPEC)'
ifneq '' '$(WINDIR)'
# Probably under Windows.
host_os = windows
endif
endif
################################################################
# Installation directories.
emacsdir := $(HOME)/.emacs.d
mylispdir := $(emacsdir)/my
################################################################
# Build tool definition/switches.
EMACS = emacs
# I prefer native Windows Emacs, so use it if available.
ifeq 'windows' '$(host_os)'
ifneq '' '$(call which,runemacs.exe)'
EMACS = runemacs
endif
endif
RST2HTML = rst2html
ifeq '$(host_os)' 'windows'
RST2HTML = rst2html.py
endif
################################################################
# Proj dirs/files.
EL_FILES := $(wildcard *.el)
RST_FILES := $(wildcard *.rst)
HTML_FILES := $(RST_FILES:.rst=.html)
################################################################
# Targets.
.PHONY: all
all: install
################################################################
# Install/uninstall targets.
.PHONY: upgrade
upgrade:
\
mkdir -p $(mylispdir); \
rm -f $(emacsdir)/autoload-my.el; \
rm -f ~/.emacs; \
[ -d $(emacsdir)/my-lisp ] && mv $(emacsdir)/my-lisp $(mylispdir); \
for f in .emacs-my .emacs-custom.el .emacs-pre .emacs-post .emacs-places .emacs.desktop .emacs.bmk .emacs-places .emacs-autogen .ido.last .recentf; do \
if [ -f ~/$$f ]; then [ -f $(emacsdir)/$$f ] && mv ~/$$f $(emacsdir)/$$f.1 || mv ~/$$f $(emacsdir); fi; \
if [ -f $(mylispdir)/$$f ]; then [ -f $(emacsdir)/$$f ] && mv $(mylispdir)/$$f $(emacsdir)/$$f.2 || mv $(mylispdir)/$$f $(emacsdir); fi; \
done; \
make install
.PHONY: install-all
install-all: install
cp .emacs-pre $(emacsdir)/.emacs-pre
cp .emacs-post $(emacsdir)/.emacs-post
.PHONY: install
install:
mkdir -p $(mylispdir)
find $(mylispdir) -type f '(' -name '*.el' -o -name '*.elc' ')' -delete
for file in .emacs-pre .emacs-post; do \
[ -f $(emacsdir)/$$file ] || cp $$file $(emacsdir)/$$file; \
done
cp .emacs $(emacsdir)/init.el
cp .emacs-defs .emacs-my $(emacsdir)
mkdir -p $(emacsdir)/server $(HOME)/.gnus/scores
cp all.SCORE $(HOME)/.gnus/scores
cp -f $(EL_FILES) $(mylispdir); \
./.emacs-autogen.sh $(emacsdir)/.emacs-autogen; \
$(EMACS) -Q --batch --eval='(let ((generated-autoload-file "$(mylispdir)/loaddefs.el")) (update-directory-autoloads "$(mylispdir)"))'
\
$(EMACS) -Q --batch --eval='(load "$(curdir)/.emacs-defs")' --eval='(my-load.add-my-loadpaths)' --eval='(load "$(emacsdir)/.emacs-pre")' \
--eval='(byte-compile-file "$(emacsdir)/.emacs-my")' --eval='(byte-force-recompile "$(mylispdir)")'
cp -r srecode/ $(HOME)/.emacs.d/
.PHONY: uninstall
uninstall:
rm -f $(HOME)/.emacs $(mylispdir)/.emacs-my $(mylispdir)/.emacs-autogen
find $(mylispdir) -type f -name '*.el' -delete
rm -f -r $(emacsdir)/srecode
.PHONY: tar
tar:
tar cf dot-emacs.tar .emacs .emacs-my
################################################################
# Documentation targets.
.PHONY: html
html: $(HTML_FILES)
$(HTML_FILES): %.html: %.rst
$(RST2HTML) --stylesheet=rst.css $*.rst $@
################################################################
# Clean targets.
.PHONY: distclean
distclean: clean
.PHONY: clean
clean:
rm -f dot-emacs.tar $(HTML_FILES)