Makefile
author Oleksandr Gavenko <gavenkoa@gmail.com>
Fri, 09 Jan 2015 22:15:17 +0200
changeset 1191 2671cf871a38
parent 1150 dad3fb58f710
child 1199 dff272add01e
permissions -rw-r--r--
ido-case-fold

# 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)))

################################################################
# 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.

EL_FILES := $(wildcard *-mode.el) debian-doc.el maven-central.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 $(EL_FILES)
	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
	mkdir -p $(HOME)/.gnus/scores
	cp all.SCORE $(HOME)/.gnus/scores
	rm -f -r $(HOME)/.emacs.d/my-lisp
	mkdir -p $(HOME)/.emacs.d/my-lisp
	for file in $(EL_FILES); do \
		cp -f $$file $(HOME)/.emacs.d/my-lisp; \
	done
	$(EMACS) -Q --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
	cp -r srecode/ $(HOME)/.emacs.d/

.PHONY: uninstall
uninstall:
	rm -f $(HOME)/.emacs $(HOME)/.emacs-my $(HOME)/.emacs-autogen
	rm -f -r $(HOME)/.emacs.d/my-lisp $(HOME)/.emacs.d/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)