# 
# Copyright (C) 2006-2009 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:=commtouch
PKG_VERSION:=1.0.0
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz

include $(INCLUDE_DIR)/package.mk
  
define Package/comm-touch
  SECTION:=base
  CATEGORY:=Base system
  DEPENDS:=+libuci +jansson 
  TITLE:=commtouch
  DESCRIPTION:=commtouch
endef

define Build/Compile
	$(INSTALL_DIR) $(PKG_INSTALL_DIR)
	$(MAKE) -C $(PKG_BUILD_DIR) CC="$(TARGET_CC)" CFLAGS="-I$(STAGING_DIR)/usr/include" CLIBS="-L$(STAGING_DIR)/usr/lib -lnetfilter_queue -lnfnetlink -luci" DESTDIR="$(PKG_INSTALL_DIR)" install
endef

define Package/comm-touch/install
	$(INSTALL_DIR) $(1)/sbin
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/commtouch $(1)/sbin/
	$(INSTALL_DIR) $(1)/etc/config
	$(INSTALL_DATA) ./files/category_list.config $(1)/etc/config/category_list
	$(INSTALL_DATA) ./files/content_filter $(1)/etc/config/content_filter
	$(INSTALL_DIR) $(1)/etc/init.d
	#$(INSTALL_BIN) ./files/commtouch.init $(1)/etc/init.d/commtouch
	$(INSTALL_BIN) ./files/commtouch_server_resolver.init $(1)/etc/init.d/commtouch_server_resolver
endef

$(eval $(call BuildPackage,comm-touch))
