#!/usr/bin/make -f
# Sample debian.rules file - for GNU Hello (1.3).
# Copyright 1994,1995 by Ian Jackson.
# I hereby give you perpetual unlimited permission to copy,
# modify and relicense this file, provided that you do not remove
# my name from the file itself.  (I assert my moral right of
# paternity under the Copyright, Designs and Patents Act 1988.)
# This file may have to be extensively modified
#
# Modified to be a prototype for debmake by Christoph Lameter <clameter@debian.org>
#
# Modified to work with debhelper-tools by Christian Kurz <shorty@debian.org>

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


build: build-stamp
build-stamp:
	dh_testdir
	#if [ -x configure ]; then ./configure --prefix=/usr; fi
	make CFLAGS="-O2 -g -Wall -fPIC"
	gcc -g -shared -Wl,-soname,libefence.so.0 -o libefence.so.0.0 efence.o page.o print.o -lc -lpthread
	rm *.o
	make CFLAGS="-O2 -g -Wall"
	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp
	rm -f libefence.so.0.0
	dh_clean
	-$(MAKE) -i clean

# Build architecture-independent files here.
binary-indep: build
# We have nothing to do by default.

# Build architecture-dependent files here.
binary-arch: build
	dh_testdir
	dh_testroot
	dh_clean
	dh_installdirs usr/lib usr/share/man/man3
	install -m 644 libefence.a debian/tmp/usr/lib
	install -m 644 libefence.so.0.0 debian/tmp/usr/lib
	dh_link /usr/lib/libefence.so.0.0 /usr/lib/libefence.so.0
	#ln -s debian/tmp/usr/lib/libefence.so.0 ./libefence.so
	dh_link /usr/lib/libefence.so.0 /usr/lib/libefence.so
	install -m 644 libefence.3 debian/tmp/usr/share/man/man3/libefence.3
	dh_installdocs README debian/README.gdb
	dh_installchangelogs
	dh_installmanpages -pefence libefence.3
	chown -R root.root debian/tmp
	dh_strip
	dh_compress
	dh_installdeb
	dh_fixperms
	dh_shlibdeps debian/tmp/usr/lib/libefence.so.0.0
	dpkg-shlibdeps debian/tmp/usr/lib/libefence.so.0.0
	dh_gencontrol
	dh_md5sums
	dh_builddeb	

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