forked from haskell/haskell-mode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
156 lines (123 loc) · 5.59 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#
# Note: Due to MELPA distributing directly from github source version
# needs to be embedded in files as is without preprocessing.
#
# Version string is present in:
# - Makefile
# - haskell-mode.el
# - haskell-mode.texi
#
# We should have a script that changes it everywhere it is needed and
# syncs it with current git tag.
#
VERSION = 17.5
INSTALL_INFO = install-info
# Use $EMACS environment variable if present, so that all of these are
# equivalent:
#
# 1. export EMACS=/path/to/emacs && make
# 2. EMACS=/path/to/emacs make
# 3. make EMACS=/path/to/emacs
#
# This is particularly useful when EMACS is set in ~/.bash_profile
#
EMACS ?= emacs
EMACS_VERSION := $(shell "$(EMACS)" -Q --batch --eval '(princ emacs-version)')
EFLAGS = --eval "(when (boundp 'load-prefer-newer) (setq load-prefer-newer t))"
BATCH = @echo EMACS $@; "$(EMACS)" $(EFLAGS) --batch -Q -L .
ELFILES := $(filter-out haskell-mode-autoloads.el,$(wildcard *.el))
ELCHECKS := $(wildcard tests/*-tests.el)
AUTOLOADS = haskell-mode-autoloads.el
PKG_DIST_FILES = $(ELFILES) logo.svg NEWS haskell-mode.info dir
INIT_PACKAGES="(progn \
(require 'package) \
(push '(\"melpa\" . \"https://melpa.org/packages/\") package-archives) \
(package-initialize) \
(dolist (pkg '(package-lint)) \
(unless (package-installed-p pkg) \
(unless (assoc pkg package-archive-contents) \
(package-refresh-contents)) \
(package-install pkg))) \
)"
.PHONY: all compile info clean check check-emacs-version check-ert check-package-lint check-relint
all: check-emacs-version compile $(AUTOLOADS) info
check-emacs-version :
$(BATCH) --eval "(when (version< emacs-version \"25.1\") \
(message \"Error: haskell-mode requires Emacs 25.1 or later\") \
(message \"Your version of Emacs is %s\" emacs-version) \
(message \"Found as '$(EMACS)'\") \
(message \"Use one of:\") \
(message \" 1. export EMACS=/path/to/emacs && make\") \
(message \" 2. EMACS=/path/to/emacs make\") \
(message \" 3. make EMACS=/path/to/emacs\") \
(kill-emacs 2))"
@echo Using EMACS = $(EMACS), version = $(EMACS_VERSION)
compile: build-$(EMACS_VERSION)/build-flag
build-$(EMACS_VERSION) :
mkdir $@
# Emacs byte compilation state leaks from file to file if multiple
# files are requested to be build at the same time. We have to
# workaround this issue on Makefile level. Note also that we consider
# an .el file to be dependent on all other files because we do not do
# proper dependency tracking (yet).
build-$(EMACS_VERSION)/%.elc : %.el $(ELFILES)
$(BATCH) --eval '(setq byte-compile-error-on-warn t)' \
--eval "(setq byte-compile-dest-file-function (lambda (filename) \
(concat (file-name-directory filename) \"build-\" emacs-version \"/\" \
(file-name-nondirectory filename) \"c\")))" \
--eval "(when (check-declare-file \"$<\") (kill-emacs 2))" \
-f batch-byte-compile $< \
build-$(EMACS_VERSION)/build-flag : build-$(EMACS_VERSION) $(patsubst %.el,build-$(EMACS_VERSION)/%.elc,$(ELFILES))
touch $@
check-%: tests/%-tests.el
$(BATCH) -l "$<" -f ert-run-tests-batch-and-exit;
check: compile $(AUTOLOADS) check-package-lint check-relint check-ert
check-ert: $(ELCHECKS)
$(BATCH) -L tests \
$(patsubst %,-l %,$(ELCHECKS)) \
-f ert-run-tests-batch-and-exit
@echo "checks passed!"
# TODO: fix issues, then enforce build failure if this fails
check-package-lint:
$(BATCH) --eval $(INIT_PACKAGES) --eval '(setq package-lint-main-file "haskell-mode.el")' -f package-lint-batch-and-exit $(ELFILES) || true
clean:
$(RM) -r build-$(EMACS_VERSION) $(AUTOLOADS) $(AUTOLOADS:.el=.elc) haskell-mode.info dir
info: haskell-mode.info dir
dir: haskell-mode.info
$(INSTALL_INFO) --dir=$@ $<
haskell-mode.info: doc/haskell-mode.texi
LANG=en_US.UTF-8 $(MAKEINFO) $(MAKEINFO_FLAGS) -o $@ $<
doc/haskell-mode.html: doc/haskell-mode.texi doc/haskell-mode.css
LANG=en_US.UTF-8 $(MAKEINFO) $(MAKEINFO_FLAGS) --html --css-include=doc/haskell-mode.css --no-split -o $@ $<
$(BATCH) -l doc/haskell-manual-fixups.el -f haskell-manual-fixups-batch-and-exit $@
doc/html/index.html : doc/haskell-mode.texi
if [ -e doc/html ]; then rm -r doc/html; fi
mkdir doc/html
cp -r doc/anim doc/html/anim
LANG=en_US.UTF-8 $(MAKEINFO) $(MAKEINFO_FLAGS) --html \
--css-ref=haskell-mode.css \
-c AFTER_BODY_OPEN='<div class="background"> </div>' \
-c EXTRA_HEAD='<link rel="shortcut icon" href="haskell-mode-32x32.png">' \
-c SHOW_TITLE=0 \
-o doc/html $<
$(BATCH) -l doc/haskell-manual-fixups.el -f haskell-manual-fixups-batch-and-exit doc/html/*.html
doc/html/haskell-mode.css : doc/haskell-mode.css doc/html/index.html
cp $< $@
doc/html/haskell-mode.svg : images/haskell-mode.svg doc/html/index.html
cp $< $@
doc/html/haskell-mode-32x32.png : images/haskell-mode-32x32.png doc/html/index.html
cp $< $@
doc/html : doc/html/index.html \
doc/html/haskell-mode.css \
doc/html/haskell-mode.svg \
doc/html/haskell-mode-32x32.png
deploy-manual : doc/html
cd doc && ./deploy-manual.sh
$(AUTOLOADS): $(ELFILES)
$(BATCH) \
--eval '(setq make-backup-files nil)' \
--eval "(setq generated-autoload-file (concat command-line-default-directory \"/\" \"$@\"))" \
--eval "(require 'autoload)" \
-f batch-update-autoloads "."
# check if autoloads will really load
$(BATCH) -l "$@"