-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
121 lines (94 loc) · 3.43 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
# Time-stamp: <2022-02-15 21:41:24 kmodi>
# Makefile to tangle eless.org and export documentation as well.
# Run just "make" to see usage examples.
MAKE_ := $(MAKE) --no-print-directory
PREFIX = /usr/local
TMPDIR ?= /tmp
EMACS ?= emacs
EMACS_exists := $(shell command -v $(EMACS) 2> /dev/null)
MAKEINFO ?= makeinfo
MAKEINFO_exists := $(shell command -v $(MAKEINFO) 2> /dev/null)
# Directory where the required elisp packages are auto-installed
ELESS_ELPA=$(TMPDIR)/$(USER)/eless-dev/
ELESS_ELISP_DIR="$(shell pwd)/build/"
ORG_FILE=$(shell pwd)/eless.org
# Function to be run in emacs --batch
FUNC=
.PHONY: default help emacs_batch \
eless html info ghub doc docs all vcheck \
test ctemp clean \
install uninstall
default: eless
help:
@echo "Help for Eless building"
@echo "==========================================================================="
@echo " make eless <- Build eless bash script"
@echo " make doc <- Build eless documentation (Info + Github)"
@echo " make all <- Build eless script + documentation"
@echo " make install [PREFIX=<dir>] <- Build and install eless and docs"
@echo " make uninstall [PREFIX=<dir>] <- Uninstall eless and docs"
@echo " make help <- Show this help"
# Note: The Org file from $(ORG_FILE) is loaded *after* the --eval
# section gets evaluated i.e. --eval '(progn ..)' $(ORG_FILE) If the
# order is reversed i.e. i.e.$(ORG_FILE) --eval '(progn ..)', the act
# of loading the $(ORG_FILE) file first will load the older Org
# version that ships with Emacs and then run the stuff in --eval that
# loads the new Org version.. and thus we'll end up with mixed Org in
# the load-path.
emacs_batch:
@echo ""
@echo "$(ORG_FILE) ::"
@$(EMACS) --batch --eval "(progn\
(setenv \"ELESS_ELPA\" \"$(ELESS_ELPA)\")\
(setq-default make-backup-files nil)\
(load-file (expand-file-name \"setup-eless.el\" \"$(ELESS_ELISP_DIR)\"))\
)" $(ORG_FILE) \
-f $(FUNC) \
--kill
eless:
@$(MAKE_) emacs_batch FUNC=eless-build-script
html:
@$(MAKE_) emacs_batch FUNC=eless-build-html-docs
info:
ifeq ("$(MAKEINFO_exists)","")
$(error $(MAKEINFO) binary was not found; texinfo is needed to build the eless Info manual)
endif
@$(MAKE_) emacs_batch FUNC=eless-build-info-docs
ghub:
@$(MAKE_) emacs_batch FUNC=eless-build-org-docs
doc docs: info ghub
all: vcheck eless doc
vcheck:
ifeq ("$(EMACS_exists)","")
$(error $(EMACS) binary was not found)
endif
@echo "Emacs binary used: $(EMACS)"
@$(EMACS) --batch --eval "(progn\
(setenv \"ELESS_ELPA\" \"$(ELESS_ELPA)\")\
(load-file (expand-file-name \"setup-eless.el\" \"$(ELESS_ELISP_DIR)\"))\
(message \"[Version check] Emacs %s\" emacs-version)\
(message \"[Version check] %s\" (org-version nil :full))\
)" \
--kill
test:
@EMACS=$(EMACS) TMPDIR=$(TMPDIR) ./test/run_tests.sh
ctemp:
@find $(shell pwd)/docs -name "*.*~" -delete
clean: ctemp
@rm -rf $(ELESS_ELPA)
@rm -f ./docs/*.html ./docs/*.texi
install: all
mkdir -p $(PREFIX)/bin/
cp -f eless $(PREFIX)/bin/.
chmod 755 $(PREFIX)/bin/eless
mkdir -p $(PREFIX)/share/eless/info/
cp -f eless.org $(PREFIX)/share/eless/.
cp -f ./docs/eless.info $(PREFIX)/share/eless/info/.
cp -f ./docs/dir $(PREFIX)/share/eless/info/.
uninstall:
rm -f $(PREFIX)/bin/eless
rm -rf $(PREFIX)/share/eless/
# Set a make variable during rule execution
# https://stackoverflow.com/a/1909390/1219634
# Check if an executable exists
# https://stackoverflow.com/a/34756868/1219634