#!/usr/bin/make -f

# add appropriate flags for Debian
DEB_CONFIGURE_EXTRA_FLAGS =
ifeq ($(shell dpkg-vendor --is Debian && echo yes),yes)
	DEB_CONFIGURE_EXTRA_FLAGS += --with-aticonfig=yes
endif
# add appropriate flags for Ubuntu
ifeq ($(shell dpkg-vendor --is Ubuntu && echo yes),yes)
	DEB_CONFIGURE_EXTRA_FLAGS += --with-aticonfig=/usr/lib/fglrx/bin/aticonfig
endif

DHFLAGS=--parallel

%:
	dh $@ $(DHFLAGS)

override_dh_install:
	rm -rfv debian/tmp/usr/lib/*/*.a
	rm -rfv debian/tmp/usr/lib/*/*.la
	rm -rfv debian/tmp/usr/lib/*/mate-sensors-applet/plugins/*.a
	rm -rfv debian/tmp/usr/lib/*/mate-sensors-applet/plugins/*.la
	dh_install --fail-missing

override_dh_auto_configure:
	NOCONFIGURE=1 ./autogen.sh
	dh_auto_configure $(DHFLAGS) -- \
		--libexecdir=/usr/lib/mate-sensors-applet \
		$(DEB_CONFIGURE_EXTRA_FLAGS) \
		--with-nvidia=yes \
		--with-gtk=2.0

override_dh_strip:
	dh_strip -pmate-sensors-applet --dbg-package=mate-sensors-applet-dbg
	dh_strip -plibmate-sensors-applet-plugin0 --dbg-package=libmate-sensors-applet-plugin0-dbg

get-orig-source:
	uscan --noconf --force-download --rename --download-current-version --destdir=..
