xref: /linux/security/apparmor/Makefile (revision 4fdef2183e6598cc977a9bb9321ef99a44125da3)
1016d825fSJohn Johansen# Makefile for AppArmor Linux Security Module
2016d825fSJohn Johansen#
3016d825fSJohn Johansenobj-$(CONFIG_SECURITY_APPARMOR) += apparmor.o
4016d825fSJohn Johansen
5016d825fSJohn Johansenapparmor-y := apparmorfs.o audit.o capability.o context.o ipc.o lib.o match.o \
6016d825fSJohn Johansen              path.o domain.o policy.o policy_unpack.o procattr.o lsm.o \
7016d825fSJohn Johansen              resource.o sid.o file.o
8016d825fSJohn Johansen
9*4fdef218SJohn Johansenclean-files: capability_names.h rlim_names.h
10016d825fSJohn Johansen
11*4fdef218SJohn Johansen
12*4fdef218SJohn Johansen# Build a lower case string table of capability names
13*4fdef218SJohn Johansen# Transforms lines from
14*4fdef218SJohn Johansen#    #define CAP_DAC_OVERRIDE     1
15*4fdef218SJohn Johansen# to
16*4fdef218SJohn Johansen#    [1] = "dac_override",
17016d825fSJohn Johansenquiet_cmd_make-caps = GEN     $@
18*4fdef218SJohn Johansencmd_make-caps = echo "static const char *capability_names[] = {" > $@ ;\
19*4fdef218SJohn Johansen	sed $< >>$@ -r -n -e '/CAP_FS_MASK/d' \
20*4fdef218SJohn Johansen	-e 's/^\#define[ \t]+CAP_([A-Z0-9_]+)[ \t]+([0-9]+)/[\2] = "\L\1",/p';\
21*4fdef218SJohn Johansen	echo "};" >> $@
22016d825fSJohn Johansen
23*4fdef218SJohn Johansen
24*4fdef218SJohn Johansen# Build a lower case string table of rlimit names.
25*4fdef218SJohn Johansen# Transforms lines from
26*4fdef218SJohn Johansen#    #define RLIMIT_STACK		3	/* max stack size */
27*4fdef218SJohn Johansen# to
28*4fdef218SJohn Johansen#    [RLIMIT_STACK] = "stack",
29*4fdef218SJohn Johansen#
30*4fdef218SJohn Johansen# and build a second integer table (with the second sed cmd), that maps
31*4fdef218SJohn Johansen# RLIMIT defines to the order defined in asm-generic/resource.h  Thi is
32*4fdef218SJohn Johansen# required by policy load to map policy ordering of RLIMITs to internal
33*4fdef218SJohn Johansen# ordering for architectures that redefine an RLIMIT.
34*4fdef218SJohn Johansen# Transforms lines from
35*4fdef218SJohn Johansen#    #define RLIMIT_STACK		3	/* max stack size */
36*4fdef218SJohn Johansen# to
37*4fdef218SJohn Johansen# RLIMIT_STACK,
38016d825fSJohn Johansenquiet_cmd_make-rlim = GEN     $@
39*4fdef218SJohn Johansencmd_make-rlim = echo "static const char *rlim_names[] = {" > $@ ;\
40*4fdef218SJohn Johansen	sed $< >> $@ -r -n \
41*4fdef218SJohn Johansen	    -e 's/^\# ?define[ \t]+(RLIMIT_([A-Z0-9_]+)).*/[\1] = "\L\2",/p';\
42*4fdef218SJohn Johansen	echo "};" >> $@ ;\
43*4fdef218SJohn Johansen	echo "static const int rlim_map[] = {" >> $@ ;\
44*4fdef218SJohn Johansen	sed -r -n "s/^\# ?define[ \t]+(RLIMIT_[A-Z0-9_]+).*/\1,/p" $< >> $@ ;\
45*4fdef218SJohn Johansen	echo "};" >> $@
46016d825fSJohn Johansen
47016d825fSJohn Johansen$(obj)/capability.o : $(obj)/capability_names.h
48016d825fSJohn Johansen$(obj)/resource.o : $(obj)/rlim_names.h
49016d825fSJohn Johansen$(obj)/capability_names.h : $(srctree)/include/linux/capability.h
50016d825fSJohn Johansen	$(call cmd,make-caps)
51016d825fSJohn Johansen$(obj)/rlim_names.h : $(srctree)/include/asm-generic/resource.h
52016d825fSJohn Johansen	$(call cmd,make-rlim)
53