#
# Copyright (C) 2007-2008 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# $Id: Makefile 14096 2009-01-18 17:02:40Z florian $

include $(TOPDIR)/rules.mk

PKG_NAME:=gotemp
PKG_VERSION:=1.0
PKG_RELEASE:=1


include $(INCLUDE_DIR)/package.mk

define Package/gotemp
  SECTION:=net
  CATEGORY:=Network
  TITLE:=gotemp
  URL:=http://../
  DEPENDS:=+libusb
endef

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

	$(CP) src/* $(PKG_BUILD_DIR)	

endef
EX_LIBS  = -L$(STAGING_DIR)/usr/lib -lusb
INCLUDES = -I$(STAGING_DIR)/usr/include -I$(LINUX_DIR)/include -I$(TOPDIR)/build_dir/linux-vsc75xx/linux-2.6.23.17/include -I$(TOPDIR)/build_dir/linux-vsc75xx/webif-webstax/sw_mgd_cgi

#TARGET_CFLAGS += $(INCLUDES) -g
TARGET_CFLAGS += $(INCLUDES)

define Build/Compile
#	$(call Build/Compile/Default)
	CC="$(TARGET_CC)" \
	CXX="$(TARGET_CXX)" \
	CFLAGS="$(TARGET_CFLAGS)     -Wall \
	-DLINUX " \
	CPPFLAGS="$(TARGET_CPPFLAGS)  " \
	CXXFLAGS="$(TARGET_CXXFLAGS)    -Wall -g\
	-DLINUX " \
	$(MAKE) -C $(PKG_BUILD_DIR) \
		DESTDIR="$(PKG_INSTALL_DIR)" \
		CFLAGS="$(TARGET_CFLAGS)" \
		EX_LIBS="$(EX_LIBS)" \

endef
define Package/gotemp/install
#	$(INSTALL_DIR) $(1)/etc/init.d
#	$(INSTALL_BIN) ./files/gotemp.init $(1)/etc/init.d/gotemp
	$(INSTALL_DIR) $(1)/usr/sbin
	$(CP) $(PKG_BUILD_DIR)/gotemp $(1)/usr/sbin/gotemp
	$(INSTALL_DIR) $(1)/lib
	$(INSTALL_DIR) $(1)/lib/modules/
	$(INSTALL_DIR) $(1)/lib/modules/2.6.23.17/
	$(CP) ./files/ldusb.ko $(1)/lib/modules/2.6.23.17/ldusb.ko
endef

$(eval $(call BuildPackage,gotemp))
