-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
60 lines (46 loc) · 1.49 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
.DELETE_ON_ERROR:
define help =
lint byte compile *.el
clean
compile $(pkg)
package $(name)-$(ver).tar
install add $(name)-$(ver).tar to $(local-pa)
endef
.PHONY: help
help:
$(info $(help))@:
pp-%:
@echo "$(strip $($*))" | tr ' ' \\n
src := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
emacs := 24.4
_meta := $(shell awk -F\" '/wordnut-meta-(name|version)/ {printf("%s ", $$2)}' $(src)/wordnut.el)
name := $(word 1, $(_meta))
ver := $(word 2, $(_meta))
pkg := $(src)/$(name)-pkg.el
desc := $(shell head -1 $(src)/wordnut.el | sed -E 's/^(.+-- )(.+)( -\*-.+)$$/\2/')
elc := $(patsubst %.el, %.elc, $(filter-out $(pkg), $(wildcard $(src)/*.el)))
%.elc: %.el
emacs -Q -batch -L "$(src)" -f batch-byte-compile $<
.PHONY: lint
lint: $(elc)
@rm $^
@cd $(dir $<) && stat -c %s *el | awk '{s += $$1} END {print s}'
.PHONY: clean
clean:
rm -f $(pkg)
$(name)-$(ver).tar: $(pkg)
$(if $(filter $(src),$(CURDIR)/),$(error do not run this target in src dir),)
tar -Pcf $@ $(src)/*.el --transform 's,$(src),$(name)-$(ver),'
.PHONY: package
package: $(name)-$(ver).tar
$(pkg): $(src)/wordnut.el
echo '(define-package "$(name)" "$(ver)" "$(desc)" (quote ((emacs "$(emacs)"))))' > $@
compile: $(pkg)
local-pa := ~/lib/software/alex/emacs/pkg
.PHONY: install
install: $(name)-$(ver).tar
emacs -Q -batch -l package-x \
--eval '(setq package-archive-upload-base "$(local-pa)")' \
--eval '(package-upload-file "$<")'
# in emacs 24.5, (package-upload-file) corrupts our tar file
mv $< $(local-pa)