#!/usr/bin/make -f
#export DH_VERBOSE=1

PACKAGE_NAME=python-simplejson
MODULE_NAME=simplejson

PYVERS=2.5

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
  CFLAGS += -O0
else
  CFLAGS += -O2
endif
export CFLAGS

clean: 
	dh_testdir
	dh_testroot
	rm -rf dist build build-stamp build-ext-*
#	find . -name '*\.py[co]' -delete
	dh_clean install-stamp install-ext-*

build: build-stamp
build-stamp: $(PYVERS:%=build-ext-%)
	touch $@
build-ext-%:
	dh_testdir
	python$* setup.py build
	touch $@

install: install-stamp
install-stamp: build-stamp $(PYVERS:%=install-ext-%)
	touch $@
	rm $(CURDIR)/debian/$(PACKAGE_NAME)/usr/lib/python2.5/site-packages/simplejson/*.py
install-ext-%:
	python$* setup.py install \
		--root $(CURDIR)/debian/$(PACKAGE_NAME) \
		--single-version-externally-managed
	touch $@

binary-indep:

binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs
	dh_installdocs
#	dh_link /usr/share/javascript/jquery/jquery.js \
#		/usr/share/doc/python-simplejson/docs/_static/jquery.js
	dh_strip
	dh_compress -X.py -X.json -X.js
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb -- -Z bzip2

binary: binary-indep binary-arch

.PHONY: clean binary-indep binary-arch binary unpatch
