#! /usr/bin/make -f
#
# Debian rules extensively rewritten by Martin Mitchell <martin@debian.org>

DPKG_EXPORT_BUILDTOOLS=1
include /usr/share/dpkg/architecture.mk
-include /usr/share/dpkg/buildtools.mk

CFLAGS = -O2 -g -Wall -DUNIX -DNOPROTO -ffile-prefix-map=$(CURDIR)=.
LDFLAGS = -s
STRIP=$(DEB_HOST_GNU_TYPE)-strip --strip-unneeded --remove-section=.note --remove-section=.comment

build:
# Builds the binary package.
	make CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)"
	touch build

clean:
# Undoes the effect of `make -f debian/rules build'.
	rm -f build
	rm -rf debian/tmp debian/substvars debian/files debian/*~
	rm -f *.o beav core

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.

binary-arch:	checkroot build
	test -f build || make -f debian.rules build
	rm -rf debian/tmp
	install -d -g root -m 755 -o root debian/tmp/usr/share/doc/beav debian/tmp/DEBIAN debian/tmp/usr/bin debian/tmp/usr/share/man/man1
	install -g root -m 755 -o root beav debian/tmp/usr/bin/beav
	$(STRIP) debian/tmp/usr/bin/beav
	install -g root -m 644 -o root beav.1 debian/tmp/usr/share/man/man1/beav.1
	gzip -9vn debian/tmp/usr/share/man/man1/*
	cp debian/changelog debian/tmp/usr/share/doc/beav/changelog.Debian
	cp beav140.txt debian/tmp/usr/share/doc/beav
	gzip -9vn debian/tmp/usr/share/doc/beav/*
	cp debian/copyright debian/tmp/usr/share/doc/beav
	dpkg-shlibdeps debian/tmp/usr/bin/beav
	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`"

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