# ---------------------------------------------------------------------------
# (C) Copyright 2012..2017 Roesch & Walter Industrie-Elektronik GmbH, Germany
#     support@rw-gmbh.de
# ---------------------------------------------------------------------------
#
# Makefile for generation of:
# mcug3.[o, ko] loadable kernel module driver
#
# Changelog:
#	2017-06-10 added depmod @ install target
#	2012-07-06 Arranged for compiling 2.6, 3.x and 4.x using Kbuild infrastructure
#                  usage: make [clean install]
# 
######################################################################
# !!!!! please consider to set up KDIR for other kernel versions !!!!!
######################################################################

# Using File Kbuild !!

PWD	:= $(shell pwd)
KDIR    ?= /lib/modules/$(shell uname -r)/build
MODDIR  ?= mcu

all default:
	$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules

.PHONY: clean 
clean:
	$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) clean

# You must be su, to do that!
install modules_install: $(INSTALLDIR)
	su -c "$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) INSTALL_MOD_DIR=$(MODDIR) modules_install"
	depmod -a

# End of Makefile

