#!/usr/bin/make -f
# -*- mode: makefile; coding: utf-8 -*-
# Copyright © 2008-2010 Jonas Smedegaard <dr@jones.dk>
# Description: Main Debian packaging script for hulahop
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
# 02111-1307 USA.

DEB_BUILDDIR = build
DEB_PYTHON_SYSTEM = pycentral
include /usr/share/cdbs/1/rules/upstream-tarball.mk
include /usr/share/cdbs/1/rules/utils.mk
include /usr/share/cdbs/1/class/python-autotools.mk
include /usr/share/cdbs/1/rules/debhelper.mk

DEB_UPSTREAM_PACKAGE = hulahop
DEB_UPSTREAM_URL = http://download.sugarlabs.org/sources/sucrose/glucose/$(DEB_UPSTREAM_PACKAGE)
DEB_UPSTREAM_TARBALL_EXTENSION = tar.bz2
DEB_UPSTREAM_TARBALL_MD5 = e616e18c86dc3286a00550fa09e687eb

pkg = python-hulahop

# Needed to locate xulrunner
LDFLAGS += -L/usr/lib/xulrunner-1.9

# Woraround for type punning causing "size of array 'arg' is negative"
CXXFLAGS += -fno-strict-aliasing

# Minimum usable version of xulrunner
python-xpcom-minver = 1.9~rc2

# apparently needs current version of python-xpcom at runtime
#  (dh_xulrunner does not work here as of 1.9.1.3-3)
python-xpcom-curver := $(shell dpkg -s python-xpcom | perl -ne 's/-[^-]*$$//; s/^Version:\W+// and print and exit')

# Set Debian as vendor in prefs.js and install as conffile
install/$(pkg)::
	mkdir -p debian/$(cdbs_curpkg)/etc/hulahop
	perl -pe 's/(general\.useragent\.vendorComment", ")[^"]*/$$1Debian\/$(DEB_NOEPOCH_VERSION)/' \
		< debian/$(cdbs_curpkg)/usr/share/hulahop/prefs.js \
		> debian/$(cdbs_curpkg)/etc/hulahop/prefs.js
	rm debian/$(cdbs_curpkg)/usr/share/hulahop/prefs.js
	ln -s /etc/hulahop/prefs.js debian/$(cdbs_curpkg)/usr/share/hulahop/prefs.js

# Needed by upstream build process
CDBS_BUILD_DEPENDS += , python-xpcom (>= $(python-xpcom-minver)), xulrunner-dev (>= $(python-xpcom-minver)), python-gtk2-dev

# Needed (always/seldom) at runtime
CDBS_DEPENDS = python-xpcom (>= $(python-xpcom-curver)), python-gtk2, python-gobject
CDBS_SUGGESTS = sugar-web-activity
