#
# Copyright (C) 2011 HBM Netherlands B.V.
# Schutweg 15a
# 5145NP Waalwijk
# The Netherlands
# http://www.hbm.com
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
#

include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk

PKG_NAME:=hbm-eth-core
PKG_RELEASE:=1

include $(INCLUDE_DIR)/package.mk

define KernelPackage/hbm-eth-core
  SUBMENU:=Other modules
  TITLE:=HBM IM2 Intel 82576 Ethernet core (eeprom access) driver
  DEPENDS:=
  FILES:=$(PKG_BUILD_DIR)/hbm-eth-core-driver.$(LINUX_KMOD_SUFFIX)
endef

define KernelPackage/hbm-eth-core/description
 Kernel module for the Intel 82576 Ethernet driver register access (for EEPROM programming)
endef

EXTRA_KCONFIG:=
EXTRA_CFLAGS:=-I$(PKG_BUILD_DIR)
MAKE_OPTS:= \
	ARCH="$(LINUX_KARCH)" \
	CROSS_COMPILE="$(TARGET_CROSS)" \
	SUBDIRS="$(PKG_BUILD_DIR)" \
	EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
	$(EXTRA_KCONFIG)

define Build/Prepare
	mkdir -p $(PKG_BUILD_DIR)
	$(CP) ./src/*.c $(PKG_BUILD_DIR)/
	$(CP) ./src/*.h $(PKG_BUILD_DIR)/
endef

define Build/Compile
	echo 'obj-m	:= hbm-eth-core-driver.o'> $(PKG_BUILD_DIR)/Makefile
	$(MAKE) -C "$(LINUX_DIR)" \
		$(MAKE_OPTS) \
		modules
	rm -f $(PKG_BUILD_DIR)/*.o
endef

define Build/InstallDev
endef

$(eval $(call KernelPackage,hbm-eth-core))
