# 
# Copyright (C) 2010 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
#

include $(TOPDIR)/rules.mk

PKG_NAME:=stackless
PKG_VERSION:=2.6.5

PKG_SOURCE:=$(PKG_NAME)-265-export.tar.bz2
PKG_SOURCE_URL:=http://www.stackless.com/binaries/
PKG_MD5SUM:=9361b9e486b49104e3f3a4e4a4123943
PKG_BUILD_DIR:=python-2.6.5-stackless

include $(INCLUDE_DIR)/package.mk

define Package/stackless
  SECTION:=lang
  CATEGORY:=Languages
  TITLE:=stackless python
  URL:=http://www.stackless.com/
endef

define Package/stackless/description
   Stackless Python is an enhanced version of the Python programming language.
   It allows programmers to reap the benefits of thread-based programming without 
   the performance and complexity problems associated with conventional threads.
endef

CONFIGURE_ARGS += \
	--enable-static \
	--enable-shared

# If you wish to link against uclibc++ consider using the
# following variables :
CONFIGURE_VARS += \
	CXXFLAGS="$$$$CXXFLAGS -fno-builtin -fno-rtti -nostdinc++"  \
	CPPFLAGS="$$$$CPPFLAGS -I$(STAGING_DIR)/usr/include/uClibc++ -I$(LINUX_DIR)/include" \
	LDFLAGS="$$$$LDFLAGS" 
#	LIBS="-nodefaultlibs -luClibc++ -lm -lnotimpl" \

#MAKE_FLAGS += \
#	CFLAGS="$(TARGET_CFLAGS)"

define Build/Compile
	# pass CFLAGS again to override -O2 set by configure
	$(MAKE) -C $(PKG_BUILD_DIR) \
		CFLAGS="$(TARGET_CFLAGS)" \
		DESTDIR="$(PKG_INSTALL_DIR)" \
		all install
endef


define Build/InstallDev
	mkdir -p $(1)/usr/include/
	$(CP) $(PKG_BUILD_DIR)/usr/include/*.h $(1)/usr/include/
	mkdir -p $(1)/usr/package
	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libpython.{a,so*} $(1)/usr/lib/
endef

define Build/UninstallDev
	rm -rf	$(1)/usr/include/package \
		$(1)/usr/package/package.{a,so*}
endef

define Package/stackless/install
	$(INSTALL_DIR) $(1)/usr/lib
	$(CP) $(PKG_BUILD_DIR)/usr/lib/libpython.{a,so*}  $(1)/usr/lib/
	$(INSTALL_DIR) $(1)/usr/share/stackless
	$(CP) $(PKG_BUILD_DIR)/Lib/*.py $(1)/usr/share/stackless
#	$(INSTALL_DIR) $(1)/etc/config/
#	$(INSTALL_CONF) $(1)/etc/config/package
endef

$(eval $(call BuildPackage,stackless))
