#! make -f

VERSION=0.8

export UTRANS_DATA_DIR ?= $(CURDIR)
export SYSTEMD_UNIT_PATH=./input/user:./input

all:
	sed -i 's#^readonly VERSION=[[:digit:]]\+\(\.[[:digit:]]\)\+#readonly VERSION=$(VERSION)#' utrans

	sed -i -e '1 s#Version [[:digit:]]\+\(\.[[:digit:]]\)\+#Version $(VERSION)#' \
	-e '1 s#"[[:digit:]]\{4\}-[[:digit:]]\{2\}-[[:digit:]]\{2\}"#$(shell date -I)#' man/*.1

check: shellcheck mancheck
	find ./t/expected -type f -executable -exec sh -n '{}' ';'
	cd ./t && ./run

mancheck: man/*.1
	groff -mandoc -t -K utf8 -ww -b -z $?

shellcheck:
ifeq (, $(shell which shellcheck))
	$(warning "No shellcheck found in $(PATH), skipping")
else
	shellcheck --external-sources --exclude SC2155 --severity=info utrans
	shellcheck utrans-rc
endif

systemd-lsb-tests: t/expected/lsb/init.d/exec-*
	cp t/test-exec_environmentfile.conf /tmp

	for lsb_test in $^; do \
	# Run each one in a new program group: exec-ignoresigpipe-yes signals \
	# the whole group \
	setsid $$lsb_test start; done

clean:

update-expected:
	cd ./t && ./update
