forked from appmgr/appmgr
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
68 lines (54 loc) · 1.7 KB
/
Makefile
File metadata and controls
68 lines (54 loc) · 1.7 KB
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
all: check test docs
BINS=$(wildcard bin/app-*)
LIBS=$(wildcard lib/appmgr/*)
OUT=out
BATS=$(sort $(patsubst test/%,%,$(filter-out test/X-%,$(wildcard test/*.bats))))
TESTS=$(addprefix test-,$(BATS))
CHECKS=$(addsuffix .check,$(addprefix $(OUT)/,$(BINS)))
GIT_VERSION=$(shell git describe --dirty --always)
VERSION=${VERSION:-${GIT_VERSION}}
M=make -j8 -s VERSION=${VERSION}
install: docs
@if [ "$(DESTDIR)" = "" ]; then echo "You have to set DESTDIR"; exit 1; fi
@$(M) -C docs DESTDIR=$(DESTDIR) install
mkdir -p $(DESTDIR)/lib/appmgr
cp -r app bin/ lib/ share/ $(DESTDIR)/lib/appmgr
mkdir -p $(DESTDIR)/bin
ln -sf ../lib/appmgr/app $(DESTDIR)/bin
check: $(CHECKS)
.PHONY: check
$(OUT)/%.check: %
@mkdir -p $(shell dirname $@)
shellcheck $(patsubst check-%,check/%,$<)
@touch $@
test-%:
@echo === $@
@PATH=test/bats/bin:$(PATH) bats $(patsubst test-%,test/%,$@)
show-tests:
@echo BATS=$(BATS)
@echo TESTS=$(TESTS)
@echo $(addprefix set_header-,$(BINS))
test: $(TESTS)
.PHONY: test
clean:
@rm -rf $(OUT)
@$(M) -C docs clean
.PHONY: clean
docs:
@$(M) -C docs
.PHONY: docs
define set_header
set_header-$(1):
@count=`wc -l $(2)|cut -f 1 -d ' '` && \
cat $(2) > x && \
echo "# HEADER END" >> x && \
sed '1,/HEADER END/d' $(1) >> x && \
if [ `md5sum $(1)|cut -f 1 -d ' '` != `md5sum x|cut -f 1 -d ' '` ]; then echo Updated: $(1); cp x $(1); fi; \
rm x
endef
$(foreach f,$(BINS),$(eval $(call set_header,$(f),share/appmgr/bin-header)))
$(foreach f,$(LIBS),$(eval $(call set_header,$(f),share/appmgr/lib-header)))
set-headers: $(addprefix set_header-,$(BINS)) $(addprefix set_header-,$(LIBS))
.PHONY: set-headers
# If you want to add your own goals or utilities, put them in Makefile.local
-include Makefile.local