#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
#export DH_VERBOSE=1
#export DH_OPTIONS=-v

#include /usr/share/cdbs/1/rules/debhelper.mk
#include /usr/share/cdbs/1/class/autotools.mk
#include /usr/share/cdbs/1/class/python-module.mk

%:
	dh $@ --with python2,systemd

override_dh_auto_configure:
	mv configure configure.dist && ./autogen.sh
	dh_auto_configure -- --enable-gnfs

override_dh_install:
	strip --remove-section=.comment --remove-section=.note --strip-unneeded \
		debian/tmp/usr/lib/*/glusterfs/*/xlator/debug/trace.so
	strip --remove-section=.comment --remove-section=.note --strip-unneeded \
		debian/tmp/usr/lib/*/glusterfs/*/xlator/debug/error-gen.so
	strip --remove-section=.comment --remove-section=.note --strip-unneeded \
		debian/tmp/usr/lib/*/glusterfs/*/xlator/debug/io-stats.so
	find debian/tmp/usr/lib -type f -name \*.la -exec sed 's/^dependency_libs/#dependency_libs/g' -i {} \;
	install -D -p -m 0644 extras/glusterfs-logrotate \
		debian/tmp/etc/logrotate.d/glusterfs
	install -D -p -m 0644 extras/glusterfs-georep-logrotate \
		debian/tmp/etc/logrotate.d/glusterfs-georep
	install -D -p -m 0644 extras/systemd/glusterd.service \
		debian/tmp/lib/systemd/system/glusterd.service
	sed -i s/sysconfig/default/ debian/tmp/lib/systemd/system/glusterd.service
	install -D -p -m 0644 extras/systemd/glustereventsd.service \
		debian/tmp/lib/systemd/system/glustereventsd.service
	install -D -p -m 0644 extras/systemd/glusterfssharedstorage.service \
		debian/tmp/lib/systemd/system/glusterfssharedstorage.service
	install -D -p -m 0755 extras/mount-shared-storage.sh \
		debian/tmp/usr/lib/x86_64-linux-gnu/glusterfs/mount-shared-storage.sh
	install -D -p -m 0644 extras/glusterd-sysconfig \
		debian/tmp/etc/default/glusterd
	dh_install

override_dh_builddeb:
	dh_builddeb -- -Zxz

override_dh_strip:
	dh_strip --dbg-package=glusterfs-dbg
