#!/usr/bin/make -f
# $Id: rules 1493 2008-02-08 08:47:24Z xam $

PACKAGE	:= loop-aes
PACKAGE_DIR = debian/$(PACKAGE)
MODULES_DIR = $(PACKAGE_DIR)/usr/src/modules
TESTSUITE_DIR = $(PACKAGE_DIR)/usr/share/loop-aes-testsuite

build:
# Nothing to do

install: build install-source install-testsuite

install-source: PACKAGE = loop-aes-source
install-source: 
	dh_testdir
	dh_testroot
	dh_clean -p$(PACKAGE)
	dh_installdirs -p$(PACKAGE)
	dh_installchangelogs -p$(PACKAGE) ChangeLog
	dh_installdocs -p$(PACKAGE) README debian/README.Debian

	dh_install -p$(PACKAGE) $(filter-out debian,$(wildcard *)) usr/src/modules/loop-aes
	dh_install -p$(PACKAGE) debian/copyright debian/changelog debian/compat debian/README.Debian debian/Makefile-2.6 $(wildcard debian/modules/*) usr/src/modules/loop-aes/debian

	dh_fixperms -p$(PACKAGE)
	chmod +x $(MODULES_DIR)/loop-aes/debian/rules
	cd $(MODULES_DIR)/.. && tar cvf - modules | bzip2 -9 > loop-aes.tar.bz2
	rm -rf $(MODULES_DIR)

install-testsuite: PACKAGE = loop-aes-testsuite
install-testsuite:
	dh_testdir
	dh_testroot
	dh_clean -p$(PACKAGE)
	dh_installdirs -p$(PACKAGE)
	dh_installchangelogs -p$(PACKAGE)
	dh_installdocs -p$(PACKAGE)
	dh_installman -p$(PACKAGE) debian/loop-aes-runtests.8

	mkdir -p $(TESTSUITE_DIR) 
	cp gpgkey*.asc $(TESTSUITE_DIR)
	cp Makefile $(TESTSUITE_DIR)
	install -m 0755 -D debian/loop-aes-runtests $(PACKAGE_DIR)/usr/sbin/loop-aes-runtests

binary: binary-arch binary-indep

binary-arch:
# Nothing to do

binary-indep: install
	dh_compress -i
	dh_fixperms -i
	dh_installdeb -i
	dh_gencontrol -i
	dh_md5sums -i
	dh_builddeb -i

clean:
	dh_testdir
	dh_testroot
	dh_clean

.PHONY: clean binary-indep binary-arch binary build install install-source install-testsuite
