#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.

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

include /usr/share/cdbs/1/rules/buildvars.mk
#include /usr/share/cdbs/1/rules/patchsys-quilt.mk
include /usr/share/cdbs/1/class/langcore.mk
include /usr/share/cdbs/1/class/autotools.mk


#DEB_CONFIGURE_PREFIX=/usr$(if $(cdbs_crossbuild),/$(DEB_HOST_GNU_TYPE))
# place mingw builds under /usr/$(DEB_HOST_GNU_TYPE) prefix
DEB_CONFIGURE_PREFIX=/usr$(if $(findstring mingw,$(DEB_HOST_GNU_TYPE)),/$(DEB_HOST_GNU_TYPE))

# after patching .am files, we need update auto* stuff
DEB_AUTO_UPDATE_ACLOCAL=1.11
DEB_AUTO_UPDATE_AUTOHEADER=1.11
DEB_AUTO_UPDATE_LIBTOOL=pre
DEB_AUTO_UPDATE_AUTOCONF=1.11
DEB_AUTO_UPDATE_AUTOMAKE=1.11

#config.status: configure
#	dh_testdir
#	cp -f /usr/share/misc/config.sub /usr/share/misc/config.guess .
#	# Add here commands to configure the package.
#	./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info


#build: build-stamp
#build-stamp:  config.status
#	dh_testdir

#	# Add here commands to compile the package.
#	$(MAKE)

#	touch build-stamp

clean::
	dh_testdir
	dh_testroot
	rm -f build-stamp

	# Add here commands to clean up after the build process.
	[ ! -f Makefile ] || $(MAKE) distclean
	#rm -f config.sub config.guess

	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs

	# Add here commands to install the package into debian/tmp
	$(MAKE) install DESTDIR=$(CURDIR)/debian/tmp

	# Copy the example C files
	mkdir -p $(CURDIR)/debian/examples
	cp $(CURDIR)/sample/*.c $(CURDIR)/debian/examples
	cp $(CURDIR)/debian/Makefile.sample $(CURDIR)/debian/examples/Makefile

	dh_install --sourcedir=debian/tmp --list-missing


# 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
	dh_installexamples
	dh_installman
	dh_installchangelogs
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	dh_makeshlibs -V
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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