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

include $(TOPDIR)/rules.mk

PKG_NAME:=wide-dhcpv6
PKG_VERSION:=20080615
PKG_RELEASE:=1

PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
#PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
#PKG_SOURCE_URL:=http://downloads.sourceforge.net/project/wide-dhcpv6/wide-dhcpv6/wide-dhcpv6-20080615/
#PKG_MD5SUM:=1011e165850fe40d3e332dad2bfd30b3

include $(INCLUDE_DIR)/package.mk

define Package/wide-dhcpv6/Default
  #SECTION:=net
  #CATEGORY:=Network
  SECTION:=ipv6
  CATEGORY:=IPv6
  TITLE:=WIDE DHCPv6
  #URL:=http://downloads.sourceforge.net/project/wide-dhcpv6/
endef

define Package/wide-dhcpv6-relay
  $(call Package/wide-dhcpv6/Default)
  TITLE+= relay
endef

define Package/wide-dhcpv6-client
  $(call Package/wide-dhcpv6/Default)
  TITLE+= client
endef

define Package/wide-dhcpv6-server
  $(call Package/wide-dhcpv6/Default)
  TITLE+= server
endef

define Build/Prepare
    @echo "Preparing...................."
	$(call Build/Prepare/Default)
	$(CP) -p src/* $(PKG_BUILD_DIR)/
endef

define Build/Configure
    # it's not GNU autoconf stuff
	(cd $(PKG_BUILD_DIR) ; rm -rf config.{cache,status} ; \
		./configure \
	);
endef


define Build/Compile
	@echo "Compile...................."
	UNAME_S=Linux \
	UNAME_M=$(ARCH) \
	UNAME_R=2.6.23 \
	$(MAKE) -C $(PKG_BUILD_DIR) \
		$(TARGET_CONFIGURE_OPTS) \
		DESTDIR="$(PKG_INSTALL_DIR)" \
		all install
endef

define Package/wide-dhcpv6-relay/install
	$(INSTALL_DIR) $(1)/usr/sbin
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/dhcp6relay $(1)/usr/sbin/wide-dhcp6relay
endef

define Package/wide-dhcpv6-client/install
	$(INSTALL_DIR) $(1)/usr/sbin
	$(INSTALL_DIR) $(1)/etc/dhcp6/
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/dhcp6c $(1)/usr/sbin/wide-dhcp6c 
	#$(INSTALL_BIN) $(PKG_BUILD_DIR)/dhcp6c.conf $(1)/usr/sbin/
	#$(INSTALL_BIN) $(PKG_BUILD_DIR)/dhcp6c.conf.info $(1)/usr/sbin/
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/openwrt-dhcp6c-script $(1)/etc/dhcp6/dhcp6c-script
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/start_dhcp6c $(1)/usr/sbin/start_dhcp6c
	#$(INSTALL_BIN) $(PKG_BUILD_DIR)/start_radvd $(1)/usr/sbin/start_radvd
endef

define Package/wide-dhcpv6-server/install
	$(INSTALL_DIR) $(1)/usr/sbin
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/dhcp6s $(1)/usr/sbin/wide-dhcp6s
endef



$(eval $(call BuildPackage,wide-dhcpv6-relay))
$(eval $(call BuildPackage,wide-dhcpv6-client))
$(eval $(call BuildPackage,wide-dhcpv6-server))
