# 
# Copyright (C) 2006 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# $Id: Makefile 12228 2008-08-06 22:43:15Z nbd $

include $(TOPDIR)/rules.mk

PKG_NAME:=eet
PKG_VERSION:=
PKG_RELEASE:=1

PKG_SOURCE:=e17.libs.$(PKG_NAME)_anoncvs.enlightenment.org__20080825.tar.gz
PKG_SOURCE_URL:=http://downloads.openmoko.org/sources/
PKG_BUILD_DIR=$(BUILD_DIR)/Xorg/$(_CATEGORY)/${PKG_NAME}/

PKG_FIXUP = libtool

include $(INCLUDE_DIR)/package.mk

define Package/eet
  SECTION:=xorg-lib
  CATEGORY:=Xorg
  SUBMENU:=lib
  TITLE:=EET is a tiny library designed to write an arbitary set of chunks of data to a file
  URL:=http://wiki.enlightenment.org/index.php/Eet
  DEPENDS:=+libjpeg +zlib
endef

define Package/eet/description
  EET is a tiny library designed to write an arbitary set of chunks of data to a file and optionally compress each chunk (very much like a zip file) and allow fast random-access reading of the file later on. EET files are perfect for storing data that is written once (or rarely) and read many times, especially when the program does not want to have to read all the data in at once.
endef

define Build/Configure
	(cd $(PKG_BUILD_DIR); NOCONFIGURE=YES ./autogen.sh );
	$(call Build/Configure/Default, \
	)
endef

define Build/Compile
	mkdir -p $(PKG_INSTALL_DIR)/host $(PKG_INSTALL_DIR)/target
	$(MAKE) -C $(PKG_BUILD_DIR) all
	DESTDIR="$(PKG_INSTALL_DIR)/target" $(MAKE) -C $(PKG_BUILD_DIR) all install
	$(MAKE) -C $(PKG_BUILD_DIR) clean
	(cd $(PKG_BUILD_DIR); rm -f config.cache; \
		./configure \
			--prefix=/usr \
			--exec-prefix=/usr \
			--bindir=/usr/bin \
			--datadir=/usr/share \
			--includedir=/usr/include \
			--infodir=/usr/share/info \
			--libdir=/usr/lib \
			--libexecdir=/usr/lib \
			--localstatedir=/var \
			--mandir=/usr/share/man \
			--sbindir=/usr/sbin \
			--sysconfdir=/etc \
	);
	$(MAKE) -C $(PKG_BUILD_DIR) all CC="$(HOSTCC)" CFLAGS="" LDFLAGS="-I$(STAGING_DIR_HOST)/usr/lib/"
	DESTDIR="$(PKG_INSTALL_DIR)/host" $(MAKE) -C $(PKG_BUILD_DIR) all install
endef

define Build/InstallDev
	$(INSTALL_DIR) $(1)/usr/include $(1)/usr/lib $(1)/usr/bin $(STAGING_DIR_HOST)/usr/include $(STAGING_DIR_HOST)/usr/lib $(STAGING_DIR_HOST)/usr/bin
	$(CP) $(PKG_INSTALL_DIR)/target/usr/include/* $(1)/usr/include/
	$(CP) $(PKG_INSTALL_DIR)/target/usr/lib/* $(1)/usr/lib/
	$(CP) $(PKG_INSTALL_DIR)/target/usr/bin/* $(1)/usr/bin/
	$(CP) $(PKG_INSTALL_DIR)/host/usr/lib/* $(STAGING_DIR_HOST)/usr/lib/
	$(CP) $(PKG_INSTALL_DIR)/host/usr/bin/* $(STAGING_DIR_HOST)/usr/bin/
endef

define Package/eet/install
	$(INSTALL_DIR) $(1)/usr/lib $(1)/usr/bin $(STAGING_DIR_HOST)/usr/lib $(STAGING_DIR_HOST)/usr/bin
	$(CP) $(PKG_INSTALL_DIR)/target/usr/lib/*.so* $(1)/usr/lib/
	$(CP) $(PKG_INSTALL_DIR)/target/usr/bin/* $(1)/usr/bin/
	$(CP) $(PKG_INSTALL_DIR)/host/usr/lib/*.so* $(STAGING_DIR_HOST)/usr/lib/
	$(CP) $(PKG_INSTALL_DIR)/host/usr/bin/* $(STAGING_DIR_HOST)/usr/bin/
endef

$(eval $(call BuildPackage,eet))