#! /usr/bin/make -f
%:
	dh $@

export DEB_CFLAGS_MAINT_APPEND := -Wall
# It is doubtful whether GRUB 0.97 plays well with hardening.  Use GRUB 2
# instead for that.
export DEB_BUILD_MAINT_OPTIONS := hardening=-all

override_dh_auto_configure:
	CFLAGS= LDFLAGS= dh_auto_configure -- \
		--libdir=\$${prefix}/lib --disable-auto-linux-mem-opt

override_dh_auto_build-arch:
	dh_auto_build

	## the creation of these manpages here is temporary,
	## when building grub finally works with the version
	## of autoconf in debian we can use MAINTAINER_MODE_TRUE
	# create man page for grub
	( cd docs && help2man \
	--name="the grub shell" \
	--include=grub.8.additions --include=help2man.additions \
	--section=8 --output=grub.8 \
	../grub/grub )

	# create man page for grub-install
	( cd util && chmod 755 grub-install )
	( cd docs && help2man \
	--name="install GRUB on your drive" \
	--include=grub-install.8.additions --include=help2man.additions \
	--section=8 --output=grub-install.8 \
	../util/grub-install )

	# create man page for mbchk
	( cd docs && help2man \
	--name="check the format of a Multiboot kernel" \
	--include=help2man.additions \
	--section=1 --output=mbchk.1 \
	../util/mbchk )

	# create man page for grub-md5-crypt
	( cd util && chmod 755 grub-md5-crypt )
	( cd docs && help2man \
	--name="Encrypt a password in MD5 format" \
	--include=help2man.additions \
	--section=8 --output=grub-md5-crypt.8 \
	../util/grub-md5-crypt )

override_dh_auto_build-indep:
	# create html documentation from texi files
	( cd docs && \
	  texi2html --init-file=../debian/texi2html.init -split_chapter \
	            --output=grub grub.texi )

override_dh_auto_test:

override_dh_clean:
	dh_clean
	chmod +x debian/script debian/kernel/*

override_dh_installinfo:
	cp docs/grub.info docs/grub-legacy.info
	dh_installinfo
