#!/usr/bin/make -f

CFLAGS=-O2 -Wall -g

configure: configure-stamp
configure-stamp:
	dh_testdir
	aclocal
	autoheader
	automake -a
	autoconf
	./configure --prefix=/usr --mandir=\$${prefix}/share/man
	# Automake. Sigh.
	grep -v AMDEP_TRUE Makefile > Makefile.new ; mv -f Makefile.new Makefile
	touch configure-stamp

build: configure-stamp build-stamp
build-stamp:
	dh_testdir
	$(MAKE) CFLAGS="$(CFLAGS)"
	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp configure-stamp
	-$(MAKE) distclean
	dh_clean doc/acpi.1 install-sh depcomp missing mkinstalldirs \
		aclocal.m4 config.log config.status config.h config.cache \
		COPYING INSTALL configure Makefile.in stamp-h stamp-h.in \
		Makefile config.h.in

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs
	dh_installman acpi.1 acpi.de.1
	$(MAKE) install prefix=$(CURDIR)/debian/acpi/usr

# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installdocs README AUTHORS
	dh_installchangelogs ChangeLog
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install configure
