forked from DamienCassou/pillar-mode
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
105 lines (85 loc) · 2.48 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
CWD = $(shell pwd)
SCRIPT = $(CWD)/script
GIT_DIR = $(CWD)/.git
EMACS ?= emacs
EMACSFLAGS = --batch -Q
CASK = cask
VERSION := $(shell EMACS=$(EMACS) $(CASK) version)
PKG_DIR := $(shell EMACS=$(EMACS) $(CASK) package-directory)
USER_EMACS_D = ~/.emacs.d
USER_INIT_EL = $(USER_EMACS_D)/init.el
USER_ELPA_D = $(USER_EMACS_D)/elpa
SRCS = $(filter-out flycheck_%, $(filter-out %-pkg.el, $(wildcard *.el)))
TESTS = $(filter-out %-pkg.el, $(wildcard test/*.el))
OBJECTS = $(SRCS:.el=.elc)
PACKAGE_SRCS = $(SRCS) pillar-pkg.el
PACKAGE_TAR = pillar-$(VERSION).tar
PRECOMMIT_SRC = $(SCRIPT)/pre-commit.sh
PRECOMMIT_HOOK = $(GIT_DIR)/hooks/pre-commit
.PHONY: all
all : env compile dist
# Configure tooling and environment.
.PHONY: env
env : packages $(PRECOMMIT_HOOK)
# Run tests before committing.
$(PRECOMMIT_HOOK) :
ln -s $(PRECOMMIT_SRC) $(PRECOMMIT_HOOK)
chmod +x $(PRECOMMIT_HOOK)
# Byte-compile elisp files.
.PHONY: compile
compile : $(OBJECTS)
# Run tests.
.PHONY: unit-tests ecukes-tests check
unit-tests : compile
$(CASK) exec $(EMACS) $(EMACSFLAGS) \
$(patsubst %,-l % , $(SRCS))\
$(patsubst %,-l % , $(TESTS))\
-f ert-run-tests-batch-and-exit
ecukes-tests : compile
$(CASK) exec ecukes --script
check : unit-tests ecukes-tests
# Install packages with Cask.
$(PKG_DIR) : Cask
$(CASK)
$(CASK) install
touch $(PKG_DIR)
# Create a tar that can be installed by package.el
.PHONY: dist
dist : $(PACKAGE_TAR)
$(PACKAGE_TAR) : $(PACKAGE_SRCS)
rm -rf pillar-$(VERSION)
mkdir -p pillar-$(VERSION)
cp -f $(PACKAGE_SRCS) pillar-$(VERSION)
tar cf $(PACKAGE_TAR) pillar-$(VERSION)
rm -rf pillar-$(VERSION)
# Install elisp packages with cask.
.PHONY: packages
packages : $(PKG_DIR)
# Install the package to the user's Emacs dir.
.PHONY: install
install : dist
$(EMACS) $(EMACSFLAGS) -l package \
-f package-initialize --eval '(package-install-file "$(CWD)/$(PACKAGE_TAR)")'
# Uninstall the package.
.PHONY: uninstall
uninstall :
rm -rf $(USER_ELPA_D)/pillar-*
# Restore to pristine state.
.PHONY: clean-all
clean-all : clean clean-pkgdir
# Clean generated files.
.PHONY: clean
clean :
rm -f $(OBJECTS)
rm -rf pillar-*.tar pillar-pkg.el
# Remove packages installed by Cask.
.PHONY: clean-pkgdir
clean-pkgdir :
rm -rf $(PKG_DIR)
# Generate files.
pillar-pkg.el : Cask
$(CASK) package
%.elc : %.el $(PKG_DIR)
$(CASK) exec $(EMACS) $(EMACSFLAGS) \
--eval '(setq package-user-dir "$(PKG_DIR)")' -f package-initialize \
-f batch-byte-compile $<