#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

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

KSRC=/raid/Grml/kernel/linux-2.6.18-grml
KVERS='2.6.18-grml'

build:
	cd acerhk-0.5.34 && KERNELSRC=$(KSRC) make && cp acerhk.ko ../ && cd ..
	cd arcmsr-1.20.0X.13/kernel-version-2.6.x/arcmsr && make -C $(KSRC) CONFIG_SCSI_ARCMSR=m SUBDIRS=$(shell pwd)/arcmsr-1.20.0X.13/kernel-version-2.6.x/arcmsr modules && cp arcmsr.ko ../../../ && cd ../../../
	cd btsco/kernel &&  KSRC=$(KSRC) make && cp snd-bt-sco.ko ../../ && cd ../..
	cd cowloop-2.15 && KVERS=$(KVERS) KERNDIR=$(KSRC) make cowloop.ko && cp cowloop.ko ../ && cd ..
	cd et131x && KERNEL_VER=$(KVERS) KERNEL_DIR=$(KSRC) make && cp et131x.ko ../ && cd ..
	cd peak-linux-driver-4.3/driver && KERNSRC=$(KSRC) KVERSION=$(KVERS) make && cp pcan.ko ../../ && cd ../..
	cd r1000_v1.04 && KDIR=$(KSRC) KVER=$(KVERS) make modules && cp src/r1000.ko ../ && cd ..
	cd tpm_emulator-0.4 && KERNEL_BUILD=$(KSRC) KERNEL_RELEASE=$(KVERS) make && cp tpm_emulator.ko ../ && cd ..

binary:
	@echo nothing to be done...

clean:
	dh_testdir
	dh_testroot
	dh_clean 
	rm -f *.ko
	cd acerhk-0.5.34 && KERNELSRC=$(KSRC) make clean && cd ..
	cd arcmsr-1.20.0X.13/kernel-version-2.6.x/arcmsr &&  rm -f *.o *.ko && cd ../../..
	cd btsco/kernel &&  make clean && cd ../..
	cd cowloop-2.15 && make clean && cd ../
	cd et131x && make clean && cd ..
	cd peak-linux-driver-4.3/driver && make clean && cd ../..
	cd r1000_v1.04 && make clean && cd ..
	cd tpm_emulator-0.4 && KERNEL_BUILD=$(KSRC) KERNEL_RELEASE=$(KVERS) make clean && cd ..

install: build
	dh_testdir
	dh_testroot
	dh_clean -k 
	dh_installdirs lib/modules/2.6.18-grml/misc lib/modules/2.6.18-grml/kernel/drivers/scsi

	# Add here commands to install the package into debian/grml-kerneladdons.
	install -m 644 *.ko debian/grml-kerneladdons-2.6.18/lib/modules/2.6.18-grml/misc/

# Build architecture-independent files here.
binary-indep: install
# We have nothing to do by default.

# Build architecture-dependent files here.
binary-arch: install
	dh_testdir
	dh_testroot
	dh_installchangelogs 
	dh_installdocs
	dh_link /lib/modules/2.6.18-grml/misc/arcmsr.ko  /lib/modules/2.6.18-grml/kernel/drivers/scsi/arcmsr.ko
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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