#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.

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

export GIT_COLA_NO_VENDOR_LIBS=1

package=git-cola
PKGDIR=$(CURDIR)/debian/$(package)
HTMLDIR=$(PKGDIR)/usr/share/doc/git-cola/html

override_dh_auto_test:

build: build-arch build-indep
build-arch: build-stamp
build-indep: build-stamp
build-stamp:
	dh_testdir
	PYTHON=python3 $(MAKE) all doc
	touch $@

clean:
	dh_testdir
	dh_testroot
	dh_clean build-stamp
	[ ! -f Makefile ] || $(MAKE) clean
	find . -name "*.pyc" -delete
	rm -f $(CURDIR)/share/doc/git-cola/_build/html/.buildinfo

install: build
	dh_testdir
	dh_testroot
	dh_install
	dh_installdirs
	PYTHON=python3 $(MAKE) DESTDIR=$(PKGDIR) prefix=/usr install install-doc install-html
#!/usr/bin/env python
	sed -i 's|env python|env python3|' \
		$(PKGDIR)/usr/share/git-cola/bin/git-xbase
	find . -name "*.pyc" -delete
	chmod a-x $(PKGDIR)/usr/share/git-cola/lib/cola/widgets/archive.py
#	chmod a-x $(PKGDIR)/usr/share/git-cola/lib/qtpy/py3compat.py
	mkdir $(PKGDIR)/usr/share/metainfo/
	mv $(PKGDIR)/usr/share/appdata/*.xml $(PKGDIR)/usr/share/metainfo/

# Build architecture-independent files here.
binary-indep: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs 
	rm -rf $(PKGDIR)/usr/share/doc/git-cola/changelog \
		$(PKGDIR)/usr/share/doc/git-cola/html/sources/
	dh_installdocs
	dh_installexamples
	dh_installman
	dh_python3
#	dh_link /usr/share/javascript/jquery/jquery.js \
#		/usr/share/doc/git-cola/html/_static/jquery.js
	rm $(PKGDIR)/usr/share/doc/git-cola/html/static/jquery.js
	dh_link /usr/share/javascript/jquery/jquery.js \
		/usr/share/doc/git-cola/html/static/jquery.js
	rm $(PKGDIR)/usr/share/doc/git-cola/html/static/underscore.js
	dh_link /usr/share/javascript/underscore/underscore.js \
		/usr/share/doc/git-cola/html/static/underscore.js
	sed -i "s|https://cdnjs.\+modernizr.min.js|/usr/share/javascript/modernizr/modernizr.min.js|" \
		$(HTMLDIR)/*.html
	dh_strip
	dh_compress -Xobjects.inv
	dh_fixperms
	dh_perl
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

# Build architecture-dependent files here.
binary-arch: build install

binary: binary-indep binary-arch

.PHONY: build clean binary-indep binary-arch binary install override_dh_auto_test
