#! /usr/bin/make -f
############################ -*- Mode: Makefile -*- ###########################
## rules ---
## Author	    : Manoj Srivastava ( srivasta@pilgrim.umass.edu )
## Created On	    : Sat Apr 27 06:36:31 1996
## Created On Node  : melkor.pilgrim.umass.edu
## Last Modified By : Manoj Srivastava
## Last Modified On : Tue Mar 21 01:02:08 2000
## Last Machine Used: glaurung.green-gryphon.com
## Update Count	    : 127
## Status	    : Unknown, Use with caution!
## HISTORY	    :
## Description	    :
##
###############################################################################

#
# VERSION=$(shell LC_ALL=C dpkg-parsechangelog | grep ^Version: | \
#                          sed 's/^Version: *//')
#

#    $Id: rules,v 1.23 2000/03/21 07:04:44 srivasta Exp $


# Please change the maintainer information, as well as the debian version
# below, (and maybe the priority as well, espescially if you are uploading
# an official package)

# The maintainer information.
maintainer := Manoj Srivastava
email := srivasta@debian.org

# Priority of this version (or urgency, as dchanges would call it)
priority := Low
#  Package specific stuff

# The name of the package (for example, `emacs').
package = kernel-package
version := $(shell perl -n0777e 'if ($$. == 1 && m/\(([\S]+)\)/o){print "$$1\n";}' debian/changelog)


FILES_TO_CLEAN  = debian/files
STAMPS_TO_CLEAN = stamp-binary
DIRS_TO_CLEAN   =

CONFLOC    := /etc/kernel-pkg.conf
LIBLOC     := /usr/share/kernel-package
MODULE_LOC := /usr/src/modules

# Location of the source dir
SRCTOP     := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
# where kernel-package files go to
DEBDIR     := $(LIBLOC)
DEBDIR_NAME:= $(shell basename $(DEBDIR))

DOCDIR  = debian/tmp/usr/share/doc/$(package)
MAN1DIR = debian/tmp/usr/share/man/man1
MAN5DIR = debian/tmp/usr/share/man/man5
MAN8DIR = debian/tmp/usr/share/man/man8

# install commands
install_file=    install -p    -o root -g root -m 644
install_program= install -p    -o root -g root -m 755
make_directory=  install -p -d -o root -g root -m 755


all build:
# Builds the binary package.

clean:
	rm -f $(FILES_TO_CLEAN) $(STAMPS_TO_CLEAN)
	rm -f -r debian/tmp
	rm -f core `find . \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
                -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
                -o -name '.*.rej' -o -name '.SUMS' -o -size 0 \) -print` TAGS

binary: binary-arch binary-indep

binary-arch: build
# builds the architecture dependent part

binary-indep: build stamp-binary

stamp-binary:
	@test $$(id | sed -e 's/(.*$$//' -e 's/^uid=//') || \
		(echo need root priviledges; exit 1)
	$(checkdir)
	rm -rf debian/tmp  debian/tmp.deb
	$(make_directory)  debian/tmp/DEBIAN
	$(make_directory)  debian/tmp/etc
	$(make_directory)  debian/tmp/usr/bin
	$(make_directory)  debian/tmp/usr/sbin
	$(make_directory)  debian/tmp/usr/share/$(package)
	$(make_directory)  $(MAN1DIR)
	$(make_directory)  $(MAN5DIR)
	$(make_directory)  $(MAN8DIR)
	$(make_directory)  $(DOCDIR)
	$(install_file)    debian/conffiles debian/tmp/DEBIAN/conffiles
	$(install_program) debian/postinst debian/tmp/DEBIAN/postinst
	$(install_program) debian/prerm debian/tmp/DEBIAN/prerm
	$(install_file)    debian/changelog $(DOCDIR)/changelog
	$(install_file)    README $(DOCDIR)/README
	$(install_file)    kernel/Flavours $(DOCDIR)/Flavours
	$(install_file)    Problems $(DOCDIR)/Problems
	$(install_file)    Multi-Arch $(DOCDIR)/Multi-Arch
	$(install_file)    Rationale $(DOCDIR)/Rationale
	gzip -9fqr         $(DOCDIR)
	$(install_file)    debian/copyright  	   $(DOCDIR)/copyright
	$(install_file)    kernel-pkg.conf.5 	   $(MAN5DIR)/kernel-pkg.conf.5
	$(install_file)    kernel-img.conf.5 	   $(MAN5DIR)/kernel-img.conf.5
	$(install_file)    kernel-package.5  	   $(MAN5DIR)/kernel-package.5
	$(install_file)    make-kpkg.8       	   $(MAN1DIR)/make-kpkg.1
	$(install_file)    kernel-packageconfig.8  $(MAN8DIR)/
	gzip -9fqr         debian/tmp/usr/share/man
	$(install_file)    kernel-pkg.conf debian/tmp/etc/kernel-pkg.conf
	$(install_program) kernel-packageconfig \
		           debian/tmp/usr/sbin/kernel-packageconfig
	$(install_program) make-kpkg debian/tmp/usr/bin/make-kpkg
	(cd kernel;        tar cf - * | \
           (cd             $(SRCTOP)/debian/tmp/usr/share/$(package);\
                           tar xf -))
	$(install_file)    Rationale $(SRCTOP)/debian/tmp/usr/share/$(package)/
	# Hack, tell the   rules file what version of kernel package it is
	sed -e             's/=K=V/$(version)/' kernel/rules > \
                              $(SRCTOP)/debian/tmp/usr/share/$(package)/rules
	dpkg-gencontrol -isp
	chown -R root.root debian/tmp
	dpkg --build       debian/tmp ..
	touch              stamp-binary

define checkdir
        test -f  make-kpkg -a -f debian/rules
endef

source diff:
	@echo >&2 'source and diff are obsolete - use dpkg-source -b'; false


.PHONY: binary binary-arch binary-indep clean

