diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..49538be --- /dev/null +++ b/Makefile @@ -0,0 +1,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 |