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

include $(TOPDIR)/rules.mk

PKG_NAME:=luabind
PKG_VERSION:=0.9.1
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=@SF/luabind
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_MD5SUM:=8a323fb51d07dad5cfdb12c432793d55

include $(INCLUDE_DIR)/package.mk

define Package/libluabind
  SECTION:=libs
  CATEGORY:=Libraries
  TITLE:=This library helps you create bindings between C++ and Lua.
  DEPENDS:=+lua +boost
endef

define Package/libluabind/description
	Luabind is a library, inspired by and similar to Boost.Python, that helps you create bindings between C++ and Lua.
	It has the ability to expose functions and classes, written in C++, to Lua.
endef

define Build/Configure
endef

CONFIGURE_PREFIX:=$(PKG_INSTALL_DIR)
LUA_PATH:=$(STAGING_DIR)/usr
TARGET_CXXFLAGS+=-I$(STAGING_DIR)/usr/include
define Build/Compile
	( cd $(PKG_BUILD_DIR) ; \
	  	export LUA_PATH=$(LUA_PATH) ; \
		echo "using gcc : : : <cflags>$(TARGET_CFLAGS) <cxxflags>$(TARGET_CXXFLAGS) <linkflags>$(TARGET_LDFLAGS) ;" > user-config.jam ; \
		bjam \
			toolset=gcc \
			--user-config=user-config.jam \
			--prefix=$(PKG_INSTALL_DIR) \
			release \
			install \
	)
endef

define Build/InstallDev
	$(INSTALL_DIR) $(1)/usr/include/luabind/
	$(CP) $(PKG_INSTALL_DIR)/include/luabind/* $(1)/usr/include/luabind/
	$(INSTALL_DIR) $(1)/usr/lib
	$(CP) $(PKG_INSTALL_DIR)/lib/*.so* $(1)/usr/lib/
endef

define Package/libluabind/install
	$(INSTALL_DIR) $(1)/usr/lib
	$(CP) $(PKG_INSTALL_DIR)/lib/libluabind*.so* $(1)/usr/lib/
endef

$(eval $(call BuildPackage,libluabind))
