
# NOTE!  This Makefile is for building the pxi module on the local
# machine, not for cross-compiling.  If you are cross-compiling, run
# make from your kernel build tree and pass an M= argument to this
# directory.

# Must have
# /lib/modules/`uname -r`/source/include/linux/kfifo.h
# And these macros ...
# kfifo_from_user
# kfifo_is_full
# kfifo_to_user
# kfifo_is_empty
# kfifo_reset_out

# We need these symbols ...
# U __kfifo_alloc
# U __kfifo_dma_in_prepare
# U __kfifo_dma_out_prepare
# U __kfifo_free
# U __kfifo_from_user
# U __kfifo_to_user

LOOKFOR = kfifo_from_user
KVER := $(shell uname -r)
KFIFO_H := /lib/modules/$(KVER)/build/include/linux/kfifo.h

ifneq "$(shell grep -q -w __$(LOOKFOR) /lib/modules/$(KVER)/build/Module.symvers; echo $$?)" "0"
$(error Requires a kfifo implementation that provides __$(LOOKFOR))
endif

ifneq "$(shell grep -q -w $(LOOKFOR) $(KFIFO_H); echo $$?)" "0"
$(info $(shell grep -w $(LOOKFOR) $(KFIFO_H); echo $$?))
$(error Requires a kfifo implementation that provides $(LOOKFOR))
endif

modules:
	make -C /lib/modules/$(KVER)/build M=`pwd` modules NOT_EMBEDDED=1
.PHONY: modules

.PHONY: clean
clean:
	make -C /lib/modules/$(KVER)/build M=`pwd` clean

.PHONY: install
install:
	make -C /lib/modules/$(KVER)/build M=`pwd` modules_install  NO_POWER=1
