#!/usr/bin/make -f

export DEB_BUILD_HARDENING=1

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

install/glusterfs-common::
	for f in debian/tmp/usr/lib/glusterfs/*/xlator/debug/trace.so; do \
		debug_path=`echo "$$f" | sed -e 's|debian/tmp|debian/glusterfs-dbg/usr/lib/debug|'`; \
		install -d "`dirname $$debug_path`"; \
		objcopy --only-keep-debug "$$f" "$$debug_path"; \
	done
	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.0.0.0
	strip --remove-section=.comment debian/tmp/usr/lib/glusterfs/*/xlator/debug/io-stats.so.0.0.0
	find debian/tmp/usr/lib -type f -name \*.la -exec sed 's/^dependency_libs/#dependency_libs/g' -i {} \;
	find debian/tmp/usr/lib -type f -name \*.so.0.0.0 -exec chrpath -d -k {} \;
	chrpath -d -k debian/tmp/usr/sbin/glusterfsd
	chrpath -d -k debian/tmp/usr/sbin/gluster
	rm -f debian/tmp/usr/lib/glusterfs/glusterfs/python/syncdaemon/*.pyc
	rm -f debian/tmp/usr/lib/glusterfs/glusterfs/python/syncdaemon/*.pyo

clean::
	dh $@

get-orig-source::
	uscan --force-download --verbose
