# ===========================================================================
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Copyright (c) 2008-2014, Marvell International Ltd.
#
# Alternatively, this software may be distributed under the terms of the GNU
# General Public License Version 2, and any use shall comply with the terms and
# conditions of the GPL.  A copy of the GPL is available at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
# IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
# ARE EXPRESSLY DISCLAIMED.  The GPL license provides additional details about
# this warranty disclaimer.
# ================================================================================

POKY          ?= /media/overflow/lsp/g2/g2src
POKY_BLD      ?= $(POKY)/poky/build

MODULE         = sccplite
DRV_ROOT       = $(POKY)/drivers

PRJROOT       ?= /fw/lsp/drop_g2/bundle
MODROOT       ?= $(PWD)
BUILD_ROOT    ?= $(MODROOT)/..
KERNEL_PATH   ?= $(POKY_BLD)/tmp/sysroots/granite2/usr/src/kernel
SRC_ROOT       = $(POKY_BLD)/tmp/work/granite2-linux-poky-gnueabi

# CROSS_COMPILE ?= arm-marvell-linux-gnueabi-
# CROSS_COMPILE ?= arm-poky-linux-gnueabi-

CROSS_COMPILE ?= arm-marvell-linux-gnueabi-
CROSS_COMPILE ?= arm-poky-linux-gnueabi-
ARCH          ?= arm

#ARM_ROOT ?= $(POKY_BLD)/tmp/sysroots/i686-linux/usr/bin/
#CCPREFIX ?= arm-poky-linux-gnueabi-
#CROSS_COMPILE ?= $(ARM_ROOT)armv7a-poky-linux-gnueabi/$(CCPREFIX)

.PHONEY: check install


# cross-compile module makefile

obj-m := sccplite.o 

ORIGINAL_SOURCE = $(realpath $(PWD))
ccflags-y += -I$(ORIGINAL_SOURCE) 
ccflags-y += -v
ldflags-y += -L.

SRC := $(shell pwd)

all:
	echo "all sccplite"
	echo $(KERNEL_PATH) 
	$(MAKE) -C $(KERNEL_PATH) M=$(SRC)  SUBDIRS=`pwd` ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) modules

modules_install:
	echo "install sccplite"
	echo $(KERNEL_PATH) 
	$(MAKE) -C $(KERNEL_PATH) M=$(SRC) SUBDIRS=`pwd` ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE)  modules_install

clean:
	rm -f *.o *~ core .depend .*.cmd *.ko *.mod.c
	rm -f Module.markers Module.symvers modules.order
	rm -rf .tmp_versions Modules.symvers




