PACKAGE := realtime-lsm
VERSION := 0.8.7
SOURCES := Makefile realtime.c
COMMONCAP := commoncap.c
DIST_EXTRA := AUTHORS ChangeLog COPYING INSTALL README
DISTFILES := $(SOURCES) $(DIST_EXTRA)

KERNEL_DIR := /usr/src/linux

distdir := $(PACKAGE)-$(VERSION)

obj-m := realtime.o

realtime-objs:= realtime.o commoncap.o


ifndef KERNELRELEASE

all:	$(SOURCES) config
	$(MAKE) modules -C $(KERNEL_DIR) SUBDIRS=$(shell pwd)

config:
	@if grep CONFIG_SECURITY_CAPABILITIES=m $(KERNEL_DIR)/.config; \
	then ln -sf $(KERNEL_DIR)/security/$(COMMONCAP) .; \
	else echo "Failed: Security Capabilities not configured as module"; \
	     echo "Realtime LSM will not work with $(KERNEL_DIR)"; \
	     echo "Please rerun \`make config' on the kernel and try again."; \
	     false; \
	fi

install:
	$(MAKE) modules_install -C $(KERNEL_DIR) SUBDIRS=$(shell pwd)

clean:
	-rm -f *.ko *.o $(COMMONCAP)
	-rm -f *.mod.* .*.cmd
	-rm -rf .tmp_versions

endif

$(distdir): $(DISTFILES)
	mkdir -p $(distdir)
	cp -p $(DISTFILES) $(distdir)

dist:	$(distdir)
	tar czf $(distdir).tar.gz $(distdir)
	rm -rf $(distdir)

.DELETE_ON_ERROR:
