-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
88 lines (68 loc) · 2.79 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
# Makefile
# Copyright (C) 2016, 2019, 2021 Alex Kost <alezost@gmail.com>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Commentary:
# This file is used to byte-compile various *.el files of my Emacs
# config so that I can see and fix compilation warnings.
# Code:
EMACS = emacs
MY_INIT_DIR = $(CURDIR)/init
MY_UTILS_DIR = $(CURDIR)/utils
MY_ELPA_DIR = $(CURDIR)/packages
EMACS_ELPA_DIR = $(CURDIR)/data/elpa
GUIX_DIR = $(HOME)/.guix-profiles/emacs/emacs/share/emacs/site-lisp
GUIX_ELPA_DIR = $(GUIX_DIR)/guix.d
SLIME_DIR = $(shell find "$(HOME)/.quicklisp/dists/quicklisp/software" -mindepth 1 -maxdepth 1 -type d -name "slime*" | head -n1)
SLIME_CONTRIB_DIR = $(SLIME_DIR)/contrib
L_dirs = $(shell test -d $(1) && \
find -L $(1) -mindepth 1 -maxdepth 1 -type d \
-exec echo -L {} \;)
LOAD_PATH = \
-L $(MY_UTILS_DIR) \
$(call L_dirs,$(MY_ELPA_DIR)) \
-L $(GUIX_DIR) \
$(call L_dirs,$(GUIX_ELPA_DIR)) \
$(if $(SLIME_DIR), -L $(SLIME_CONTRIB_DIR) -L $(SLIME_DIR)) \
$(call L_dirs,$(EMACS_ELPA_DIR))
EMACS_BATCH = $(EMACS) -batch -Q $(LOAD_PATH)
UTILS_ELS = $(shell find -L $(MY_UTILS_DIR) -maxdepth 1 -name 'al-*el')
UTILS_ELCS = $(UTILS_ELS:.el=.elc)
# "init.el" and "keys.el" should be compiled first.
INIT_ELS = \
$(MY_INIT_DIR)/init.el \
$(MY_INIT_DIR)/keys.el \
$(shell find -L $(MY_INIT_DIR) -maxdepth 1 -name '*el' \
! -name 'init.el' ! -name 'keys.el')
INIT_ELCS = $(INIT_ELS:.el=.elc)
all: $(UTILS_ELCS)
%.elc: %.el
@printf "Compiling $<\n"
-@$(EMACS_BATCH) --eval "(setq load-prefer-newer t)" \
-f batch-byte-compile $< ;
# This target is not very useful actually: compiling init files brings
# tons of garbage warnings because 'with-eval-after-load' wraps lambda
# in 'eval-after-load', so almost everything inside it is unknown (as it
# is used to set up a foreign package) and produces a warning.
init: $(INIT_ELS)
@printf "Compiling init files\n"
@$(EMACS_BATCH) -f batch-byte-compile $^ ;
clean-utils:
@printf "Removing utils/*.elc...\n"
$(RM) $(UTILS_ELCS)
clean-init:
@printf "Removing init/*.elc...\n"
$(RM) $(INIT_ELCS)
clean: clean-utils clean-init
.PHONY: all init clean clean-utils clean-init
# Makefile ends here