LogoKolab Groupware OBS > Projects
Log In

View File debian.rules of Package cyrus-imapd (Project Kolab:3.4)

#!/usr/bin/make -f
# debian/rules for CMU Cyrus IMAP version 2.2
# GNU copyright 1997 by Joey Hess.
# Copyright (c) 2001 by Henrique de Moraes Holschuh
# Published under the GNU GPL license
# Based on previous work by Michael-John Turner <mj@debian.org>,
#			    David Parker <david@neongoat.com>
#

# DebHelper control
export DH_ALWAYS_EXCLUDE=CVS

export MAINPKG=cyrus-imapd
export TMPPKG := $(CURDIR)/debian/tmp
export PKGDIR := $(CURDIR)/debian/$(MAINPKG)

export DEB_HOST_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
export DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)

# Extra version information to add to Cyrus IMAPd ID
DEBVERSION:=$(shell LCALL=C dpkg-parsechangelog | sed -ne 's/^Version: \(.*-\)/\1/p')
EXTRA_IDENT:="Debian-$(DEBVERSION)"

# DB engine version
DBENGINE=BerkeleyDB4.7

DEBUGFLAGS=-g
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
	DEBUGFLAGS += -O0
else
	DEBUGFLAGS += -O2
endif

# TODO: Support parallel builds (make -j x)

# FOR AUTOCONF 2.52 AND NEWER ONLY
CONFFLAGS =
ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
  CONFFLAGS += --build $(DEB_HOST_GNU_TYPE)
else
  CONFFLAGS += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
endif

# Other oddities
ifneq (,$(findstring strict,$(DEB_BUILD_OPTIONS)))
	CONFFLAGS += --enable-warnings-are-errors
endif

clean:
	dh_testdir
	dh_testroot
	dh_clean

build: build-arch build-indep

configure-stamp: $(QUILT_STAMPFN)
	dh_testdir
	aclocal -I cmulocal
	libtoolize --install
	autoheader
	automake --add-missing || autoreconf -v && automake --add-missing
	autoreconf -v

	#
	# IF YOU CHANGE BERKELEY DB VERSION, MAKE SURE TO UPDATE
	# DBENGINE AT THE TOP OF THIS MAKEFILE!
	./configure CFLAGS="-fno-strict-aliasing -fPIC -Wall -pipe $(DEBUGFLAGS)" $(CONFFLAGS) \
		--enable-event-notification \
		--enable-idled \
		--enable-gssapi --with-gss_impl=heimdal \
		--enable-listext \
		--enable-murder \
		--enable-nntp \
		--enable-replication \
		--enable-xapian \
		--prefix=/usr \
		--exec-prefix=/usr \
		--libexecdir=/usr/sbin \
		--bindir=/usr/bin \
		--sbindir=/usr/sbin \
		--includedir=/usr/include \
		--datadir=/usr/share/cyrus \
		--sysconfdir=/etc \
		--sharedstatedir=/usr/share/cyrus \
		--localstatedir=/var/lib/imap \
		--mandir=/usr/share/man \
		--with-auth=pts \
		--with-com_err="" \
		--with-cyrus-prefix=/usr/lib/cyrus-imapd \
		--with-cyrus-group=mail \
		--with-cyrus-user=cyrus \
		--with-extraident=$(EXTRA_IDENT) \
		--with-ldap=/usr \
		--with-lock=fcntl \
		--with-perl=/usr/bin/perl \
		--with-openssl=/usr \
		--with-sasl=/usr \
		--with-pidfile=/var/run/cyrus-master.pid \
		--with-service-path=/usr/lib/cyrus-imapd \
		--with-syslogfacility=MAIL \
		--with-ucdsnmp=/usr
	if grep -q "WARNING: Disabling GSSAPI" config.log ; then \
		echo "ERROR: GSSAPI not found by configure" >&2 ;\
		exit 1 ;\
	fi
	echo 'To build this package, configure was called as follows:' \
		> debian/README.configure-options
	grep with\ options config.status \
	| sed -e 's/^.*options \\"/configure /;s/\\"$///' \
		>> debian/README.configure-options
	touch configure-stamp

build-arch: build-arch-stamp
build-arch-stamp: configure-stamp
	dh_testdir
	#
	PERL_MM_OPT="INSTALLDIRS=vendor" $(MAKE)
	# store database configuration for possible automatic
	# upgrading later
	echo "DBENGINE $(DBENGINE)" >>debian/cyrus-db-types.txt
	grep _db lib/imapoptions \
	| cut -d, -f1-2 | sed -e 's/{ "//;s/_db", "/ /;s/"$$//' \
	| sed -e 's/^tls.* /TLS /;s/^subs.* /SUBS /;s/^seen.* /SEEN /;s/^pts.* /PTS /;s/^mbox.* /MBOX /'\
	| awk '{printf("%s %s\n",toupper($$1),$$2);}' \
	>>debian/cyrus-db-types.txt
	mv debian/cyrus-db-types.txt debian/cyrus-db-types.txt.old \
	&& sort -u < debian/cyrus-db-types.txt.old > debian/cyrus-db-types.txt \
	&& rm debian/cyrus-db-types.txt.old
	#
	# store some useful state about the current package
	echo "PACKAGE_VERSION $(DEBVERSION)" >debian/cyrus-hardwired-config.txt
	if grep -q -s -n -E '^[[:space:]]*#define[[:space:]]+USE_DIR_FULL[[:space:]]+1' config.h ; then \
		echo "USE_DIR_FULL 1" >>debian/cyrus-hardwired-config.txt ;\
	else \
		echo "USE_DIR_FULL 0" >>debian/cyrus-hardwired-config.txt ;\
	fi
	touch build-arch-stamp

# We aren't actually able to build arch-indep independently from
# arch-dep, so we guarantee that the arch build has been done first
build-indep: build-indep-stamp
build-indep-stamp: configure-stamp build-arch-stamp
	dh_testdir
	cd doc && \
		pod2man ../perl/sieve/scripts/sieveshell.pl > ../man/sieveshell.1 && \
		fig2dev -L png murder.fig murder.png && \
		rm -f groff-html-*.png pod2htm*
	cd doc && \
		mkdir -p man && \
		for man in ../man/*.[1-9] ../debian/*.[1-9]; do \
			echo "Generating html manpage for $$man..."; \
			groff -man -Thtml $$man > man/`basename $$man`.html; \
		done
	pod2html perl/imap/cyradm.sh > doc/man/cyradm.1.html
	rm -f pod2htm*
	touch build-indep-stamp

install-arch: build-arch-stamp
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs -a
	$(MAKE) install DESTDIR=$(TMPPKG)
	mv $(TMPPKG)/usr/lib/cyrus-imapd/master $(TMPPKG)/usr/lib/cyrus-imapd/cyrus-master

	# Move the perl crap to a saner place
	mkdir -p $(TMPPKG)/usr/lib
	mkdir -p $(TMPPKG)/usr/share/perl5

	# Default configuration
	mkdir -p $(TMPPKG)/etc
	install -p -m 644 debian/imapd.conf $(TMPPKG)/etc
	install -p -m 644 debian/cyrus-imapd-2.4.x-imapd.annotations.conf \
		$(TMPPKG)/etc/imapd.annotations.conf
	install -m 644 master/conf/prefork.conf   $(TMPPKG)/etc/cyrus.conf

	# Correct paths used in cyrus.conf (https://issues.kolab.org/show_bug.cgi?id=3468)
	sed -i -e 's/\/var\/imap\//\/var\/lib\/imap\//g' $(TMPPKG)/etc/cyrus.conf

	# Avoid namespace turf wars
	mv $(TMPPKG)/usr/share/man/man8/master.8 $(TMPPKG)/usr/share/man/man8/cyrus-master.8
	mv $(TMPPKG)/usr/share/man/man8/deliver.8 $(TMPPKG)/usr/share/man/man8/cyr_deliver.8
	install -p -m 644 debian/cyrdump.8 $(TMPPKG)/usr/share/man/man8/cyrdump.8

	# And add our own manpages
	mkdir -p $(TMPPKG)/usr/share/man/man8
	install -p -m 644 debian/cyrus-makedirs.8 $(TMPPKG)/usr/share/man/man8/cyrus-makedirs.8
	install -p -m 644 debian/arbitronsort.8 $(TMPPKG)/usr/share/man/man8/arbitronsort.8

	# SNMP files
	mkdir -p $(TMPPKG)/usr/share/snmp/mibs
	install -m 644 master/CYRUS-MASTER.mib $(TMPPKG)/usr/share/snmp/mibs/CYRUS-MASTER-MIB.txt

	# Install cyradm icons
	mkdir -p $(TMPPKG)/usr/share/icons/mini
	install -p -m 644 debian/cyradm-32x32.xpm $(TMPPKG)/usr/share/icons/cyradm.xpm
	install -p -m 644 debian/cyradm-16x16.xpm $(TMPPKG)/usr/share/icons/mini/cyradm.xpm

	# Install debian-provided scripts
	mkdir -p $(TMPPKG)/usr/sbin
	install debian/cyrus-makedirs $(TMPPKG)/usr/sbin/cyrus-makedirs

	# and logcheck files
	mkdir -p \
		$(TMPPKG)/etc/logcheck/ignore.d.server/ \
		$(TMPPKG)/etc/logcheck/violations.ignore.d/
	install -p -m 644 debian/logcheck.ignore \
		$(TMPPKG)/etc/logcheck/ignore.d.server/logcheck-cyrus
	install -p -m 644 debian/logcheck.violations.ignore \
		$(TMPPKG)/etc/logcheck/violations.ignore.d/logcheck-cyrus

	# Install the stuff needed for upgrades
	mkdir $(TMPPKG)/usr/lib/cyrus-imapd/upgrade
	for i in convert-sieve.pl dohash rehash undohash translatesieve \
		upgradesieve masssievec; do \
		install -p -m 755 tools/$$i $(TMPPKG)/usr/lib/cyrus-imapd/upgrade ;\
	done
	# And other upgrade helpers
	install -p -m 644 debian/cyrus-db-types.txt debian/cyrus-hardwired-config.txt \
		   $(TMPPKG)/usr/lib/cyrus-imapd/
	# And other misc useful tools
	install -p -m 755 tools/arbitronsort.pl $(TMPPKG)/usr/sbin/arbitronsort
	# Lintian overrides
	cd debian ; \
	for i in *.lintian ; do \
		mkdir -p "$${i%%.lintian}/usr/share/lintian/overrides" ;\
		install -p -m 644 "$$i" "$${i%%.lintian}/usr/share/lintian/overrides/$${i%%.lintian}" ;\
	done
	dh_install -a --sourcedir=$(TMPPKG)
	touch install-arch-stamp

# We aren't actually able to install arch-indep independently from
# arch-dep, so we guarantee that the arch build has been done first
install-indep: build-indep-stamp install-arch
	dh_testdir
	dh_testroot
	#dh_clean -k
	dh_installdirs -i
	#
	# Massage the documentation into place
#	#mkdir -p $(DOCDIR)
	#find doc/text -name '[Ra-z]*' -type f -exec cp -f {} $(PKGDIR)/usr/share/doc/$(MAINPKG) \;
	#-(cd $(PKGDIR)/usr/share/doc/$(MAINPKG) && rm copyrights changes htmlstrip.c)
	#find $(PKGDIR)/usr/share/doc/$(MAINPKG) -type f ! -name '*txt' ! -name '*.*' -exec mv {} {}.txt \;
	#
	# Install the html docs and examples
#	mkdir -p $(DOCDIR)/html
#	install -m 644 doc/*.html doc/murder.png $(DOCDIR)/html
#	cp -a doc/man $(DOCDIR)/html
#	cp -a debian/examples $(DOCDIR)
#	install -m 644 doc/cyrusv2.mc $(DOCDIR)/examples
	#
	# Install contrib/ files
#	mkdir -p $(DOCDIR)/contrib
#	xargs < debian/cyrus-common.contrib -rti cp -r '{}' $(DOCDIR)/contrib
	#
	dh_install -i --sourcedir=$(TMPPKG)

binary-indep: install-indep
	dh_testdir -i
	dh_testroot -i
#	dh_installdebconf -i
	dh_installdocs -p cyrus-imapd
	dh_installexamples -p cyrus-imapd
	dh_installmenu -i
#	dh_installlogrotate -i
#	dh_installpam -i
#	dh_installmime -i
#	dh_installcron -i
	dh_installman -i
	dh_installchangelogs -p cyrus-imapd doc/changes.html
	#dh_installchangelogs -p cyrus-doc-2.2
	dh_strip -i
	dh_link -i
	dh_compress -i
	dh_fixperms -i
	dh_makeshlibs -i
	dh_installdeb -i
	dh_perl -i
	dh_shlibdeps -i
	dh_gencontrol -i
	dh_md5sums -i
	dh_builddeb -i

binary-arch: install-arch
	dh_testdir -a
	dh_testroot -a
	dh_installdebconf -a
	dh_installdocs -p $(MAINPKG)
	dh_installexamples -p $(MAINPKG)
	dh_installmenu -a
#	dh_installlogrotate -a
#	dh_installpam -a
#	dh_installmime -a
	dh_installinit -p $(MAINPKG) --noscripts --name=cyrus-imapd
	dh_installcron -a --name=cyrus-imapd
	dh_installman -a
#	dh_installinfo -a
	dh_installchangelogs -p $(MAINPKG) doc/changes.html perl/imap/Changes
	dh_fixperms -a
	dh_strip -a
	dh_link -a
	dh_compress -a
	dh_fixperms -a
	dh_makeshlibs -a
	dh_installdeb -a
	dh_perl -a
	dh_shlibdeps -a
	dh_gencontrol -a
	dh_md5sums -a
	dh_builddeb -a

binary: binary-indep binary-arch
.PHONY: build build-indep build-arch clean binary-indep binary-arch binary install-arch install-indep