#!/usr/bin/make -f

SHELL := sh -e

D := $(CURDIR)/debian/suckless-tools
TOOLS = $(shell ls | sed -e 's|debian||')

%:
	dh $@

override_dh_auto_clean:
	dh_auto_clean
	for TOOL in $(TOOLS); \
	do \
		make -C $${TOOL} clean; \
	done
	@diff -q tabbed/config.h tabbed/config.def.h && rm -f tabbed/config.h || true

override_dh_auto_build:
	for TOOL in $(TOOLS);\
	do \
		make -C $${TOOL}; \
	done

override_dh_auto_install:
	for TOOL in $(TOOLS); \
	do \
		$(MAKE) -C $${TOOL} DESTDIR=$(D) TERMINFO=$(D)/usr/share/terminfo PREFIX=/usr install; \
	done
	dh_installman debian/manpages/*

override_dh_installdocs:
	dh_installdocs
	for TOOL in $(TOOLS); \
	do \
		cp $${TOOL}/README $(D)/usr/share/doc/suckless-tools/README.$${TOOL}; \
	done

override_dh_fixperms:
	dh_fixperms -Xusr/bin/slock

get-orig-source:
	$(dir $(firstword $(MAKEFILE_LIST)))create_orig_source


