#! /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
	install -d debian/tmp/DEBIAN
	install -o root -g root -m 755 debian/preinst debian/tmp/DEBIAN
	install -d debian/tmp/usr/doc/$(package)
	install -o root -g root -m 644 debian/README \
			debian/tmp/usr/doc/$(package)/copyright
	install -d debian/tmp/bin debian/tmp/usr/man/man8
	install -o root -g root -m 755 fdflush debian/tmp/bin
	install -o root -g root -m 644 fdflush.1 debian/tmp/usr/man/man8/fdflush.8
	dpkg-shlibdeps fdflush
	dpkg-gencontrol
	dpkg --build debian/tmp ..

checkroot:
	test root = "`whoami`"

