forked from emacscollective/borg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
borg.mk
170 lines (140 loc) · 4.82 KB
/
borg.mk
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# Copyright (C) 2016-2022 Jonas Bernoulli
#
# Author: Jonas Bernoulli <[email protected]>
# SPDX-License-Identifier: GPL-3.0-or-later
BORG_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
BORG_CLEAN_ELN := true
help::
-include etc/borg/config.mk
ifeq "$(BORG_SECONDARY_P)" "true"
DRONES_DIR ?= $(shell git config "borg.drones-directory" || echo "elpa")
BORG_ARGUMENTS = -L $(BORG_DIR) --load borg-elpa \
--funcall borg-elpa-initialize
else
DRONES_DIR ?= $(shell git config "borg.drones-directory" || echo "lib")
BORG_ARGUMENTS = -L $(BORG_DIR) --load borg \
--funcall borg-initialize
endif
EMACS ?= emacs
EMACS_ARGUMENTS ?= -Q --batch
EMACS_EXTRA ?=
.PHONY: help helpall clean build native quick-clean quick-build quick \
init-clean init-build bootstrap bootstrap-borg
.FORCE:
SILENCIO = --load subr-x
SILENCIO += --eval "(setq byte-compile-warnings '(not docstrings))"
SILENCIO += --eval "(fset 'original-message (symbol-function 'message))"
SILENCIO += --eval "(fset 'message\
(lambda (format &rest args)\
(unless (or (equal format \"pcase-memoize: equal first branch, yet different\")\
(equal format \"Not registering prefix \\\"%s\\\" from %s. Affects: %S\")\
(and (stringp (car args))\
(string-match-p \"Scraping files for\" (car args))))\
(apply 'original-message format args))))"
## Help
help helpall::
$(info )
$(info Getting help)
$(info ------------)
$(info make help = show brief help)
$(info make helpall = show extended help)
$(info )
$(info Batch targets)
$(info -------------)
$(info make clean = remove all byte-code and native files)
helpall::
$(info make clean-force = remove all byte-code files using find)
help helpall::
$(info make build = byte-compile all drones and init files)
$(info make native = byte+native-compile drones and byte-compile init files)
helpall::
$(info make quick-clean = clean most drones and init files)
$(info make quick-build = byte-compile most drones and init files)
help helpall::
$(info make quick = clean and byte-compile most drones and init files)
$(info )
$(info Drone targets)
$(info -------------)
$(info make build/DRONE = byte-compile DRONE)
$(info make native/DRONE = byte+native-compile DRONE)
helpall::
$(info )
$(info Init file targets)
$(info -----------------)
$(info make init-clean = remove byte-code init files)
$(info make init-tangle = recreate init.el from init.org)
$(info make init-build = byte-compile init files)
help helpall::
$(info )
$(info Bootstrapping)
$(info -------------)
$(info make bootstrap = bootstrap collective or new drones)
@printf "\n"
## Batch
clean:
ifeq "$(BORG_CLEAN_ELN)" "true"
@rm -f init.elc $(INIT_FILES:.el=.elc)
@$(EMACS) $(EMACS_ARGUMENTS) $(EMACS_EXTRA) $(SILENCIO) \
$(BORG_ARGUMENTS) \
--funcall borg--batch-clean 2>&1
else
@find . -name '*.elc' -exec rm '{}' ';'
endif
clean-force:
@find . -name '*.elc' -exec rm '{}' ';'
build: init-clean
@$(EMACS) $(EMACS_ARGUMENTS) $(EMACS_EXTRA) $(SILENCIO) \
$(BORG_ARGUMENTS) \
--funcall borg-batch-rebuild $(INIT_FILES) 2>&1
native: init-clean
@$(EMACS) $(EMACS_ARGUMENTS) $(EMACS_EXTRA) $(SILENCIO) \
$(BORG_ARGUMENTS) \
--eval "(borg-batch-rebuild nil t)" $(INIT_FILES) 2>&1
## Batch Quick
quick-clean: clean-init
@$(EMACS) $(EMACS_ARGUMENTS) $(EMACS_EXTRA) $(SILENCIO) \
$(BORG_ARGUMENTS) \
--eval '(borg--batch-clean t)' 2>&1
quick-build:
@$(EMACS) $(EMACS_ARGUMENTS) $(EMACS_EXTRA) $(SILENCIO) \
$(BORG_ARGUMENTS) \
--eval '(borg-batch-rebuild t)' $(INIT_FILES) 2>&1
quick: quick-clean quick-build
## Per-Clone
clean/%: .FORCE
@$(EMACS) $(EMACS_ARGUMENTS) $(EMACS_EXTRA) $(SILENCIO) \
$(BORG_ARGUMENTS) \
--eval '(borg-clean "$*")' 2>&1
$(BORG_DIR)borg.mk: ;
build/% $(DRONES_DIR)/% : .FORCE
@$(EMACS) $(EMACS_ARGUMENTS) $(EMACS_EXTRA) $(SILENCIO) \
$(BORG_ARGUMENTS) \
--eval '(borg-build "$*")' 2>&1
native/%: .FORCE
@$(EMACS) $(EMACS_ARGUMENTS) $(EMACS_EXTRA) $(SILENCIO) \
$(BORG_ARGUMENTS) \
--eval '(borg-build "$*" nil t)' 2>&1
## Init Files
init-clean:
@rm -f init.elc $(INIT_FILES:.el=.elc)
init-tangle: init.el
init.el: init.org
@$(EMACS) $(EMACS_ARGUMENTS) $(EMACS_EXTRA) \
--load org \
--eval '(org-babel-tangle-file "init.org")' 2>&1
init-build: init-clean
@$(EMACS) $(EMACS_ARGUMENTS) $(EMACS_EXTRA) \
$(BORG_ARGUMENTS) \
--funcall borg-batch-rebuild-init $(INIT_FILES) 2>&1
## Bootstrap
bootstrap:
@printf "\n=== Running 'git submodule init' ===\n\n"
@git submodule init
@printf "\n=== Running '$(BORG_DIR)borg.sh clone' ===\n"
@$(BORG_DIR)borg.sh clone
@printf "\n=== Running '$(BORG_DIR)borg.sh checkout' ===\n"
@$(BORG_DIR)borg.sh checkout --reset-hard
@printf "\n=== Running 'make build' ===\n\n"
@make build
@printf "\n=== Bootstrapping finished ===\n\n"
@git submodule status