#!/usr/bin/make -f
# Made with the aid of dh_make, by Craig Small
# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess.
# This version is for a hypothetical package that builds an
# architecture-dependant package, as well as an architecture-independant
# package.

package=radiusclient

version=$(shell expr `pwd` : '.*-\([0-9.]*\)')
version_major=$(shell expr `pwd` : '.*-\([0-9]*\).[0-9.]*')
version_so=0.0.1

topdir=$(shell pwd)

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

build: build-stamp
build-stamp:
	dh_testdir

	./configure --prefix=/usr --sysconfdir=/etc --enable-shadow

# Patch the generated libtool to avoid passing -rpath when linking,
# and to explicitly link libraries against the libraries they
# depend on.
	sed < libtool > libtool-2 \
	  -e 's/^hardcode_libdir_flag_spec.*$$/hardcode_libdir_flag_spec=" -D__LIBTOOL_IS_A_FOOL__ "/' \
	  -e '/^archive_cmds="/s/"$$/ \\$$deplibs"/'
	mv libtool-2 libtool
	chmod 755 libtool

	make

	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp

	-rm -rf static shared

	# Add here commands to clean up after the build process.
	-$(MAKE) distclean

	dh_clean

dirs:
	dh_installdirs

	dh_testdir
	dh_testroot

	dh_installdocs
	dh_installexamples
	dh_installmenu
#	dh_installmanpages
	dh_undocumented login.radius.1 radacct.1 radexample.1 radlogin.1 radstatus.1
	dh_installchangelogs CHANGES 

binary-arch: dirs radiusclient1 libradius1 libradius1-dev
	dh_installdeb

	dh_strip
	dh_compress
	dh_fixperms

	dh_shlibdeps
	dh_gencontrol
	dh_makeshlibs -m$(version_so)
	dh_md5sums

	dh_builddeb

radiusclient1: build
	for file in radacct radexample radlogin radstatus; do \
	  install -m755 $(topdir)/src/.libs/$$file $(topdir)/debian/tmp/usr/sbin; \
	done
	install -m755 $(topdir)/login.radius/migs/login.radius $(topdir)/debian/tmp/usr/sbin
	for file in issue port-id-map radiusclient.conf dictionary dictionary.ascend dictionary.compat dictionary.merit servers; do \
	  install -m644 $(topdir)/etc/$$file $(topdir)/debian/tmp/etc/radiusclient; \
	done

libradius1: build
	install -m755 $(topdir)/lib/.libs/libradiusclient.so.$(version_so) debian/libradius1/usr/lib
	cd debian/libradius1/usr/lib && ln -s libradiusclient.so.$(version_so) libradiusclient.so.0

libradius1-dev: build
	install -m644 $(topdir)/include/radiusclient.h $(topdir)/debian/libradius1-dev/usr/include
	install -m644 $(topdir)/lib/.libs/libradiusclient.a $(topdir)/debian/libradius1-dev/usr/lib
	install -m644 $(topdir)/lib/libradiusclient.la $(topdir)/debian/libradius1-dev/usr/lib
	cd debian/libradius1-dev/usr/lib && ln -s libradiusclient.so.$(version_so) libradiusclient.so

source diff:                                                                  
	@echo >&2 'source and diff are obsolete - use dpkg-source -b'; false

binary: binary-arch
.PHONY: build clean binary-arch binary radiusclient1 libradius1-dev

# Local variables:
# mode: Makefile
# End:
