File debian.rules of Package 389-admin

#!/usr/bin/make -f
# -*- makefile -*-

DEB_HOST_ARCH_BITS ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_BITS)
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

ifeq (64,$(DEB_HOST_ARCH_BITS))
	export USE_64=1
else
	# fixes build on i386
	CPPFLAGS=-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
endif

# Deterministic "build number". Format is defined in ./buildnum.pl
BUILD_DATE := $(shell dpkg-parsechangelog --show-field Date)
BUILDNUM := $(shell date --utc --date="$(BUILD_DATE)" +%Y.%j.%H%M)

override_dh_auto_configure:
	dh_auto_configure -- \
		--disable-rpath \
		--with-openldap \
		--with-httpd=/usr/sbin/apache2 \
		--with-apxs=/usr/bin/apxs2

override_dh_auto_build:
	dh_auto_build -- BUILDNUM=$(BUILDNUM)

override_dh_auto_install:
	dh_auto_install --destdir=$(CURDIR)/debian/tmp

override_dh_install:
	# purge .la files
	find $(CURDIR)/debian/tmp -name "*.la" -type f -exec rm -f "{}" \;
	# and others
	rm -f $(CURDIR)/debian/tmp/usr/lib/*/*.so
	rm -f $(CURDIR)/debian/tmp/etc/rc.d/init.d/dirsrv-admin

	# rename the binaries & manpages, don't need wrappers
	rename 's,.pl$$,,' $(CURDIR)/debian/tmp/usr/sbin/*.pl
	rename 's,.pl,,' $(CURDIR)/debian/tmp/usr/share/man/man8/*.pl.8

	chmod -x $(CURDIR)/debian/tmp/etc/default/* \
		$(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/dirsrv/perl/*
	dh_install --fail-missing

override_dh_systemd_enable:
	dh_systemd_enable -p389-admin --no-enable --name=dirsrv-admin dirsrv-admin.service

override_dh_installinit:
	dh_installinit --name dirsrv-admin --error-handler=invoke_failure -- defaults 15 85

override_dh_shlibdeps:
	dh_shlibdeps -l"debian/389-admin/usr/lib/$(DEB_HOST_MULTIARCH)/:debian/389-admin/usr/lib/$(DEB_HOST_MULTIARCH)/dirsrv"

%:
	dh $@ --with quilt,autoreconf,systemd --parallel --builddir build/