#!/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

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

PREFIX_ARCB=${CURDIR}/debian/arcboot
PREFIX_TIP22=${CURDIR}/debian/tip22

architecture=$(dpkg --print-architecture)

configure: configure-stamp
configure-stamp:
	dh_testdir
	# Add here commands to configure the package.

	touch configure-stamp

build: configure-stamp build-stamp
build-stamp:
	dh_testdir

	# Add here commands to compile the package.
	make
	cp ext2load/ext2load arcboot.raw

	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp configure-stamp

	# Add here commands to clean up after the build process.
	-$(MAKE) clean
	-rm -f arcboot.raw

	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	# install arcboot into debian/arcboot
	install -m 644 arcboot.raw ${PREFIX_ARCB}/usr/lib/arcboot/arcboot.raw
	install -m 755 scripts/arcboot ${PREFIX_ARCB}/usr/sbin/arcboot

	# install tip22 into debian/tip22
	make PREFIX=${PREFIX_TIP22} -C tip22 install

# Build architecture-independent files here.
binary-indep: build install
# nothing to do

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installdebconf -parcboot -ptip22
	dh_installdocs -parcboot -ptip22
	dh_installexamples etc/arcboot.conf -parcboot
	dh_installexamples tip22/kernel/ -ptip22
	dh_installmenu
#	dh_installlogrotate
#	dh_installemacsen
#	dh_installpam
#	dh_installmime
#	dh_installinit
	dh_installcron
	dh_installman -parcboot -ptip22
	dh_installinfo
#	dh_undocumented
	dh_installchangelogs -parcboot -ptip22
	dh_link -parcboot -ptip22
	dh_strip -parcboot -ptip22
	dh_compress -parcboot -ptip22
	dh_fixperms -parcboot -ptip22
#	dh_makeshlibs
	dh_installdeb -parcboot -ptip22
#	dh_perl
	dh_shlibdeps -parcboot -ptip22
	dh_gencontrol -parcboot -ptip22
	dh_md5sums -parcboot -ptip22
	dh_builddeb -parcboot -ptip22

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