#!/usr/bin/make -f

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

PYVERS := $(shell pyversions -s -v)

%:
	dh $@ --with python2

override_dh_auto_build:
	dh_auto_build
	NO_SETUPTOOLS=1 python setup.py -q build

override_dh_auto_test:
ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
	# use the default python version to select the script dir to run the tests
	-/bin/sh ./test/fulltest.sh $(PYVERS)
endif


override_dh_auto_install:
	NO_SETUPTOOLS=1 python setup.py -q install --no-compile \
			--root=$(CURDIR)/debian/pylint \
			--install-layout=deb

	rm -rf debian/pylint/usr/lib/python*/*-packages/pylint/test

	# fixes shebangs
	for exec in pylint pylint-gui symilar ; do \
	  if head -1 debian/pylint/usr/bin/$$exec | grep "^#! */usr/bin" | grep "python" >/dev/null ; then \
		sed -i "s@^#! */usr/bin/env \+python\$$@#!/usr/bin/python@" debian/pylint/usr/bin/$$exec; \
	  fi ; \
	  chmod a+x debian/pylint/usr/bin/$$exec; \
	done

	install -m 644 elisp/pylint.el debian/pylint/usr/share/emacs/site-lisp/pylint/

override_dh_installchangelogs:
	dh_installchangelogs -i ChangeLog

override_dh_compress:
	dh_compress -i -X.py -X.ini -X.xml -Xtest
