#!/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='/usr/src/linux'
KVERS='2.6.22-grml'

build:
	cd acerhk-0.5.34 && KERNELSRC=$(KSRC) make && cp acerhk.ko ../ && cd ..
	cd atl2/src/ && make  && cp atl2.ko ../../ && cd ../../
	cd cowloop-2.15 && KVERS=$(KVERS) KERNDIR=$(KSRC) make cowloop.ko && cp cowloop.ko ../ && cd ..
	cd peak-linux-driver-4.3/driver && KERNSRC=$(KSRC) KVERSION=$(KVERS) make && cp pcan.ko ../../ && cd ../..
	cd r5u870-0.10.0 && make KDIR=$(KSRC) && cp r5u870.ko ../ && cd ../
	cd r1000_v1.04 && KDIR=$(KSRC) KVER=$(KVERS) make modules && cp src/r1000.ko ../ && cd ..
	cd sdricoh_cs-0.1.1 && KERNEL_DIR=$(KSRC) KERNEL_VERSION=$(KVERS) make && cp sdricoh_cs.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 atl2/src && make clean && cd ../..
	cd cowloop-2.15 && make clean && cd ../
	cd peak-linux-driver-4.3/driver && make clean && cd ../..
	cd r5u870-0.10.0 && make clean && cd ../
	cd r1000_v1.04 && make clean && cd ..
	cd sdricoh_cs-0.1.1 && make clean && cd ..

install: build
	dh_testdir
	dh_testroot
	dh_clean -k 
	dh_installdirs lib/modules/2.6.22-grml/misc

	# Add here commands to install the package into debian/grml-kerneladdons.
	install -m 644 *.ko debian/grml-kerneladdons-2.6.22/lib/modules/2.6.22-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.22-grml/misc/r1000.ko   /lib/modules/2.6.22-grml/kernel/drivers/net/r1000.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
