#! /usr/bin/make -f

# Debian package information
package			= fdflush

# C compiler information
CC				= gcc
CFLAGS			= -O2
LDFLAGS			= -s

all build:
	make CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)"
	touch stamp-build

clean:
	make $(MFLAGS) distclean
	rm -f stamp-build debian/files debian/substvars
	rm -rf debian/tmp

binary: binary-indep binary-arch

binary-indep:

binary-arch: checkroot
	test -f stamp-build || make $(MFLAGS) -f debian/rules build
	-rm -rf debian/tmp

# Install Debian-specific stuff
	install -d debian/tmp/DEBIAN
	install -o root -g root -m 755 debian/preinst debian/tmp/DEBIAN

# Install executable
	install -d debian/tmp/bin
	install -o root -g root -m 755 fdflush debian/tmp/bin

# Install manpages
	install -d debian/tmp/usr/man/man1
	install -o root -g root -m 644 fdflush.1 debian/tmp/usr/man/man1/fdflush.1

# Install everything
	dh_installdocs
	dh_installchangelogs
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb
		
checkroot:
	test root = "`whoami`"

