#!/usr/bin/make -f
# debian/rules for device3dfx-module
# Copyright (C) 1999 Steve Haslam
# Distributable under the terms of the GNU GPL version 2 (or later).

# This rules file is intended only to build the device3dfx-module-KVER
# package.

M4 = m4
M4DEFINES = -DKVERS="$(KVERS)" -DKSRC="$(KSRC)" -DKEMAIL="$(KEMAIL)" -DKMAINT="$(KMAINT)" -DKDREV="$(KDREV)" -DDEBDATE="$(shell date +"%a, %d %b %Y %H:%M:%S %z")"

# We are called from make-kpkg through one of the targets kdist,
# kdist_configure, kdist_changes or kdist_image
# When called from make-kpkg we have available:
#  KVERS
#  KSRC
#  KEMAIL
#  KMAINT
#  KDREV

configure: configure-stamp
configure-stamp: debian/control debian/changelog
	touch $@

build: build-stamp
build-stamp: configure-stamp
	dh_testdir
#	this makes 3dfx.o
	$(MAKE) -f Makefile.debian
	touch $@

install: install-stamp
install-stamp: build-stamp
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	install -d debian/tmp/lib/modules/$(KVERS)/misc
	install -m 644 3dfx.o debian/tmp/lib/modules/$(KVERS)/misc/3dfx.o

	touch $@

clean:
#	dh_testdir
	test -f debian/control.m4
#	dh_testroot
	test "$(shell whoami)" = "root"
	if test -f debian/control; then dh_clean; fi
	$(MAKE) clean
	rm -f configure-stamp build-stamp install-stamp debian/control debian/changelog

kdist_clean: clean

debian/control: debian/control.m4
	$(M4) $(M4DEFINES) debian/control.m4 > $@

debian/changelog: debian/changelog.m4
	$(M4) $(M4DEFINES) debian/changelog.m4 > $@

.PHONY: build install configure

kdist_configure: configure-stamp

kdist_changes:
	@echo >&2 'Note: kdist_changes is obsolete'

kdist_image: install-stamp
#	dh_testversion
	dh_testdir
	dh_testroot
#	dh_installdebconf	
	dh_installdocs
	dh_installexamples
	dh_installmenu
#	dh_installemacsen
#	dh_installpam
#	dh_installinit
	dh_installcron
	dh_installmanpages
	dh_installinfo
	dh_installmodules
#	dh_undocumented
	dh_installchangelogs
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	# You may want to make some executables suid here.
	dh_suidregister
#	dh_makeshlibs
	dh_installdeb
#	dh_perl
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb --destdir=$(KSRC)/..

kdist: kdist_image
	@echo >&2 'kdist- not implemented'

.PHONY: kdist kdist_image kdist_changes kdist_configure

# We are called from dpkg-build through one of the targets binary,
# binary-arch: fault these.

binary binary-arch:
	@echo >&2 'Use make-kpkg to compile this module' && false

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

.PHONY: binary binary-arch source diff
