#!/usr/bin/make -f
-# Debian rules for YAZ
-# $Id: rules,v 1.1 2001-05-28 12:44:03 adam Exp $
+#
+# Script for building YAZ from source to .deb-packages.
#
-# 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
-
-package=yaz
-version=1.0.0
-
-build:
- $(checkdir)
- ./configure --prefix=/usr --enable-shared
- $(MAKE) CFLAGS=-O2
- cd doc; $(MAKE) CFLAGS=-O2
- touch build
+# Created by Morten Hendriksen <mgh@dbc.dk> based on sample
+# debhelper script from Joey Hess. GPL copyright 1997 to 1999 by Joey Hess.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+# This is the debhelper compatability version to use.
+export DH_COMPAT=2
+
+YAZ_WITH_SSL?=1
+CONFIG_FLAGS=--enable-static --enable-shared --enable-tcpd --prefix=/usr
+
+# Enable parallel builds if CONCURRENCY_LEVEL is set
+ifdef CONCURRENCY_LEVEL
+MCFLAGS=-j$(CONCURRENCY_LEVEL)
+else
+MCFLAGS=
+endif
+
+ifeq ($(YAZ_WITH_SSL),1)
+export BUILD_SSL=1
+SSL_FLAGS=--with-openssl
+else
+SSL_FLAGS=
+endif
+
+YAZ_VERSION=1.9.1
+YAZSRCDIR?=$(shell pwd)
+# If this is not IndexData's release, then it is a cvs-checkout. Go cheat!
+# YAZ_VERSION:=$(YAZ_VERSION)-$(shell date -r$(YAZSRCDIR)/CVS +"CVS%Y%m%d")
+export YAZ_VERSION
+
+# Local library path for linking with right dependencies
+LOCAL_LINK=-ldebian/yaz-runtime/usr/lib:debian/yaz-ssl/usr/lib
+
+$(YAZSRCDIR)/configure: $(YAZSRCDIR)/configure.in
+ cd $(YAZSRCDIR); sh buildconf.sh
+
+stamp-configure: $(YAZSRCDIR)/configure
+ dh_testdir
+
+ -rm -rf build
+ mkdir build
+ cd build; $(YAZSRCDIR)/configure $(CONFIG_FLAGS) $(SSL_FLAGS)
+ touch stamp-configure
+
+build: stamp-build
+stamp-build: stamp-configure
+ dh_testdir
+
+ # Add here commands to compile the package.
+ $(MAKE) -C build $(MCFLAGS)
+
+ touch stamp-build
clean:
- $(checkdir)
- rm -f build
- -$(MAKE) -i distclean
- rm -rf *~ debian/tmp debian/*~ debian/files* debian/substvars
-
-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
- install -d debian/tmp/DEBIAN\
- -d debian/tmp/usr/share/doc/$(package)
- install -m 755 debian/postinst debian/prerm debian/tmp/DEBIAN
- install -m 644 debian/shlibs debian/tmp/DEBIAN
- $(MAKE) prefix=`pwd`/debian/tmp/usr install
- install -m 644 doc/*.html debian/tmp/usr/share/doc/$(package)
- install -m 644 doc/*.ps debian/tmp/usr/share/doc/$(package)
- install -m 644 doc/*.txt debian/tmp/usr/share/doc/$(package)
- gzip debian/tmp/usr/share/doc/$(package)/*.ps
- gzip debian/tmp/usr/share/doc/$(package)/*.txt
- cp debian/copyright debian/tmp/usr/share/doc/$(package)/.
- cp debian/changelog debian/tmp/usr/share/doc/$(package)/changelog.Debian
- cp CHANGELOG debian/tmp/usr/share/doc/$(package)/changelog
- strip --strip-debug debian/tmp/usr/lib/*.a
- strip --strip-unneeded debian/tmp/usr/lib/lib*.so.$(version)
- dpkg-shlibdeps debian/tmp/usr/bin/yaz-client debian/tmp/usr/bin/yaz-ztest
- dpkg-gencontrol
- chown -R root.root debian/tmp
- chmod -R g-ws debian/tmp
- dpkg --build debian/tmp ..
-
-define checkdir
- test -f debian/rules
-endef
-
-# Below here is fairly generic really
-
-binary: binary-indep binary-arch
-
-checkroot:
- $(checkdir)
- test root = "`whoami`"
-
-.PHONY: binary binary-arch binary-indep clean checkroot
+ dh_testdir
+ #dh_testroot
+ -rm -f stamp-*
+ -rm -rf build
+
+ dh_clean
+ -rm -rf debian/yaz-runtime debian/yaz-ssl debian/yaz-devel \
+ debian/with-ssl debian/*.debhelper debian/substvars debian/shlibs.yaz-*
+
+install: stamp-install
+stamp-install: stamp-build
+ dh_testdir
+ dh_testroot
+ dh_clean -k -a
+ dh_installdirs -a
+
+ # Add here commands to install the package into debian/tmp.
+ -mkdirhier debian/tmp/usr
+ $(MAKE) -C build install prefix=`pwd`/debian/tmp/usr
+
+ touch stamp-install
+
+# Build architecture-independent files here.
+binary-indep: build install
+ dh_testdir
+ dh_testroot
+ dh_installdocs -p yaz-doc doc/*.html doc/*.pdf
+ dh_installchangelogs -p yaz-doc
+ dh_link -p yaz-doc
+ dh_strip -p yaz-doc
+ dh_compress -p yaz-doc
+ dh_fixperms -p yaz-doc
+ dh_gencontrol -p yaz-doc
+ dh_md5sums -p yaz-doc
+
+ dh_builddeb -p yaz-doc
+
+# Build architecture-dependent files here.
+binary-arch: build install
+ dh_testdir
+ dh_testroot
+ifeq ($(YAZ_WITH_SSL),1)
+ dh_movefiles -p yaz-ssl usr/bin/*ssl usr/lib/libyazssl*
+endif
+ dh_movefiles -p yaz-devel usr/share/aclocal usr/lib/*.a usr/lib/*.la usr/lib/*.so usr/include usr/bin/yaz-config usr/bin/yaz-comp
+ dh_movefiles -p yaz-runtime usr/lib usr/share/yaz usr/bin
+ dh_installexamples -p yaz-devel
+
+ cp LICENSE debian/copyright
+ cp CHANGELOG changelog
+ dh_installdocs --all README TODO changelog debian/copyright
+
+ dh_installchangelogs
+ dh_link
+ dh_strip
+ dh_compress -a
+ dh_fixperms -a
+
+ dh_installdeb -p yaz-runtime
+ dh_installdeb -p yaz-devel
+ dh_installman -p yaz-devel doc/yaz-config.1
+ dh_undocumented -p yaz-devel yaz-comp.1
+ dh_installman -p yaz-runtime doc/yaz-client.1 doc/yaz-ztest.8 doc/yaz.7 doc/zoomsh.1
+ echo "libyaz 1 yaz-runtime" > debian/yaz-runtime/DEBIAN/shlibs
+ echo "libyazthread 1 yaz-runtime" >> debian/yaz-runtime/DEBIAN/shlibs
+ echo "libyazmalloc 1 yaz-runtime" >> debian/yaz-runtime/DEBIAN/shlibs
+ chmod 644 debian/yaz-runtime/DEBIAN/shlibs
+ dh_shlibdeps -p yaz-runtime $(LOCAL_LINK)
+ifeq ($(YAZ_WITH_SSL),1)
+ dh_installdeb -p yaz-ssl
+ dh_installman -p yaz-ssl doc/yaz-client-ssl.1 doc/yaz-ztest-ssl.8
+ echo "libyazssl 1 yaz-ssl" >> debian/yaz-ssl/DEBIAN/shlibs
+ chmod 644 debian/yaz-ssl/DEBIAN/shlibs
+ dh_shlibdeps -p yaz-ssl $(LOCAL_LINK)
+ cat debian/postinst >> debian/yaz-ssl/DEBIAN/postinst
+endif
+ cat debian/postinst >> debian/yaz-runtime/DEBIAN/postinst
+
+ dh_gencontrol -p yaz-runtime
+ dh_md5sums -p yaz-runtime
+
+ dh_gencontrol -p yaz-devel
+ dh_md5sums -p yaz-devel
+
+ifeq ($(YAZ_WITH_SSL),1)
+ dh_gencontrol -p yaz-ssl
+ dh_md5sums -p yaz-ssl
+endif
+ # Go kill those CVS-dirs before build
+ -find debian/tmp -type d -name CVS | xargs rm -rf
+ # For some reason it is necessary to remove empty-dirs in yaz-doc
+ -rm -rf debian/tmp/usr/include debian/tmp/usr/share/aclocal debian/tmp/usr/lib debian/tmp/usr/bin \
+ debian/tmp/usr/share/yaz
+
+ dh_builddeb -p yaz-runtime
+ dh_builddeb -p yaz-devel
+ifeq ($(YAZ_WITH_SSL),1)
+ dh_builddeb -p yaz-ssl
+endif
+
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install install-stamp configure
+
+yazrelease:
+ # Conveniency target for building both SSL and non-ssl versions
+ dh_testdir
+ # Non-ssl version and source
+ dpkg-buildpackage $(EXTRA_OPTS) -rfakeroot
+ # SSL version
+ -YAZ_WITH_SSL=1 dpkg-buildpackage $(EXTRA_OPTS) -rfakeroot -B