# # Makefile for rsbac decision module example. # # Author and (c) 1999-2009 Amon Ott <ao@rsbac.org> # # Set this to your kernel directory # comment out, if kernel is not SMP or has no MODVERSIONS #SMP=1 #MODVERSIONS=1 DESTDIR := PREFIX := $(DESTDIR)/usr/local # comment out, if RSBAC kernel has no PROC support CONFIG_RSBAC_PROC := 1 ifeq ($(KERN), "") KERN := /lib/modules/`uname -r`/ endif ifeq ($(KERN), "") KERNSOURCE := $(KERN)/source endif MODDIR := $(KERN)/misc KERNVER := $(shell uname -r|cut -d "." -f1,2) PWD := $(shell pwd) # set this to your bin dir BINDIR := $(PREFIX)/bin # ----- nothing should be changed below ----- #HELPPATH = $(KERNELDIR)/rsbac/help CC := gcc ifeq ($(KERNVER), 2.4) CFLAGS := -O2 -DCONFIG_RSBAC CFLAGS += -I$(PREFIX)/include -I/usr/include -I $(KERNSOURCE)/include else EXTRA_CFLAGS := -O2 -DCONFIG_RSBAC EXTRA_CFLAGS += -I$(PREFIX)/include -I/usr/include -I $(KERNSOURCE)/include endif SFLAGS := -lrsbac MFLAGS := -D__KERNEL__ -DMODULE -DCONFIG_RSBAC_REG ifdef SMP MFLAGS +=-D__SMP__ endif ifdef MODVERSIONS MFLAGS += -DMODVERSIONS MFLAGS += -include -I$(PREFIX)/include/linux/modversions.h \ -I/usr/include/linux/modversions.h endif ifdef CONFIG_RSBAC_PROC MFLAGS +=-DCONFIG_RSBAC_PROC endif obj-m := reg_sample1.o reg_sample3.o rbac.o MODULES := reg_sample1.o reg_sample3.o rbac.o PROG := reg_syscall rbac_admin LIBS := all : ifeq ($(KERNVER), 2.4) set -e for i in $(MODULES) ; do $(MAKE) CFLAGS="$(CFLAGS) $(MFLAGS)" $$i ; done else @make -C $(KERNSOURCE) SUBDIRS=$(PWD) modules endif for i in $(PROG) ; do gcc $(CFLAGS) $(SFLAGS) $$i.c -o $$i ; done install : $(MODULES) $(PROG) -bash -c "if test ! -d $(MODDIR) ; then mkdir $(MODDIR) ; fi" install -m 644 $(MODULES) $(MODDIR) -depmod -a -bash -c "if test ! -d $(BINDIR) ; then mkdir $(BINDIR) ; fi" install -m 644 $(PROG) $(BINDIR) uninstall : -bash -c "cd $(MODDIR) && rm $(MODULES)" -bash -c "cd $(BINDIR) && rm $(PROG)" clean : ifeq ($(KERNVER), 2.4) rm -f $(MODULES) $(PROG) else @make -C $(KERNSOURCE) SUBDIRS=$(PWD) clean endif