#! /usr/bin/make -f
#
# debian/rules for authbind
# 
# authbind is Copyright (C) 1998 Ian Jackson
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
#
# $Id: rules,v 1.3 1998/08/30 02:50:08 ian Exp $

CC= gcc

package=authbind
major=1
minor=0

arch = $(shell dpkg --print-architecture)

INSTALL = install
INSTALL_FILE    = $(INSTALL) -p    -o root -g root  -m  644
INSTALL_PROGRAM = $(INSTALL) -p    -o root -g root  -m  755
INSTALL_SCRIPT  = $(INSTALL) -p    -o root -g root  -m  755
INSTALL_DIR     = $(INSTALL) -p -d -o root -g root  -m  755

CFLAGS = -O2 -Wall
LDFLAGS = 

ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
CFLAGS += -g
LDFLAGS += -g 
endif
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
INSTALL_PROGRAM += -s
endif

export CFLAGS
export LDFLAGS
export INSTALL
export INSTALL_FILE
export INSTALL_PROGRAM
export INSTALL_SCRIPT
export INSTALL_DIR


build: 
	$(MAKE) prefix=/usr

clean:	
	$(MAKE) distclean
	rm -rf debian/{files,substvars,tmp} build
	rm -f debian/*~ debian/#*# debian/core debian/*.bak

binary-indep:   checkroot build
	$(checkdir)
# There are no architecture-independent files to be uploaded
# generated by this package.  If there were any they would be
# made here.

lab=libauthbind.so.$(major).$(minor)
udp=debian/tmp/usr/share/doc/$(package)

binary-arch:	checkroot build
	rm -rf debian/tmp
	install -d -g root -m 755 -o root debian/tmp/DEBIAN $(udp) \
		debian/tmp/usr/{bin,lib/$(package),share/man}
	$(MAKE) prefix=debian/tmp/usr etc_dir=debian/tmp/etc/authbind \
		man_dir=debian/tmp/usr/share/man  install install_man
	$(INSTALL_FILE) debian/changelog $(udp)/changelog
	gzip -9 debian/tmp/usr/share/man/man*/* $(udp)/*
	$(INSTALL_FILE) debian/copyright $(udp)/.
	$(INSTALL_SCRIPT) debian/{postrm,prerm,postinst} debian/tmp/DEBIAN
ifneq ($(arch),alpha)
	$(INSTALL_FILE) debian/shlibs debian/tmp/DEBIAN
else
	$(INSTALL_FILE) debian/shlibs.alpha debian/tmp/DEBIAN/shlibs
endif
	dpkg-shlibdeps ./authbind
	dpkg-gencontrol -isp
	chown -R root.root debian/tmp
	chmod -R g-ws debian/tmp
	dpkg --build debian/tmp ..

binary:	 binary-indep binary-arch

checkroot:
	$(checkdir)
	test root = "`whoami`"
