#!/usr/bin/make -f
#
# debian/rules for kernel-image-*-i386.
#
# GNU copyright 1997 to 1999 by Joey Hess.
# Copyright (c) 1999 Herbert Xu <herbert@debian.org>
#
# $Id: rules,v 1.10 2000/04/25 05:28:17 herbert Exp $

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

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

Version:=$(shell head -1 debian/changelog | sed 's/^kernel-image-\(.*\)-i386.*$$/\1/')

unpack: unpack-stamp
unpack-stamp:
	tar Ixf /usr/src/kernel-source-$(Version).tar.bz2

	touch unpack-stamp

build: build-stamp
build-stamp: unpack-stamp
	mkdir -p kernel-source-$(Version)/debian
	cp debian/changelog kernel-source-$(Version)/debian
	cp debian/control kernel-source-$(Version)/debian
	echo official > kernel-source-$(Version)/debian/official
	cp debian/config kernel-source-$(Version)/.config
	cd kernel-source-$(Version); make-kpkg build

	touch build-stamp

clean:
	rm -f build-stamp install-stamp unpack-stamp

	-rm -rf kernel-source-$(Version)

	dh_clean

install: install-stamp
install-stamp: build-stamp
	dh_clean -k
	dh_installdirs
	touch install-stamp

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

# Build architecture-dependent files here.
binary-arch: build install
#	dh_testversion
	cd kernel-source-$(Version); \
		make-kpkg kernel-headers; \
		make-kpkg kernel-image
	cp kernel-source-$(Version)/debian/files debian
	cd kernel-source-$(Version); \
		make-kpkg clean; \
		/usr/src/kernel-patches/i386/$(Version)/apply/ide; \
		sed 's/^\(KERNELRELEASE=.*\)$$/\1-$$(FLAVOUR)/' Makefile > Makefile.new; \
		mv Makefile.new Makefile; \
		cp ../config/ide .config; \
		make-kpkg --flavour ide kernel-image
	cat kernel-source-$(Version)/debian/files >> debian/files
	mv *.deb ..

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