PACKAGE := realtime
VERSION := 0.0.4
SOURCES := Makefile realcap.c
COMMONCAP := commoncap.c
DIST_EXTRA := README INSTALL COPYING
DISTFILES := $(SOURCES) $(DIST_EXTRA)

KERNEL_DIR := /usr/src/linux

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

obj-m := realtime.o

realtime-objs:= realcap.o commoncap.o


ifndef KERNELRELEASE

all:	$(SOURCES) commoncap.c
	$(MAKE) modules -C $(KERNEL_DIR) SUBDIRS=$(shell pwd)

$(COMMONCAP):
	@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

endif

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

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

.DELETE_ON_ERROR:
