#
# Copyright (C) 2008 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# $Id: Makefile 12821 2008-10-02 15:33:26Z lars $

include $(TOPDIR)/rules.mk

PKG_NAME:=pygobject
PKG_VERSION:=2.15.1
PKG_RELEASE:=2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=@GNOME/$(PKG_NAME)/2.15
PKG_MD5SUM:=05bf0487c885a1ef6df615e02cac5ea6

include $(INCLUDE_DIR)/package.mk
-include $(if $(DUMP),,$(STAGING_DIR)/mk/python-package.mk)

TARGET_LDFLAGS+=-I/home/lars/Projects/openwrt-olpc/staging_dir/i386/usr/include/python2.5

EXTRA_LDFLAGS+= \
	-L$(STAGING_DIR)/usr/lib/libintl/lib/ \
	-L$(STAGING_DIR)/usr/lib/libiconv/lib/

define Package/python-gobject
  SUBMENU:=Python
  SECTION:=lang
  CATEGORY:=Languages
  TITLE:=GLib bindings for python
  URL:=http://www.pygtk.org/
  DEPENDS:=python-core +glib2
endef

define Package/python-gobject/description
  GLib bindings for python
endef

define Build/Compile
	(cd $(PKG_BUILD_DIR)/gobject; \
	 $(HOSTCC) -I$(STAGING_DIR)/usr/lib/glib-2.0/include/ \
	           -I$(STAGING_DIR)/usr/include/glib-2.0/ \
			    generate-constants.c -o generate-constants);
	$(call Build/Compile/Default)
	$(call Build/Install/Default)
endef

define Build/InstallDev
	$(INSTALL_DIR) $(1)/usr/include/pygtk-2.0/
	$(INSTALL_DATA) \
		$(PKG_INSTALL_DIR)/usr/include/pygtk-2.0/* \
		$(1)/usr/include/pygtk-2.0/

	$(INSTALL_DIR) $(1)/usr/lib/pkgconfig/
	$(INSTALL_DATA) \
		$(PKG_INSTALL_DIR)/usr/lib/pkgconfig/* \
		$(1)/usr/lib/pkgconfig/

	$(SED) \
		"s,^\(prefix\|exec_prefix\|datadir\)=,\1=$(STAGING_DIR),g" \
		$(1)/usr/lib/pkgconfig/pygobject-2.0.pc

	$(INSTALL_DIR) $(1)/usr/share/pygobject/2.0/codegen
	$(INSTALL_DATA) \
		$(PKG_INSTALL_DIR)/usr/share/pygobject/2.0/codegen/*.py \
		$(1)/usr/share/pygobject/2.0/codegen

	$(INSTALL_DIR) $(1)/usr/share/pygobject/2.0/defs
	$(INSTALL_DATA) \
		$(PKG_INSTALL_DIR)/usr/share/pygobject/2.0/defs/* \
		$(1)/usr/share/pygobject/2.0/defs

	$(INSTALL_DIR) $(2)/bin
	$(INSTALL_BIN) \
		$(PKG_INSTALL_DIR)/usr/bin/* \
		$(2)/bin

	$(SED) \
		"s,^\(prefix\|datadir\)=,\1=$(STAGING_DIR),g" \
		$(2)/bin/pygobject-codegen-2.0
endef

define Package/python-gobject/install
	$(INSTALL_DIR) $(1)$(PYTHON_PKG_DIR)
	$(INSTALL_DATA) \
		$(PKG_INSTALL_DIR)$(PYTHON_PKG_DIR)/*.{pth,py} \
		$(1)$(PYTHON_PKG_DIR)/

	$(INSTALL_DIR) $(1)$(PYTHON_PKG_DIR)/gtk-2.0
	$(INSTALL_DATA) \
		$(PKG_INSTALL_DIR)$(PYTHON_PKG_DIR)/gtk-2.0/*.py \
		$(1)$(PYTHON_PKG_DIR)/gtk-2.0/

	$(foreach d,gobject gio, \
		$(INSTALL_DIR) $(1)$(PYTHON_PKG_DIR)/gtk-2.0/$(d); \
		$(INSTALL_DATA) \
			$(PKG_INSTALL_DIR)$(PYTHON_PKG_DIR)/gtk-2.0/$(d)/*.{py,so} \
			$(1)$(PYTHON_PKG_DIR)/gtk-2.0/$(d); \
	)
endef

$(eval $(call BuildPackage,python-gobject))
