#!/usr/bin/make -f
# debian/rules build file for eject copyright Martin Mitchell 2001.
# this file is placed under the GNU GPL.

package=eject
STRIP=strip --strip-unneeded --remove-section=.note --remove-section=.comment

build:
	$(checkdir)
	./configure --prefix=/usr
	$(MAKE) CFLAGS="-Wall -O2 -g"
	touch build

clean:
	$(checkdir)
	-rm -f build
	-$(MAKE) distclean
	-rm `find . -name "*~"`
	-rm -rf debian/tmp debian/files* debian/substvars

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
	$(checkdir)
	-rm -rf debian/tmp
	install -d debian/tmp/DEBIAN debian/tmp/usr/bin debian/tmp/usr/share/doc/eject debian/tmp/usr/share/man/man1
	install -m 755 eject debian/tmp/usr/bin/eject
	install -m 644 eject.1 debian/tmp/usr/share/man/man1
	$(STRIP) debian/tmp/usr/bin/eject
	install -m 755 volname debian/tmp/usr/bin/volname
	install -m 644 volname.1 debian/tmp/usr/share/man/man1
	$(STRIP) debian/tmp/usr/bin/volname
	gzip -9v debian/tmp/usr/share/man/man1/*
	cp ChangeLog README debian/tmp/usr/share/doc/eject
	cp debian/changelog debian/tmp/usr/share/doc/eject/changelog.Debian
	gzip -9v debian/tmp/usr/share/doc/eject/*
	cd debian/tmp/usr/share/doc/eject && ln -s ChangeLog.gz changelog.gz
	cp debian/copyright debian/tmp/usr/share/doc/eject
	dpkg-shlibdeps debian/tmp/usr/bin/eject
	dpkg-gencontrol -isp
	chown -R root.root debian/tmp
	chmod -R g-ws debian/tmp
	dpkg --build debian/tmp ..

define checkdir
	test -f $(package).c -a -f debian/rules
endef

# Below here is fairly generic really

binary:		binary-indep binary-arch

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

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