#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

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

DESTDIR = $(CURDIR)/debian/wxglade
VERSION = $(shell dpkg-parsechangelog --show-field Version | sed 's/-.*//')

%:
	dh $@ --with python3

override_dh_auto_clean:
	# the installation is simplified drastically!
	rm -f Makefile setup.py version.py
	rm -rf wxGlade.egg-info .eggs
	rm -f docs/html/_static/jquery.js docs/html/_static/underscore.js
	dh_auto_clean

override_dh_auto_test:
	echo "not running the tests since the test tests/test_gui.py will fail"

STATIC_SPHINX_DIR = $(DESTDIR)/usr/share/wxglade/docs/html/_static

override_dh_install:
	echo "__version__ = '$(VERSION)'" > $(CURDIR)/version.py
	dh_install
	# fix JS libraries
	rm -f $(STATIC_SPHINX_DIR)/jquery.js
	ln -s /usr/share/javascript/jquery/jquery.js \
	  $(STATIC_SPHINX_DIR)/
	rm -f $(STATIC_SPHINX_DIR)/underscore.js
	ln -s /usr/share/javascript/underscore/underscore.js \
	  $(STATIC_SPHINX_DIR)/
	rm -f $(STATIC_SPHINX_DIR)/doctools.js
	ln -s /usr/share/sphinx/themes/basic/static/doctools.js \
	  $(STATIC_SPHINX_DIR)/
	rm -f $(STATIC_SPHINX_DIR)/searchtools.js
	ln -s /usr/share/sphinx/themes/basic/static/searchtools.js \
	  $(STATIC_SPHINX_DIR)/

override_dh_fixperms:
	dh_fixperms
	rm -f $(DESTDIR)/usr/share/wxglade/LICENSE.txt
	ln -s ../doc/wxglade/copyright $(DESTDIR)/usr/share/wxglade/LICENSE.txt
	find $(DESTDIR)/usr/share/wxglade -type f | xargs chmod 644
