#! /usr/bin/make -f
%:
	dh $@

DEB_HOST_ARCH_OS ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)

TERMNAMES = a/ansi d/dumb v/vt102

ifeq ($(DEB_HOST_ARCH_OS),linux)
TERMNAMES += l/linux
endif

ifeq ($(DEB_HOST_ARCH_OS),kfreebsd)
TERMNAMES += c/cons25 x/xterm
endif

ifeq ($(DEB_HOST_ARCH_OS),hurd)
TERMNAMES += h/hurd m/mach-color
endif

TERMS = $(foreach term,$(TERMNAMES),\
          $(firstword $(wildcard /lib/terminfo/$(term)) \
                      $(wildcard /usr/share/terminfo/$(term))))

override_dh_auto_install:
	for file in $(TERMS); do \
		mkdir -p debian/di-utils-terminfo/`dirname $$file`; \
		cp -pL $$file debian/di-utils-terminfo/$$file; \
		chmod 644 debian/di-utils-terminfo/$$file; \
	done

	mkdir -p debian/di-utils/bin
	cp -pL list-devices-$(DEB_HOST_ARCH_OS) debian/di-utils/bin/list-devices
	chmod 755 debian/di-utils/bin/list-devices
	
