#!/usr/bin/make -f
# Sample debian/rules that uses debhelper. 
# GNU copyright 1997 by Joey Hess.

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

# This has to be exported to make some magic below work.
export DH_OPTIONS

# brace expansion
export SHELL=/bin/bash

DEB_HOST_ARCH		?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
DEB_HOST_GNU_TYPE	?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)

auto: auto-update-stamp
auto-update-stamp:
	@set -e; \
	for d in eicon; do \
	  echo "Regenerating autotools files in $$d ..."; \
	  cd $$d; \
	  echo "  autoconf2.13"; autoconf2.13; \
	  cd ..; \
	done

	touch auto-update-stamp

build: build-stamp
build-stamp: auto-update-stamp
	dh_testdir

	# we need a .config file. Try isdnutils.config in parent directory first
	# so that local choice can be preserved.
	test -f ../isdnutils.config && cp ../isdnutils.config .config || \
	    cp debian/dotconfig .config

	$(MAKE) subconfig
	$(MAKE)
	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp auto-update-stamp

	[ ! -f Makefile ] || $(MAKE) distclean

	: # remove updated/added autotools files
	find . -name config.sub -o -name config.guess -o \
		-name autom4te.cache -o -name config.cache -o \
		-name config.log -o -name config.status -o -name aclocal.m4 -o \
		-name config.h -o -o -name ltmain.sh | xargs rm -f
	rm -f eicon/configure
	find . -type l \
	    \( -name install-sh -o -name mkinstalldirs -o -name missing \
	       -o -name compile -o -name depcomp \
	    \) \
		| xargs rm -f

	[ ! -f Makefile ] || $(MAKE) distclean

	dh_clean

install: DH_OPTIONS=
install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs
	$(MAKE) install DESTDIR=`pwd`/debian/isdnactivecards
	cp pcbit/README.pt debian/isdnactivecards/usr/share/doc/isdnactivecards/README.pcbit.pt

binary-indep: 

# Build architecture-dependent files here.
# Pass -a to all debhelper commands in this target to reduce clutter.
binary-arch: DH_OPTIONS=-a
binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installdebconf
	dh_installdocs
	dh_installchangelogs
	dh_strip
	dh_link
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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