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

#export DH_VERBOSE=1
export DEB_BUILD_MAINT_OPTIONS = hardening=+all,-pie
# since this package produces shared library, not executable -
# -fPIE, -pie compiler/linker options are turned off.

export PYMOL_PATH=$(CURDIR)
PACKAGE = pymol
PYTHON_VERSION := $(shell pyversions -dv)

export PYBUILD_NAME = pymol
# this is incorrect but can be fixed after more urgent problems (#897431)
export PYBUILD_DESTDIR_python2=debian/pymol/

%:
	dh $@ --with python2 --buildsystem pybuild

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	chmod +x test/pymol-test
	(cd test && python run)
endif

override_dh_clean:
	$(RM) -r build test/tmp test/cmp generated
	dh_clean debian/pymol.launch debian/pymol-ref-card.* \
	         Rules.make create_shadertext.pyc

override_dh_install: debian/pymol-ref-card.pdf debian/pymol.launch
	dh_numpy
	dh_install
	install -m 755 debian/pymol.launch debian/pymol/usr/bin/pymol

override_dh_compress:
	dh_compress -Xpdb

debian/pymol-ref-card.pdf: debian/pymolRef.tex
	pdflatex -output-directory $(@D) -jobname pymol-ref-card $<

debian/pymol.launch: debian/pymol.launch.in
	sed -e s/@PYTHON_VERSION@/$(PYTHON_VERSION)/g < $< > $@
