#!/usr/bin/make -f
# Sample debian.rules file - for GNU Hello (1.3).
# Copyright 1994,1995 by Ian Jackson.
# I hereby give you perpetual unlimited permission to copy,
# modify and relicense this file, provided that you do not remove
# my name from the file itself.  (I assert my moral right of
# paternity under the Copyright, Designs and Patents Act 1988.)
# This file may have to be extensively modified
#
# Modified to be a prototype for debmake by Christoph Lameter <clameter@debian.org>

package=flip

# build without debugging symbols and strip executables when installing,
# unless DEB_BUILD_OPTIONS specifies otherwise
CFLAGS = -O2 -Wall
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

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

# the source package has a .o file for a different architecture
build:
	$(checkdir)
	-rm -f core `find . -name flip.o -mtime +20`
	make bsd

	touch build

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

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
	for x in bin sbin man/man1; do ${INSTALL_DIR} debian/tmp/usr/$$x; done
	make bsd
	${INSTALL_PROGRAM} flip `pwd`/debian/tmp/usr/bin
	${INSTALL_FILE} flip.1 `pwd`/debian/tmp/usr/man/man1
#	dh_installtests
	for d in `cat debian/dirs`; do install -d debian/tmp/$$d; done
	install debian/tests debian/tmp/usr/lib/debian-test/tests/flip

# Must have debmake installed for this to work. Otherwise please copy
# /usr/bin/debstd into the debian directory and change debstd to debian/debstd
	debstd MESSAGE
	dpkg-gencontrol -isp
	chown -R root.root debian/tmp
	chmod -R go=rX debian/tmp
	dpkg --build debian/tmp ..

define checkdir
	test -f debian/rules
endef

# Below here is fairly generic really

binary:		binary-indep binary-arch

source diff:
	@echo >&2 'source and diff are obsolete - use dpkg-source -b'; false

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

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