#!/usr/bin/make -f
# Debian package build rules file for read-edid
# Copyright (C) 2000 Progeny Linux Systems, Inc.
# Author: Branden Robinson <branden@progeny.com>
# Licensed under the GNU General Public License, version 2.  See the file
# /usr/share/common-licenses/GPL or <http://www.gnu.org/copyleft/gpl.txt>.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# This is the debhelper compatability version to use.
export DH_COMPAT=4

CFLAGS=-g -Wall
# Does DEB_BUILD_OPTIONS contain the "noopt" flag?
ifeq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
# don't get rid of the space in the next line
CFLAGS+= -O2
endif

export CFLAGS

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

build: configure build-stamp
build-stamp:
	dh_testdir
ifeq ($(DEB_HOST_ARCH),powerpc)
	$(MAKE) parse-edid
	cp -a get-edid-powerpc get-edid
else
	$(MAKE)
endif
	touch $@

configure: configure-stamp
configure-stamp:
	dh_testdir
	./configure
	touch $@

clean: configure
	dh_testdir
	dh_testroot
	rm -f build-stamp configure-stamp
	$(MAKE) distclean
	dh_clean

install: build configure
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs
	install -m 755 -d debian/read-edid/usr/bin
	install -m 755 get-edid debian/read-edid/usr/bin
	install -m 755 parse-edid debian/read-edid/usr/bin
	install -m 755 -d debian/read-edid/usr/share/man/man1
	install -m 644 get-edid.man debian/read-edid/usr/share/man/man1/get-edid.1
	ln -s get-edid.1 debian/read-edid/usr/share/man/man1/parse-edid.1

binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installdocs
	dh_undocumented
	dh_installchangelogs ChangeLog
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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