#!/usr/bin/make -f

LDFLAGS+=-Wl,--as-needed
export LIBS=-lm

ifeq ($(shell dpkg-vendor --derives-from Ubuntu && echo yes),yes)
	SUBSTVARS = -Vdist:Depends="gksu"
else
	SUBSTVARS = -Vdist:Depends=""
endif

%:
	dh $@ --with autotools_dev

override_dh_auto_test:

override_dh_gencontrol:
	dh_gencontrol -- $(SUBSTVARS)

override_dh_install:
	dh_install -plibddccontrol-dev
	# Strip wrong #include "config.h" from ddcci.h (bug#518083)
	cd debian/libddccontrol-dev/usr/include/ddccontrol/ && \
		grep -v '#include "config.h"' ddcci.h > ddcci.h.new && \
		mv ddcci.h.new ddcci.h
	dh_install --remaining-packages

override_dh_clean:
	rm -f src/gnome-ddcc-applet/Makefile
	rm -f doc/Makefile
	rm -f src/gddccontrol/gddccontrol.desktop
	dh_clean
