-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
79 lines (62 loc) · 1.64 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
LUA ?= lua
FENNEL ?= fennel
FNLDOC ?= fnldoc
FAITH ?= faith
DOCKER ?= docker
API_SRC := bump.fnl
MAIN_SRC := bump/main.fnl
SRCS := $(API_SRC) $(shell find bump -name '*.fnl')
TESTS := $(shell find t -regex '^t/api/[^/]+\.fnl$$' \
-o -regex '^t/int/[^/]+\.fnl$$')
FENNEL_BUILD_FLAGS = --no-metadata --require-as-include --compile
EXECUTABLE := bin/bump
VERSION ?= $(shell $(FENNEL) -e '(. (require :bump) :version)')
DESTDIR ?=
PREFIX ?= /usr/local
BINDIR = $(PREFIX)/bin
DOCKERDIR := docker
DOCKER_SRCS := $(foreach s,$(SRCS) Makefile,$(DOCKERDIR)/$(s))
.PHONY: build
build: $(EXECUTABLE)
$(EXECUTABLE): $(SRCS) $(dir $(EXECUTABLE))
echo '#!/usr/bin/env $(LUA)' > $@
$(FENNEL) $(FENNEL_BUILD_FLAGS) $(MAIN_SRC) >> $@
sed -i $@ -Ee '1,+5s#^(\s*local version = ")[^"]+#\1$(VERSION)#'
chmod +x $@
$(dir $(EXECUTABLE)):
mkdir -p $@
.PHONY: install
install: $(EXECUTABLE)
install -pm755 -Dt $(DESTDIR)$(BINDIR) $<
.PHONY: clean
clean:
rm -f $(EXECUTABLE) $(DOCKER_SRCS)
.PHONY: docker-image
docker-image: $(DOCKER_SRCS)
$(DOCKER) build -t bump.fnl $(DOCKERDIR)
$(DOCKERDIR)/%: %
cp $< $@
$(DOCKERDIR)/bump/%: bump/% $(DOCKERDIR)/bump
cp $< $@
$(DOCKERDIR)/bump/utils/%: bump/utils/% $(DOCKERDIR)/bump/utils
cp $< $@
$(DOCKERDIR)/bump:
mkdir -p $@
$(DOCKERDIR)/bump/utils:
mkdir -p $@
.PHONY: readme
readme: README.md
README.md: $(API_SRC:fnl=md)
mv $< $@
sed -Ei $@ -e 's@^(#+) (Function|Macro|Example)@\1# \2@'
%.md: %.fnl
$(FNLDOC) $<
.PHONY: check
check: test doctest
.PHONY: test
test: $(SRCS) $(TESTS)
@$(FENNEL) --version
$(FAITH) --tests $(subst /,.,$(patsubst %.fnl,%,$(TESTS)))
.PHONY: doctest
doctest: $(API_SRC)
$(FNLDOC) --mode check $<