#!/usr/bin/make -f
#
# debian/rules for fai-kernels
#
# $Id: rules,v 1.4 2002/01/03 13:52:27 lange Exp $

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

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

DEB_HOST_ARCH=$(MACHTYPE)
BOOTP_REVISION=BOOTP1
DHCP_REVISION=DHCP1
kversion=$(shell cat kernel-version)

kname=kernel-source-$(kversion)

unpack: unpack-stamp
unpack-stamp:
	bzcat /usr/src/$(kname).tar.bz2 | tar -xf -
	touch unpack-stamp

# kernel using BOOTP protocol
bootp: bootp-stamp
bootp-stamp: unpack-stamp kernel-config fai-kernel-config-bootp
	cat kernel-config fai-kernel-config-bootp > $(kname)/.config
	cd $(kname) ; \
	echo -e "\t\n\n" | make menuconfig ; \
	make-kpkg clean ; \
	make-kpkg --revision $(BOOTP_REVISION) kernel-image 
	touch bootp-stamp

# kernel using DHCP protocol
dhcp: dhcp-stamp
dhcp-stamp:
	cat kernel-config fai-kernel-config-bootp enable-dhcp > $(kname)/.config
	cd $(kname) ; \
	echo -e "\t\n\n" | make menuconfig ; \
	make-kpkg clean ; \
	make-kpkg --revision $(DHCP_REVISION) kernel-image 
	touch dhcp-stamp

build: bootp-stamp dhcp-stamp

veryclean:
	rm -f *-stamp *.deb
	-rm -rf $(kname)
	dh_clean

clean:
	dh_clean

install: install-stamp
install-stamp: build
	dh_clean -k
	dh_installdirs
	cp -p *.deb `pwd`/debian/fai-kernels/usr/lib/fai/kernel
	touch install-stamp

# Build architecture-independent files here.
binary-indep: build install
#	dh_testversion

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installdocs
	dh_installchangelogs 
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary: binary-arch
.PHONY: build clean binary-indep binary-arch binary install unpack bootp dhcp
