#
# Makefile for rsbac decision module example. 
#
# Author and (c) 1999 Amon Ott <ao@compuniverse.com>
#

# Set this to your kernel directory
KERNELDIR = /usr/src/linux

# comment out, if kernel is not SMP or has no MODVERSIONS
#SMP=1
#MODVERSIONS=1

# comment out, if RSBAC kernel has no PROC support
CONFIG_RSBAC_PROC=1

# set this to your module dir
MODDIR=/lib/modules/`uname -r`/misc

# set this to your bin dir
BINDIR=/usr/local/bin

# ----- nothing should be changed below -----
#HELPPATH = $(KERNELDIR)/rsbac/help

CC = gcc 

CFLAGS = -O2 -m486 -Wall -I $(KERNELDIR)/include -DCONFIG_RSBAC 
SFLAGS = -lrsbac
MFLAGS = -D__KERNEL__ -DMODULE -DCONFIG_RSBAC_REG

ifdef SMP
MFLAGS+=-D__SMP__
endif
ifdef MODVERSIONS
MFLAGS+=-DMODVERSIONS -include $(KERNELDIR)/include/linux/modversions.h
endif

ifdef CONFIG_RSBAC_PROC
MFLAGS+=-DCONFIG_RSBAC_PROC
endif

MODULES=reg_sample1.o reg_sample2.o reg_sample3.o
PROGS=reg_syscall

LIBS = 

all :
	set -e
	for i in $(PROGS) ; do $(MAKE) CFLAGS="$(CFLAGS) $(SFLAGS)" $$i ; done
	for i in $(MODULES) ; do $(MAKE) CFLAGS="$(CFLAGS) $(MFLAGS)" $$i ; done

install : $(MODULES) $(PROGS)
	-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 $(PROGS) $(BINDIR)

uninstall :
	-bash -c "cd $(MODDIR) && rm $(MODULES)"
	-bash -c "cd $(BINDIR) && rm $(PROGS)"

clean :
	rm -f $(MODULES) $(PROGS)
