#!/usr/bin/make -f
# Sample debian/rules that uses debhelper. 
# GNU copyright 1997 by Joey Hess.
#
# This version is for a hypothetical package that builds an
# architecture-dependant package, as well as an architecture-independent
# package.

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

dpkg_buildflags := dpkg-buildflags
dpkg_buildflags := DEB_CFLAGS_MAINT_PREPEND="-Wall" $(dpkg_buildflags)

DEB_BUILD_GNU_TYPE	?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
DEB_HOST_GNU_TYPE	?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_HOST_ARCH		?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
DEB_HOST_MULTIARCH	?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

LIBCDEV=$(shell dpkg-awk 'Provides:libc-dev' -- Package | sed -ne 's/^Package:[[:space:]]*//p' | head -1) | libc-dev

configure-stamp:
	dh_testdir
	dh_autoreconf
	./configure $(shell $(dpkg_buildflags) --export=configure) \
		--build=$(DEB_BUILD_GNU_TYPE) \
		--host=$(DEB_HOST_GNU_TYPE) \
		--prefix=/usr \
		--libdir=\$${exec_prefix}/lib/$(DEB_HOST_MULTIARCH) \
		--mandir=\$${prefix}/share/man \
		--infodir=\$${prefix}/share/info
	touch configure-stamp

build: build-arch build-indep
build-arch: build-stamp
build-indep: build-stamp
build-stamp: configure-stamp
	dh_testdir
	$(MAKE)
ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
	# Check the programs if we can...
	if [ "$(DEB_HOST_GNU_TYPE)" = "$(DEB_BUILD_GNU_TYPE)" ]; then $(MAKE) check; fi
endif
	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	[ ! -f Makefile ] || $(MAKE) distclean
	rm -f Makefile.in */Makefile.in */*/Makefile.in config.guess config.log config.sub INSTALL compile install-sh test-driver missing
	dh_autoreconf_clean
	dh_clean

install: DH_OPTIONS=
install: build
	dh_testdir
	dh_testroot
	dh_prep
	$(MAKE) install DESTDIR=$(CURDIR)/debian/tmp


# Build architecture-independent files here.
# Pass -i to all debhelper commands in this target to reduce clutter.
binary-indep: build install

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir -a
	dh_testroot -a
	dh_installdocs -a
#	dh_installman -a
	dh_installinfo -a
	dh_installchangelogs ChangeLog -a
	dh_install --sourcedir=$(CURDIR)/debian/tmp --list-missing
	dh_strip -a
	dh_link -a
	dh_compress -a
	dh_fixperms -a
	dh_makeshlibs -a -N libvcdinfo0
	dh_makeshlibs -p libvcdinfo0 -V 'libvcdinfo0 (>> 0.7.24)'
	dh_installdeb -a
	dh_shlibdeps -a -L libvcdinfo0 -l debian/libvcdinfo0/usr/lib
	dh_gencontrol -a -- -Vlibcdev="$(LIBCDEV)"
	dh_md5sums -a
	dh_builddeb -a

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