#!/usr/bin/make -f
# Made with the aid of dh_make, by Craig Small
# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess.
# Some lines taken from debmake, by Cristoph Lameter.
# Copyright (C) 2005 Anibal Monsalve Salazar <anibal@debian.org>

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

DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

DESTDIR = `pwd`/debian/ncpfs

IVARS = DESTDIR=$(DESTDIR)

ifneq (,$(findstring ia64, ${DEB_BUILD_ARCH}))
CONFIGARGS = --prefix=/usr --sysconfdir=/etc \
	--mandir=/usr/share/man --enable-pam \
	--disable-function-sections
else
CONFIGARGS = --prefix=/usr --sysconfdir=/etc \
	--mandir=/usr/share/man --enable-pam
endif

build: build-stamp
build-stamp:
	dh_testdir

	cp -f /usr/share/misc/config.sub .
	cp -f /usr/share/misc/config.guess .
	# Add here commands to compile the package.
	[ -f Makefile ] || ./configure ${CONFIGARGS}

	$(MAKE)

	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp install-stamp po/de.gmo
	rm -f config.sub config.guess

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

	dh_clean

install: install-stamp
install-stamp: build-stamp
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs

	# Install binaries
	$(MAKE) install $(IVARS)

	# Now install development files for the libncp-dev package
	$(MAKE) install-dev $(IVARS)

	# This is to comply with policy (the symlink that ldconfig would 
	#	produce must exist in the package).
	/sbin/ldconfig -n $(DESTDIR)/usr/lib/

	# Install ipx's conffiles
	install -m 0644 debian/ipx.conf $(DESTDIR)/etc/ipx.conf

	dh_movefiles --sourcedir=debian/ncpfs

	# Ooppsss, wrong location!
	mv debian/libncp/usr/lib/libncp.a debian/libncp-dev/usr/lib/

	# Delete unwanted directories left around by dh_movefiles
	rm -Rf $(DESTDIR)/etc/
	rm -Rf $(DESTDIR)/lib/
	rm -Rf $(DESTDIR)/usr/include/
	rm -Rf $(DESTDIR)/usr/lib/
	rm -Rf $(DESTDIR)/usr/share/man/man3/

	touch install-stamp

# 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 -A
	dh_installman
	dh_installexamples
	dh_installinit
	dh_installchangelogs Changes
	dh_lintian
	dh_link
	dh_strip
	dh_compress
	dh_fixperms

	dh_installdeb
	dh_shlibdeps -l$(DESTDIR)/usr/lib/
	dh_gencontrol
	dh_md5sums
	dh_builddeb

source diff:                                                                  
	@echo >&2 'source and diff are obsolete - use dpkg-source -b'; false

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