#! /usr/bin/make -f

SHELL = /bin/bash

PYVERS     := $(shell /usr/bin/python -c 'import sys; print sys.version[:3]')
VER     := $(shell /usr/bin/python -c 'import sys; print sys.version[:3]')
BIULD_DIR := WebKitBuild/Debug.master
build: build-stamp
build-stamp: $(PYVERS:%=build-python%)
	touch $@
build-python%:
	touch $@

clean:
	rm -rf *-stamp build-python* build
	rm -rf $(addprefix debian/,$(packages)) debian/files debian/substvars
	rm -rf _trial_temp test.log
	find . -name "*.pyc" |xargs -r rm
	dh_clean

install: build-stamp install-prereq $(PYVERS:%=install-python%) install-libs install-nover

install-prereq: build-stamp
	dh_testdir
	dh_testroot
	dh_clean -k

install-python%: install-prereq
	dh_install -ppython-webkitwx \
		$(BUILD_DIR)/webview.py \
		$(BUILD_DIR)/Debug.master/_webview.so \
			usr/lib/python$*/site-packages/wx-2.8-gtk2-unicode/wx/

install-nover:	install-prereq
	dh_install -pwebkitwx-headers \
		$(BUILD_DIR)/JavaScriptCore \
			usr/include/wxwebkit-1.0/

install-libs:	install-prereq
	dh_install
	

binary-indep:
	(cd Tools/Scripts && ./build-webkit --wx --makeargs="--wxpython")
	dh_testdir
	dh_testroot
	dh_installchangelogs -i
	dh_installdocs -i
	dh_strip -i
	dh_compress -i
	dh_fixperms -i
	dh_installdeb -i
	dh_gencontrol -i
	dh_md5sums -i
	dh_builddeb -i

binary-arch:
	dh_testdir
	dh_testroot
	echo $(shell pwd)
	echo $(shell ls -l)
	dh_installchangelogs -a
	dh_installdocs -a WebKit/wx/bindings/python/samples/simple.py
	dh_strip -a
	dh_compress -a -Xsimple.py
	dh_fixperms -a
	dh_pycentral -a
	dh_installdeb -a
	dh_shlibdeps -a
	dh_gencontrol -a
	dh_md5sums -a
	dh_builddeb -a

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install install-nover install-prereq install-libs