#! /usr/bin/make -f
############################ -*- Mode: Makefile -*- ###########################
## rules --- $Date: 2001/01/08 06:48:23 $ $Revision: 1.1 $ lowe@debian.org
## 
## This is the debian/rules file for the debian linneighborhood package
## Hacked by Will Lowe <lowe@debian.org>
## from the rules file for the make package,  written by
## Manoj Srivastava ( srivasta@tiamat.datasync.com )
##
###############################################################################

# The name of the package (for example, `emacs').
package := tcpstat

# Configuration variables (these should be pretty generic)
CC = gcc
#CFLAGS = -O2
# FSViewer already uses -O2,  and adding this again screws up
# the #includes
# LDFLAGS = -s
# this causes problems too,  so we skip it and call strip -s later
PREFIX = /usr
DEBIANDOCDIR = /usr/share/doc/$(package)

# Code for passing configure script the proper architecture
export DEB_HOST_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
export DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)

ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
  confflags += --build $(DEB_HOST_GNU_TYPE)
else
  confflags += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
endif


#  Package specific stuff.  The idea is to try to make the rules
#  generic (gradually).

FILES_TO_CLEAN  = TAGS tags debian/files 
DIRS_TO_CLEAN   = debian/tmp 
STAMPS_TO_CLEAN =  stamp-configure stamp-build stamp-binary include/stamp-h1

install_file= install -p -o root -g root -m 644
install_program= install -p -o root -g root -m 755
make_directory= install -d -o root -g root -m 755
install_link= ln -s

all build: stamp-build
# Builds the binary package.

configure: stamp-configure

stamp-configure:
	aclocal-1.10
	automake-1.10
	autoconf
	./configure $(confflags) --prefix=/usr --mandir=/usr/share/man
	touch stamp-configure

stamp-build:
	dh_testdir
	-test -f stamp-configure || $(MAKE) -f debian/rules configure 
	make
	touch stamp-build

clean:	stamp-configure
	dh_testdir
	make distclean
	-rm -f  $(FILES_TO_CLEAN) $(STAMPS_TO_CLEAN)
	-rm -rf $(shell find . -name 'Makefile.in' -o \
                     -name 'aclocal.m4' -o \
                     -name 'configure' -o \
		     -name 'autom4te.cache')

	dh_clean

binary: binary-indep binary-arch

# binary-indep: html stamp-doc

binary-arch: build stamp-binary

# Makes a binary package.
stamp-binary:
	@test root = "`whoami`" || (echo need root priviledges; exit 1)
	dh_testdir
	@test -f stamp-build  || $(MAKE) -f debian/rules build
	rm -rf               debian/tmp debian/tmp.deb
	dh_installdirs
	make install prefix=$(CURDIR)/debian/tmp/usr mandir=$(CURDIR)/debian/tmp/usr/share/man
	dh_install debian/tmp/usr
	dh_installchangelogs ChangeLog
	dh_installdocs README AUTHORS doc/Tips_and_Tricks.txt
	dh_installinfo      
	dh_installmenu
	dh_compress
	dh_strip
	dh_installdeb
	dh_shlibdeps
	dh_md5sums
	dh_gencontrol
	dh_fixperms
	dh_builddeb
	touch                $@

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


.PHONY: binary binary-arch binary-indep clean

