#
# ===========================================================================
# 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) 2014-2016, 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.
# ================================================================================

#

KERNEL_SRC ?= /lib/modules/`uname -r`/build
V ?= 0


#obj-m += icetestmodule.o
#icetestmodule-objs := ice_pltfm.o ice_verification.o ice_accessors.o descriptor.o

#obj-y += drivers/pie/
#obj-y += verification/ice/

# build the pie test and drivers
obj-y += drivers/pie/ verification/pie/ drivers/

# build the pic test drivers
obj-y += drivers/pic/ verification/pic/ drivers/

# build the pip driver
#obj-y += drivers/pip/ verification/pip/ drivers/

# build the cisx driver
obj-y += drivers/cisx/ drivers/

# build the afe drivers
obj-y += drivers/afe/ drivers/afe/devices/sample/

#build the icetest drivers
obj-y += drivers/icetest/ drivers/

#build the scanblk drivers
obj-y += drivers/scanblk/ drivers/

ccflags-y += -I$(obj)/asic/G2/include

all:
	$(MAKE) -C $(KERNEL_SRC) V=$V M=$(CURDIR)

modules_install:
	$(MAKE) -C $(KERNEL_SRC) V=$V M=$(CURDIR) modules_install

clean:
	$(MAKE) -C $(KERNEL_SRC) V=$V M=$(CURDIR) clean

#%_lib.o: CFLAGS += -fPIC -Iasic/G2/include -Idrivers/ -Idrivers/pie -Idrivers/pic -Idrivers/pip
%_lib.o: CFLAGS += -fPIC -Iasic/G2/include -Idrivers/ -Idrivers/pie -Idrivers/pic
%_lib.o: %.c
	$(CC) $(CFLAGS) -c -o $@ $^

libpieconvenience.so: ./drivers/pie/pie_convenience_lib.o ./drivers/pie/pie_driverlib_lib.o
	$(LINK.c) $(LDFLAGS) -shared -o $@ $^
libpicconvenience.so: ./drivers/pic/pic_convenience_lib.o ./drivers/pic/pic_driverlib_lib.o
	$(LINK.c) $(LDFLAGS) -shared -o $@ $^
#libpipconvenience.so: ./drivers/pip/pip_convenience_lib.o ./drivers/pip/pip_driverlib_lib.o
#	$(LINK.c) $(LDFLAGS) -shared -o $@ $^

#convenience-libs: libpieconvenience.so libpicconvenience.so libpipconvenience.so
convenience-libs: libpieconvenience.so libpicconvenience.so

