#! /usr/bin/make -f

DEB_HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH)

ifeq ($(DEB_HOST_ARCH),i386)
pm-depends := -V'pm-depends=acpid|apmd'
endif

ifeq ($(DEB_HOST_ARCH),amd64)
pm-depends := -V'pm-depends=acpid|apmd'
endif

ifeq ($(DEB_HOST_ARCH),powerpc)
pm-depends := -V'pm-depends=pbbuttonsd|pmud'
endif

clean:
	dh_testdir
	dh_clean

build:

install:
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	install -m 755 laptop-mode.sh debian/laptop-mode/usr/sbin/laptop-mode
	install -m 755 pmcs-laptop-mode debian/laptop-mode/etc/power/event.d/laptop-mode

binary-indep:

binary-arch: install
	install -m 644 debian/defaults debian/laptop-mode/etc/default/laptop-mode
	dh_testdir
	dh_testroot
	dh_installdocs
	dh_installchangelogs
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_gencontrol -- $(pm-depends)
	dh_md5sums
	dh_builddeb

binary: binary-arch binary-indep
