Escape file name with safe chars.
# Copyright (C) 2008-2010 by Oleksandr Gavenko <gavenkoa@gmail.com>
#
# You can do anything with this file without any warranty.
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:
# Default target.
.DEFAULT_GOAL = all
################################################################
# Helper definition.
which = $(firstword $(foreach item,$(subst :, ,$(PATH)),$(wildcard $(item)/$1)))
################################################################
# 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
################################################################
# 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.
FILES_MODE_EL := $(wildcard *-mode.el)
RST_FILES := $(wildcard *.rst)
HTML_FILES := $(RST_FILES:.rst=.html)
################################################################
# Targets.
.PHONY: all
all: install
################################################################
# Install/uninstall targets.
.PHONY: install-all
install-all: install
cp .emacs-pre $(HOME)/.emacs-pre
cp .emacs-post $(HOME)/.emacs-post
.PHONY: install
install: .emacs .emacs-my .emacs-pre .emacs-post $(FILES_MODE_EL)
for file in .emacs-pre .emacs-post; do \
[ -f $(HOME)/$$file ] || cp $$file $(HOME)/$$file; \
done
cp .emacs $(HOME)/.emacs
cp .emacs-my $(HOME)/.emacs-my
rm -f -r $(HOME)/.emacs.d/my-lisp
mkdir -p $(HOME)/.emacs.d/my-lisp
for file in $(FILES_MODE_EL); do \
cp -f $$file $(HOME)/.emacs.d/my-lisp; \
done
$(EMACS) --batch \
--eval='(let ( (generated-autoload-file "~/.emacs.d/my-lisp/autoload-my.el") ) (update-directory-autoloads "~/.emacs.d/my-lisp") )'
./.emacs-autogen.sh $(HOME)/.emacs-autogen
.PHONY: uninstall
uninstall:
rm -f $(HOME)/.emacs $(HOME)/.emacs-my $(HOME)/.emacs-autogen
rm -f -r $(HOME)/.emacs.d/my-lisp
.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)