DISTFILES=	Makefile.in README.md README.ubuntu.md \
		conf/Makefile conf/substitute.sh conf/substitutions.conf.franchise \
		conf/substitutions.conf.FreeBSD conf/substitutions.conf.Linux \
		dashboard/*.in dist/Makefile.in etc/*.in src test/Makefile.in
DISTTARGET=	nodes2grafana
DISTDIR=	tmp/${DISTTARGET}
DISTEXCLUDE=	--exclude=${DISTTARGET}/src/Makefile \
		--exclude=${DISTTARGET}/src/promconfig.sml \
		--exclude=${DISTTARGET}/src/nodes2prom \
		--exclude=${DISTTARGET}/src/graph2prom \
		--exclude=${DISTTARGET}/src/json-pp \
		--exclude=${DISTTARGET}/src/.cm \
		--exclude=${DISTTARGET}/src/JSON/.cm \
		--exclude=${DISTTARGET}/src/*.%%HEAP_SUFFIX%%

DISTTARFILE=	${DISTTARGET}.txz

all: ${DISTTARFILE}

${DISTTARFILE}: ${DISTDIR} Makefile
	tar cvJf ${DISTTARFILE} -C tmp ${DISTEXCLUDE} ${DISTTARGET}

${DISTDIR}: tmp
	rm -rf $@
	mkdir $@
	cd .. && { tar cf - ${DISTFILES} | tar xpf - -C dist/${DISTDIR} ; }

tmp:
	mkdir $@

clean:
	rm -rf tmp
	rm -f ${DISTTARFILE}