File debian.rules of Package kopano

#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
#
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.
#
# Modified to make a template file for a multi-binary package with separated
# build-arch and build-indep targets  by Bill Allombert 2001

# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1

# This has to be exported to make some magic below work.
export DH_OPTIONS

# These are used for cross-compiling and for saving the configure script
# from having to guess our platform (since we know it already)
DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)

INSTDIR=$(CURDIR)/debian/tmp
SMARTYVER=2.6.14

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
	CONFFLAG = ""
else
	CONFFLAG = "--enable-release"
endif

tversion := $(shell tar --version | head -1 | cut -f4 -d\ | head -c 4)
ifeq "$(tversion)" "1.14"
tstrip := --strip-path
else
tstrip := --strip-components
endif

configure: config.status

config.status:
	dh_testdir
	./bootstrap.sh
	mkdir -p py2 && cd py2 && \
	../configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) \
		--prefix=/usr --localstatedir=/var \
		--sysconfdir=/etc --mandir=\$${prefix}/share/man \
		--infodir=\$${prefix}/share/info \
		--with-systemunitdir=/lib/systemd/system \
		--with-userscript-prefix=/etc/kopano/userscripts \
		--with-quotatemplate-prefix=/etc/kopano/quotamail \
		TCMALLOC_CFLAGS=" " TCMALLOC_LIBS="-ltcmalloc_minimal" \
		PYTHON="$$(which python2)" PYTHON_CFLAGS="$$(pkg-config python2 --cflags)" PYTHON_LIBS="$$(pkg-config python2 --libs)" \
		$(CONFFLAG) --enable-release
	mkdir -p py3 && cd py3 && \
	../configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) \
		--prefix=/usr --localstatedir=/var \
		--sysconfdir=/etc --mandir=\$${prefix}/share/man \
		--infodir=\$${prefix}/share/info \
		--with-systemunitdir=/lib/systemd/system \
		--with-userscript-prefix=/etc/kopano/userscripts \
		--with-quotatemplate-prefix=/etc/kopano/quotamail \
		TCMALLOC_CFLAGS=" " \
		TCMALLOC_LIBS="-ltcmalloc_minimal" --enable-epoll \
		PYTHON="$$(which python3)" PYTHON_CFLAGS="$$(pkg-config python3 --cflags)" PYTHON_LIBS="$$(pkg-config python3 --libs)" \
		$(CONFFLAG) --enable-release

# first entry point of dpkg-buildpackage
clean:
	dh_testdir
	dh_testroot
	rm -f build-arch-stamp build-indep-stamp #CONFIGURE-STAMP#
	# Add here commands to clean up after the build process.
	-$(MAKE) -C py2 distclean
	-$(MAKE) -C py3 distclean
	dh_clean

# second entry point of dpkg-buildpackage
build: build-arch build-indep

build-arch: build-arch-stamp
build-arch-stamp:  config.status
	# Add here commands to compile the arch part of the package.
	# compile kopano
	$(MAKE) -C py2 -j4 V=1
	$(MAKE) -C py3 -j4 V=1
	cat py2/common/include/kopano/ecversion.h
	touch build-arch-stamp

build-indep: build-indep-stamp
build-indep-stamp:  config.status
	# Add here commands to compile the indep part of the package.
	touch build-indep-stamp


# no install entry point

install-indep:
	dh_testdir
	dh_testroot
	dh_clean -k -i

	# Add here commands to install the indep part of the package into
	# debian/<package>-doc.
	#INSTALLDOC#
	# because of the dh_clean and kopano-archiver-extra being arch independant, we need to install these files again
	$(MAKE) DESTDIR=$(INSTDIR) install -C py2/swig/python/kopano
	$(MAKE) DESTDIR=$(INSTDIR) install -C py2/swig/python/zarafa
	$(MAKE) DESTDIR=$(INSTDIR) install -C py2/po
	$(MAKE) DESTDIR=$(INSTDIR) install-man1 -C py2
	$(MAKE) DESTDIR=$(INSTDIR) install-man8 -C py2
	# and remove non za-sync files
	rm -f $(INSTDIR)/usr/share/man/man1/kopano*

install-arch:
	dh_testdir
	dh_testroot
	dh_clean -k -s

	# Add here commands to install the arch part of the package into
	# debian/tmp.
	$(MAKE) -C py2 DESTDIR=$(INSTDIR) install PHP_SYSCONF_DIR=/usr/share/kopano/php/mapi
	$(MAKE) -C py3 DESTDIR=$(INSTDIR)3 install PHP_SYSCONF_DIR=/usr/share/kopano/php/mapi
	(cd debian/; for i in *.init; do install -Dpm0755 "$$i" "${INSTDIR}/etc/init.d/$${i%.init}"; done)
	mkdir -p ${INSTDIR}/var/lib/kopano/autorespond
	cp -av ${INSTDIR}/usr/share/doc/kopano/example-config/*.cfg ${INSTDIR}/etc/kopano/
	rm -fv ${INSTDIR}/etc/kopano/ldap.cfg

	# since this is not linked to an initscript anymore, install the file ourselves.
	mkdir -p $(INSTDIR)/etc/default
	install -o root -g root -m 644 installer/linux/sysconfig.txt ${INSTDIR}/etc/default/kopano

	# link userscripts in /usr/share/kopano/userscripts
	mkdir -p $(INSTDIR)/usr/share/kopano/userscripts
	for file in `find $(INSTDIR)/etc/kopano/userscripts -maxdepth 1 -type f`; do \
		mv -v $$file $(INSTDIR)/usr/share/kopano/userscripts; \
		ln -sfv /usr/share/kopano/userscripts/`basename $$file` $$file; \
	done

# move example-config files
	for package in spooler gateway monitor dagent ical search archiver; do \
		mkdir -p $(INSTDIR)/usr/share/doc/kopano-$$package/example-config; \
		mv -v $(INSTDIR)/usr/share/doc/kopano/example-config/$$package.cfg $(INSTDIR)/usr/share/doc/kopano-$$package/example-config; \
	done
	mv -v $(INSTDIR)/usr/share/doc/kopano/example-config/autorespond $(INSTDIR)/usr/share/doc/kopano-dagent/example-config
	mkdir -p $(INSTDIR)/usr/share/doc/kopano-multiserver/example-config

	# generate openssl link
	CADIR="$(INSTDIR)/etc/kopano/report-ca"; \
	if [ -d "$$CADIR" ]; then for c in $$CADIR/*; do \
		ln -sfv `basename $$c` $$CADIR/`openssl x509 -in $$c -noout -hash`.0; \
	done; fi

	# remove compiled python files
	find $(INSTDIR) -name \*.pyc -delete

	# php version
	if [ -x /usr/bin/php-config ]; then \
		PHP_MAPI="php$(shell php-config --version | cut -c 1)-mapi"; \
		sed -i s/php-mapi/$$PHP_MAPI/g debian/control; \
		echo php:Depends=phpapi-$(shell php-config --phpapi) > debian/$$PHP_MAPI.substvars; \
	elif [ -x /usr/bin/php-config5 ]; then \
		sed -i s/php-mapi/php5-mapi/g debian/control; \
		echo php:Depends=phpapi-$(shell php-config5 --phpapi) > debian/php5-mapi.substvars; \
	fi
	mkdir -p ${INSTDIR}/usr/share/doc/kopano-common
	gzip -c <RELNOTES.txt >${INSTDIR}/usr/share/doc/kopano-common/changelog.gz

# Build architecture independant packages using the common target.
binary-indep: install-indep
	dh_testdir -i
	dh_testroot -i
	dh_installdirs -i
	dh_install -Npython3-kopano -i --sourcedir=debian/tmp
	dh_install -ppython3-kopano --remaining-packages -i --sourcedir=debian/tmp3
	dh_installchangelogs -i
	dh_installdocs -i
	dh_compress -i
	dh_fixperms
	dh_python2 -ppython-kopano -i --no-guessing-versions
	dh_python3 -ppython3-kopano -i
	dh_installdeb -i
	dh_gencontrol -i
	dh_md5sums -i
	dh_builddeb -i

# Build architecture dependant packages using the common target.
binary-arch-real: install-arch
	dh_testdir
	dh_testroot
	# install empty paths not present in 'make install' from <packagename>.dirs file, in actual package directory, not in tmp.
	dh_installdirs
	dh_install -Npython3-mapi --sourcedir=debian/tmp
	dh_install -ppython3-mapi --remaining-packages --sourcedir=debian/tmp3
	dh_installchangelogs
	dh_installdocs
	dh_installinit -R --name kopano-dagent
	dh_installinit -R --name kopano-gateway
	dh_installinit -R --name kopano-ical
	dh_installinit -R --name kopano-monitor
	dh_installinit -R --name kopano-presence
	dh_installinit -R --name kopano-search
	dh_installinit -R --name kopano-server
	dh_installinit -R --name kopano-spooler
	dh_link
	dh_strip --dbg-package=kopano-dbg
	dh_compress -X.py -X.pl -Xusr/share/doc/kopano/kopano7-upgrade
	dh_fixperms
	dh_python2 -ppython-mapi --no-guessing-versions
	dh_python3 -ppython3-mapi
	dh_makeshlibs
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

# last entry point of dpkg-buildpackage
# but the ubuntu buildsystem may call 'binary-arch' insteadof 'binary' target as entry point
binary-arch: binary
binary:
	# make sure these do not run concurrent
	$(MAKE) -f debian/rules DH_OPTIONS=-a binary-arch-real
	$(MAKE) -f debian/rules DH_OPTIONS=-i binary-indep

.PHONY: build clean binary-indep binary-arch binary install install-indep install-arch
openSUSE Build Service is sponsored by