# *****************************************************************
# This file is part of the book "Embedded Linux - Das Praxisbuch"
#
# Copyright (C) 2008-2012 Joachim Schroeder
# Chair Prof. Dillmann (IAIM),
# Institute for Computer Science and Engineering,
# University of Karlsruhe. All rights reserved.
#
# 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 Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
# *****************************************************************

# *****************************************************************
# Filename:  Makefile
# Copyright: Joachim Schroeder, Chair Prof. Dillmann (IAIM),
#            Institute for Computer Science and Engineering (CSE),
#            University of Karlsruhe. All rights reserved.
# Author:    Joachim Schroeder
# Date:      29.06.2008
# *****************************************************************

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

# Name and release number of this package
PKG_NAME:=kmod-iowarrior
PKG_RELEASE:=1

# Build-Directory
PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)

include $(INCLUDE_DIR)/package.mk

# Set package category under which it appears in configuration,
# dependancies, description and target file
define KernelPackage/iowarrior
  SUBMENU:=Other modules
  DEPENDS:=@PACKAGE_kmod-usb-core
  TITLE:=IOwarrior driver
  DESCRIPTION:=\
	This package contains the driver for IOWarriors 24, 40 and 56.
  VERSION:=$(LINUX_VERSION)-$(BOARD)-$(PKG_RELEASE)
  FILES:= \
	$(PKG_BUILD_DIR)/iowarrior.$(LINUX_KMOD_SUFFIX)
  AUTOLOAD:=$(call AutoLoad,80,usb-core)
endef

# Copy local source files from package into build directory to prepare build process
define Build/Prepare
	mkdir -p $(PKG_BUILD_DIR)
	$(CP) ./src/* $(PKG_BUILD_DIR)/
endef

# Commands for the compile process
define Build/Compile
	$(MAKE) -C "$(LINUX_DIR)" \
		CROSS_COMPILE="$(TARGET_CROSS)" \
		ARCH="$(LINUX_KARCH)" \
		SUBDIRS="$(PKG_BUILD_DIR)" \
		EXTRA_CFLAGS="$(BUILDFLAGS)" \
		modules
endef

# Specify what to do in the installation process
# $(INSTALL_BIN) copies udev rules
define KernelPackage/iowarrior/install
	$(INSTALL_DIR) $(1)/etc/udev/rules.d/
	$(INSTALL_BIN) ./src/10-iowarrior.rules $(1)/etc/udev/rules.d/
endef

# Compile package
$(eval $(call KernelPackage,iowarrior))
