#
# 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-bootmode-driver
PKG_RELEASE:=1

include $(INCLUDE_DIR)/package.mk

define KernelPackage/hbm-bootmode-driver
  SUBMENU:=Other modules
  TITLE:=HBM Bootmode Driver
  DEPENDS:=
  FILES:=$(PKG_BUILD_DIR)/hbm-bootmode-driver.$(LINUX_KMOD_SUFFIX)
  KCONFIG:=
  AUTOLOAD:=$(call AutoLoad,60,hbm-bootmode-driver)
endef

define KernelPackage/hbm-bootmode-driver/description
 Kernel module for that queries the boot mode switch on the backplane of the HBM GenSeries acquisition systems.
endef

EXTRA_KCONFIG:=
EXTRA_CFLAGS:=-DDEBUG_DRIVER
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/* $(PKG_BUILD_DIR)/
endef

define Build/Compile
	$(MAKE) -C "$(LINUX_DIR)" \
		$(MAKE_OPTS) \
		modules
endef

define Build/InstallDev
	$(INSTALL_DIR) $(STAGING_DIR)/usr/include/hbm
	$(CP) ./src/hbm-bootmode-driver.h $(STAGING_DIR)/usr/include/hbm
endef

$(eval $(call KernelPackage,hbm-bootmode-driver))
