#!/usr/bin/make -f

DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
CFLAGS = -Wall -g $(shell dpkg-buildflags --get CFLAGS)

confflags := \
        --host=$(DEB_HOST_GNU_TYPE) \
        --build=$(DEB_BUILD_GNU_TYPE) \
        --prefix=/usr \
        --mandir=\$${prefix}/share/man \
        --infodir=\$${prefix}/share/info \
        --sysconfdir=/etc/X11/blackbox \
        --enable-shared \
	$(NULL)

%:
	dh $@

override_dh_auto_configure:
	autoreconf -vfi
	CFLAGS="$(CFLAGS)" dh_auto_configure -- $(confflags)

override_dh_auto_build:
	$(MAKE) DEFAULT_MENU=/etc/X11/blackbox/blackbox-menu

override_dh_auto_clean:
	[ ! -f Makefile ] || $(MAKE) distclean
	cp -f /usr/share/misc/config.sub config.sub
	cp -f /usr/share/misc/config.guess config.guess

override_dh_install:
	dh_install
	rm -f $(CURDIR)/debian/blackbox/usr/share/blackbox/menu

override_dh_link:
	rm -rf $(CURDIR)/debian/libbt/usr/share/doc/libbt
	dh_link -plibbt usr/share/doc/libbt0 usr/share/doc/libbt
	dh_link
