# Compiles txrx_subsys driver and txrx_test test program
#
# Authors
# 	
# 	Christopher Campbell (cc3769@columbia.edu)
#	Valeh Valiollahpour Amiri (vv2252@columbia.edu)
#
# Last Modified
#
# 	April 11th, 2015

ifneq (${KERNELRELEASE},)

# KERNELRELEASE defined: we are being compiled as part of the Kernel
obj-m := txrx_subsys.o

else

# We are being compiled as a module: use the Kernel build system
PWD := $(shell pwd)
KDIR := /usr/src/linux
ARCH := arm
KDIR_CROSS := /home/cc3769/ES_Project/linux-socfpga
CROSS_COMP := /usr/local/DS-5/bin/arm-linux-gnueabihf-
DTC := $(KDIR)/scripts/dtc/dtc

default: module txrx_test socfpga.dtb

module:
	${MAKE} -C ${KDIR} SUBDIRS=${PWD} modules

txrx_test: txrx_test.o
	gcc -o txrx_test txrx_test.o

txrx_test.o: txrx_test.c
	gcc -c txrx_test.c

socfpga.dtb: socfpga.dts
	$(DTC) -O dtb -o socfpga.dtb socfpga.dts

clean:
	${MAKE} -C ${KDIR} SUBDIRS=${PWD} clean
	${RM} txrx_test socfpga.dtb *~

endif 
