summaryrefslogtreecommitdiff
path: root/Makefile
blob: 49538bebdeee11c7c6eb7b4b5b7c318bdf83513f (plain)
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
all: test docs

BINS=$(wildcard bin/*) $(wildcard libexec/*)

BATS=$(sort $(patsubst test/%,%,$(filter-out test/X-%,$(wildcard test/*.bats))))
TESTS=$(addprefix test-,$(BATS))

test-%:
	@echo === $@
	@bats $(patsubst test-%,test/%,$@)

show-tests:
	@echo BATS=$(BATS)
	@echo TESTS=$(TESTS)
	@echo $(addprefix set_header-,$(BINS))

test: $(TESTS)
.PHONY: test

docs:
	@make -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
 $(wildcard hooks/*) 

$(foreach f,$(BINS),$(eval $(call set_header,$(f),lib/header)))
set-headers: set-hook-headers $(addprefix set_header-,$(BINS))

$(foreach f,$(wildcard hooks/*),$(eval $(call set_header,$(f),lib/hook-header)))
set-headers: $(addprefix set_header-,$(BINS))

.PHONY: set-headers