#!/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
export DESTDIR=$(CURDIR)/debian/$(PACKAGE_NAME)/usr/lib/mindi/rootfs

# Define package name for a one-stop change.
PACKAGE_NAME = PBPKG

# Don't set any compiler flags - busybox does that just fine

configure: configure-stamp

configure-stamp:
	dh_testdir
	touch configure-stamp

# Build both architecture dependent and independent
build: build-stamp

build-stamp: configure-stamp
	dh_testdir

	# Compile the package.
	mv .config .config.sav
	$(MAKE) distclean
	mv .config.sav .config
	$(MAKE) oldconfig
	$(MAKE) busybox

	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp configure-stamp
	# Clean temporary document directory
	rm -rf debian/doc-temp
	# Clean up.
	-mv .config .config.sav
	-$(MAKE) distclean
	-mv .config.sav .config
	-rm -f busybox

	dh_clean

# Install architecture dependent and independent
install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	# Install the package files into build directory:
	# - start with upstream make install
	$(MAKE) install CONFIG_PREFIX=$(DESTDIR)
	./mondo-install.sh
	# - copy doc
	mkdir -p debian/doc-temp
	cp -a INSTALL LICENSE AUTHORS README TODO NEWS debian/doc-temp #svn.log ChangeLog 

	dh_install -s

# Build architecture dependant packages using the common target.
binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installdocs
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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