# 
# 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:=DrayTek Applications
  TITLE:=commtouch
  PKG_BUILD_DEPENDS:=+libuci +libnetfilter-queue
endef

define Package/vdslcli/description
	commtouch for WCF
endef

#
# copy the source code to build folder
#
define Build/Prepare
	@echo "Preparing...................." 
	mkdir -p $(PKG_BUILD_DIR)/src $(PKG_BUILD_DIR)/files
	$(CP) src/* $(PKG_BUILD_DIR)/src
#	$(CP) files/* $(PKG_BUILD_DIR)/files
endef

define Build/Compile
	$(MAKE) -C $(PKG_BUILD_DIR)/src \
		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
	@echo "Install.................."
#	$(INSTALL_DIR) $(1)/sbin
#	$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/commtouch $(1)/sbin/
	$(INSTALL_DIR) $(1)/etc/config
	$(INSTALL_DATA) ./files/category_object.config $(1)/etc/config/category_object
	$(INSTALL_DATA) ./files/wcf $(1)/etc/config/wcf
#	$(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_DIR) $(1)/www
	$(INSTALL_DATA) ./files/wcf_block $(1)/www/wcf_block
	$(INSTALL_DATA) ./files/wcf_block_bpjm $(1)/www/wcf_block_bpjm
endef

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