all: test docs BINS=$(wildcard bin/*) $(wildcard libexec/*) HOOKS=$(wildcard hooks/*) 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 $(foreach f,$(BINS),$(eval $(call set_header,$(f),lib/header))) set-headers: $(addprefix set_header-,$(BINS)) $(foreach f,$(HOOKS),$(eval $(call set_header,$(f),lib/header-hook))) set-headers: $(addprefix set_header-,$(HOOKS)) .PHONY: set-headers