162306a36Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci#
362306a36Sopenharmony_ci# Makefile for building the SELinux module as part of the kernel tree.
462306a36Sopenharmony_ci#
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci# NOTE: There are a number of improvements that can be made to this Makefile
762306a36Sopenharmony_ci# once the kernel requires make v4.3 or greater; the most important feature
862306a36Sopenharmony_ci# lacking in older versions of make is support for grouped targets.  These
962306a36Sopenharmony_ci# improvements are noted inline in the Makefile below ...
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ciobj-$(CONFIG_SECURITY_SELINUX) := selinux.o
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ciccflags-y := -I$(srctree)/security/selinux -I$(srctree)/security/selinux/include
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ciselinux-y := avc.o hooks.o selinuxfs.o netlink.o nlmsgtab.o netif.o \
1662306a36Sopenharmony_ci	     netnode.o netport.o status.o \
1762306a36Sopenharmony_ci	     ss/ebitmap.o ss/hashtab.o ss/symtab.o ss/sidtab.o ss/avtab.o \
1862306a36Sopenharmony_ci	     ss/policydb.o ss/services.o ss/conditional.o ss/mls.o ss/context.o
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ciselinux-$(CONFIG_SECURITY_NETWORK_XFRM) += xfrm.o
2162306a36Sopenharmony_ciselinux-$(CONFIG_NETLABEL) += netlabel.o
2262306a36Sopenharmony_ciselinux-$(CONFIG_SECURITY_INFINIBAND) += ibpkey.o
2362306a36Sopenharmony_ciselinux-$(CONFIG_IMA) += ima.o
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_cigenhdrs := flask.h av_permissions.h
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci# see the note above, replace the dependency rule with the one below:
2862306a36Sopenharmony_ci#  $(addprefix $(obj)/,$(selinux-y)): $(addprefix $(obj)/,$(genhdrs))
2962306a36Sopenharmony_ci$(addprefix $(obj)/,$(selinux-y)): $(obj)/flask.h
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ciquiet_cmd_genhdrs = GEN     $(addprefix $(obj)/,$(genhdrs))
3262306a36Sopenharmony_ci      cmd_genhdrs = $< $(addprefix $(obj)/,$(genhdrs))
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ci# see the note above, replace the $targets and 'flask.h' rule with the lines
3562306a36Sopenharmony_ci# below:
3662306a36Sopenharmony_ci#  targets += $(genhdrs)
3762306a36Sopenharmony_ci#  $(addprefix $(obj)/,$(genhdrs)) &: scripts/selinux/...
3862306a36Sopenharmony_citargets += flask.h
3962306a36Sopenharmony_ci$(obj)/flask.h: scripts/selinux/genheaders/genheaders FORCE
4062306a36Sopenharmony_ci	$(call if_changed,genhdrs)
41