#!/usr/bin/make -f

# Unset the environment variables set by dpkg-buildpackage. (This is
# necessary because distutils is brittle with compiler/linker flags
# set. Specifically, packages using f2py will break without this.)
unexport CPPFLAGS
unexport CFLAGS
unexport CXXFLAGS
unexport FFLAGS
unexport LDFLAGS

PYVER = $(shell pyversions -r)

%:
	dh $@ --with python2

override_dh_auto_clean:
	dh_auto_clean
	rm -rf build

override_dh_auto_install:
	python setup.py install --root=debian/ranger --install-layout=deb
	# link configuration
	dh_link \
		./usr/lib/$(PYVER)/dist-packages/ranger/config/commands.py    ./etc/ranger/config/commands.py \
		./usr/lib/$(PYVER)/dist-packages/ranger/config/rc.conf        ./etc/ranger/config/rc.conf     \
		./usr/lib/$(PYVER)/dist-packages/ranger/config/rifle.conf     ./etc/ranger/config/rifle.conf  \
		./usr/lib/$(PYVER)/dist-packages/ranger/data/scope.sh         ./etc/ranger/data/scope.sh      \
		./usr/lib/$(PYVER)/dist-packages/ranger/data/mime.types       ./etc/ranger/data/mime.types
	# avoid extra-license-file
	rm debian/ranger/usr/share/doc/ranger/CHANGELOG
	# tell lintian to not complain
	find debian/ranger -regex ".*/data/scope.sh" -exec chmod u+x {} \;

override_dh_auto_build:
