#!/usr/bin/make -f

# This script uses debhelper by Joey Hess
# Portions grabbed from device3dfx-source Copyright (C) 1999 Steve Haslam
export DH_VERBOSE=1
export DH_COMPAT=3
# enables magic below
export DH_OPTIONS

DEB=debian/tpctl
DOC=$(DEB)/usr/share/doc/tpctl

#VER=$(shell pwd |sed -e 's/.*-//')
# We write the source version number into the modules proto-changelog
# file. Determine it automagically
OURVERSION := $(shell head -1 debian/changelog | sed -e 's/.*(\(.*\)).*/\1/')

build:
	dh_testdir
	$(MAKE) LOCAL_LDFLAGS=-g
#	cd tpctlir && $(MAKE)

clean:
	dh_testdir
	dh_testroot
	rm -f debian/shlibs
	-$(MAKE) -i clean
#	cd tpctlir && $(MAKE) clean
	dh_clean

binary-indep: build

binary-arch: build
	#	dh_testversion 2
	dh_testdir
	dh_testroot
	dh_clean
	dh_installdirs usr usr/bin usr/sbin usr/lib
	cp tpctl/tpctl ntpctl/ntpctl $(DEB)/usr/bin
	# .so.x.y is file; .so.x is symlink; .so is symlink in -dev package
	cp -a lib/libsmapidev.so.?.? $(DEB)/usr/lib
	cp -a lib/libsmapidev.so.? $(DEB)/usr/lib
	dh_installdocs AUTHORS README TROUBLESHOOTING VGA-MODES
	#	cp tpctlir/tpctlir $(DEB)/usr/sbin
	#	cp tpctlir/README $(DOC)/README.tpctlir
	cp apmiser/apmiser $(DEB)/usr/sbin
	cp apmiser/README $(DOC)/README.apmiser
	dh_installman man/tpctl.1 man/ntpctl.1 man/apmiser.8
	dh_installchangelogs ChangeLog
	dh_installdebconf
	dh_makeshlibs
	dh_strip
	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
