#! /usr/bin/make -f

############################ -*- Mode: Makefile -*- ###########################
## rules ---
## Author           : Robert D. Hilliard <hilliard@debian.org>
## Created On       : Thu, 23 Apr 1998 17:54:36 -0400
## Last Modified By : Robert D. Hilliard <hilliard@debian.org>
## Last Modified On : Wed,  5 Apr 2000 18:58:55 -0400
## Update Count     : 
## Status           : $Id: rules,v 1.3 2000/04/05 22:59:17 bob Exp bob $
## HISTORY          :
## Description      : debian/rules for dict-jargon
## Acknowledgment   : This debian/rules file is based on the rules file for 
##		    : dict-misc, which is based on Manoj Srivasta's 
##                  : <srivasta@debian.org> sample debian/rules files,
##                  : but any errors belong to me.
###############################################################################

# The name of the package (for example, `emacs').
pkg   := dict-jargon

# Configuration variables (these should be pretty generic)
CC = cc
CFLAGS=  -O2 
LDFLAGS = -s
PREFIX = /usr
BINDIR = $(PREFIX)/bin
MANDIR = $(PREFIX)/man
MAN1DIR = $(MANDIR)/man1
DOCDIR = $(PREFIX)/share/doc/$(pkg)
DICTDIR= /usr/share/dictd

#  Package specific stuff.  The idea is to try to make the rules
#  generic (gradually).

FILES_TO_CLEAN  = debian/files 
DIRS_TO_CLEAN   = debian/tmp
STAMPS_TO_CLEAN = stamp-configure stamp-build stamp-binary-indep



install_file= install -p -o root -g root -m 644
install_program= install -p -o root -g root -m 755
make_directory= install -d -o root -g root -m 755

all build: stamp-build
# Builds the binary package.

configure: stamp-configure

stamp-configure:
	./configure --verbose --prefix=$(PREFIX) && touch stamp-configure


stamp-build:
# Builds the binary package.
	$(checkdir)
	-test -f stamp-configure || $(MAKE) -f debian/rules configure
	$(MAKE) CC="$(CC)" LDFLAGS="$(LDFLAGS)"
	$(MAKE) db
	touch stamp-build

clean:
# Undoes the effect of `$(MAKE) -f debian/rules build'.
	$(checkdir)
	-test -f Makefile && $(MAKE) distclean       
	-rm -f  $(FILES_TO_CLEAN) $(STAMPS_TO_CLEAN)
	-rm -rf $(DIRS_TO_CLEAN)
	-rm -f core `find . \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
                -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
                -o -name '.*.rej' -o -name '.SUMS' -o -size 0 \) -print` TAGS

binary: binary-indep binary-arch

binary-indep: build stamp-binary-indep


binary-arch: build stamp-binary-indep

stamp-binary-indep:
# Makes a binary package.
	@test root = "`whoami`" || (echo need root priviledges; exit 1)
	$(checkdir)
	test -f stamp-build  || $(MAKE) -f debian/rules build
	rm -rf               debian/tmp-* debian/tmp.deb
	$(make_directory)    debian/tmp
	$(make_directory)    debian/tmp/DEBIAN
	$(make_directory)    debian/tmp/usr
	$(make_directory)    debian/tmp/usr/share
	$(make_directory)    debian/tmp/usr/share/dictd
	$(make_directory)    debian/tmp/usr/share/doc
	$(make_directory)    debian/tmp/usr/share/doc/$(pkg)
	$(MAKE)              install.jargon dictdir=debian/tmp$(DICTDIR)
	$(install_file)      ChangeLog \
			       debian/tmp/usr/share/doc/$(pkg)/changelog
	$(install_file)      debian/changelog \
			       debian/tmp/usr/share/doc/$(pkg)/changelog.Debian
	$(install_file)      debian/README.debian\
			       debian/tmp/usr/share/doc/$(pkg)/README.debian
	gzip -9frq           debian/tmp/usr/share/doc/$(pkg)/
	$(install_program)    debian/postinst debian/tmp/DEBIAN/postinst
	$(install_program)    debian/postrm debian/tmp/DEBIAN/postrm
	$(install_program)    debian/prerm debian/tmp/DEBIAN/prerm
# Make sure the copyright file is not compressed
	$(install_file)      debian/copyright \
	                     debian/tmp/usr/share/doc/$(pkg)/copyright
	dpkg-gencontrol      -isp -p$(pkg) -Pdebian/tmp
	chown -R root.root   debian/tmp
	dpkg --build         debian/tmp ..


	touch                stamp-binary-indep


checkroot:
	@test root = "`whoami`" || (echo need root priviledges; exit 1)

define checkdir
	test -f  dictfmt.c -a -f debian/rules
endef

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


.PHONY: binary binary-arch binary-indep clean


