#!/usr/bin/make -f
#
# To make the binary distribution package, the ``Debianized'' source package
# and the context diff to the original package, type `./debian.rules dist'.
# Make sure that `debian.rules' is executable before the final distribution
# is made.
#
# Invoke each target with `./debian.rules <target>'.  All targets should be
# invoked with the package root as the current directory.
#
# The `binary' target must be run as root, as it needs to install files with
# specific ownerships.  The `diff' target assumes that you have the original
# source package available, unpacked, in ../$(p)-$(v).orig, or that you have
# the previous revision of the ``Debianized'' source package and context diff
# in the parent directory.
#
# Last updated: Sat Apr 5 15:55:51 COT 2003 by Andrs Roldn.

include /usr/share/dpatch/dpatch.make

BUILD_DIR=`pwd`/debian

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
 
# This is the debhelper compatability version to use.
export DH_COMPAT=3

build: patch
	@echo "Compiling..."
	$(checkdir)
# Builds the binary package.
#	 ./configure --prefix=/
	@if [ -r $$ROOT/etc/lilo.defines ]; then \
		echo "******************************************"; \
		echo "WARNING: lilo.defines overwriting defaults"; \
	fi
	#make LDFLAGS="-s"
	make all
	make docs
	#make -C doc user.ps tech.ps
	touch build

clean: unpatch
	@echo "Cleaning..."
# Undoes the effect of `make -f debian/rules build'.
	$(checkdir)
	make spotless
	-rm -f build debian/files debian/lilo.substvars debian/substvars debian/*~ *~
	-rm -f doc/*.{dvi,ps,aux,toc,log}
	-rm -rf debian/lilo debian/lilo-doc debian/*.debhelper debian/patched

	# Make sure that we provide up-to-date POT and PO files
	debconf-updatepo

binary-indep:   checkroot build
	$(checkdir)

binary-arch:    checkroot build lilo-pkg

PKGNAME=lilo

lilo-pkg:
	$(checkdir)
	rm -rf debian/$(BUILD_DIR)/$(PKGNAME)
	dh_installdirs -p$(PKGNAME) -P$(BUILD_DIR)/$(PKGNAME)
	install -g root -m 755 -o root $(PKGNAME) debian/$(PKGNAME)/sbin/lilo.real
	install -g root -m 755 -o root mkrescue debian/$(PKGNAME)/usr/sbin/
	install -g root -m 755 -o root debian/lilo.sh debian/$(PKGNAME)/sbin/lilo
	install -g root -m 755 -o root activate debian/$(PKGNAME)/sbin/
	install -g root -m 755 -o root keytab-lilo.pl debian/$(PKGNAME)/usr/sbin/keytab-lilo
	install -g root -m 755 -o root debian/liloconfig debian/$(PKGNAME)/usr/sbin/
	install -g root -m 755 -o root debian/lilo_find_mbr debian/$(PKGNAME)/usr/sbin/
	dh_installdocs  
	cp debian/contrib/debianlilobmp.conf debian/lilo/usr/share/lilo/
	cp debian/contrib/sidbmp.conf debian/lilo/usr/share/lilo/
	cp debian/contrib/sargebmp.conf debian/lilo/usr/share/lilo/
	cp debian/contrib/coffeebmp.conf debian/lilo/usr/share/lilo/
	uudecode debian/contrib/sid-menu
	uudecode debian/contrib/sarge-menu
	uudecode debian/contrib/debianlilo-menu
	uudecode debian/contrib/coffee-menu
	cp debian/contrib/lilo-term.xpm debian/lilo/usr/share/pixmaps
	cp debian/Makefile.floppy bootsect.b debian/$(PKGNAME)/usr/lib/lilo
	cp README debian/$(PKGNAME)/usr/share/doc/$(PKGNAME)/Manual.txt
	dh_installman 
	dh_installdebconf 
	dh_installchangelogs -plilo CHANGES upstream
	dh_installchangelogs 
	dh_installexamples
	dh_installmenu 
	dh_link
	dh_strip  
	dh_compress 
	dh_fixperms 
	dh_shlibdeps  
	dh_gencontrol 
	dh_installdeb  
	dh_md5sums  
	dh_builddeb  

binary: binary-indep binary-arch

checkroot:
	dh_testroot
	
.PHONY: build clean binary-indep binary-arch binary patch unpatch
