#!/usr/bin/make -f
# debian/rules file - for GNU DBM (1.8.3).
# Based on sample debian/rules file - for GNU Hello (1.3).
# Copyright 1994,1995 by Ian Jackson.
# Copyright 1998-2003 by James Troup.
# 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

#export DH_VERBOSE = 1

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/rules/simple-patchsys.mk
include /usr/share/cdbs/1/class/autotools.mk

DEB_CONFIGURE_EXTRA_FLAGS = --prefix=/usr

SHLIB_VERSION=0.3.0
DEB_DH_MAKESHLIBS_ARGS_libgdbm3 := -V"libgdbm3 (>= $(SHLIB_VERSION))"

configure/libgdbm3::
	echo "/* We use fcntl locking (POSIX) instead of flock (BSD) */" >> autoconf.h
	echo "#undef HAVE_FLOCK" >> autoconf.h

install/libgdbm-dev::
	# libc6 owns ndbm.h, but some apps want gdbm's
	mv debian/tmp/usr/include/src/dbm.h debian/tmp/usr/include
	mv debian/tmp/usr/include/src/ndbm.h debian/tmp/usr/include/gdbm-ndbm.h
	rm -rf debian/tmp/usr/include/src
	rm -f debian/tmp/usr/include/gdbm.h
	cp src/gdbm.proto debian/tmp/usr/include/gdbm.h
	chmod +w debian/tmp/usr/include/gdbm.h
	grep _ src/gdbmerrno.h >> debian/tmp/usr/include/gdbm.h
	cat src/gdbm.proto2 >> debian/tmp/usr/include/gdbm.h
	chmod -w debian/tmp/usr/include/gdbm.h

	mv debian/tmp/usr/share/man/man3/gdbm.3 debian/tmp/usr/share/man/man3/gdbm.3gdbm
	cd debian/tmp/usr/share/man/man3 ; \
	    for i in dbm gdbm_error gdbm_errno gdbm_open \
		    gdbm_close gdbm_store gdbm_fetch gdbm_delete \
		    gdbm_firstkey gdbm_nextkey gdbm_reorganize \
		    gdbm_sync gdbm_exists gdbm_strerror \
		    gdbm_setopt dbminit store fetch delete \
		    firstkey nextkey dbmclose dbm_open \
		    dbm_close dbm_fetch dbm_store dbm_delete \
		    dbm_firstkey dbm_nextkey dbm_error \
		    dbm_clearerr dbm_pagfno dbm_dirfno \
		    dbm_rdonly; do \
		ln -s gdbm.3gdbm.gz $$i.3gdbm.gz ; \
	    done
