]> git.ipfire.org Git - people/stevee/selinux-policy.git/blame - refpolicy/Makefile
make executable
[people/stevee/selinux-policy.git] / refpolicy / Makefile
CommitLineData
88d14a22
CP
1#
2# Makefile for the security policy.
3#
4# Targets:
5#
6# install - compile and install the policy configuration, and context files.
7# load - compile, install, and load the policy configuration.
8# reload - compile, install, and load/reload the policy configuration.
9# relabel - relabel filesystems based on the file contexts configuration.
10# checklabels - check filesystems against the file context configuration
11# restorelabels - check filesystems against the file context configuration
12# and restore the label of files with incorrect labels
13# policy - compile the policy configuration locally for testing/development.
14#
15# The default target is 'policy'.
16#
b4cd1533 17#
8e0ef1f9 18# Please see build.conf for policy build options.
b4cd1533
CP
19#
20
b4cd1533
CP
21########################################
22#
b67488e3 23# NO OPTIONS BELOW HERE
b4cd1533
CP
24#
25
c9f20d5b
CP
26# Include the local build.conf if it exists, otherwise
27# include the configuration of the root directory.
1a7175a8
CP
28include build.conf
29
30ifdef LOCAL_ROOT
31 -include $(LOCAL_ROOT)/build.conf
c9f20d5b 32endif
8e0ef1f9 33
120988c4
CP
34# refpolicy version
35VERSION = $(shell cat VERSION)
36
c9f20d5b 37ifdef LOCAL_ROOT
5b45ffb0 38BUILDDIR := $(LOCAL_ROOT)/
c9f20d5b
CP
39TMPDIR := $(LOCAL_ROOT)/tmp
40TAGS := $(LOCAL_ROOT)/tags
41else
5b45ffb0
CP
42TMPDIR := tmp
43TAGS := tags
c9f20d5b
CP
44endif
45
b4cd1533 46# executable paths
120988c4
CP
47BINDIR := /usr/bin
48SBINDIR := /usr/sbin
40a1f3db 49CHECKPOLICY := $(BINDIR)/checkpolicy
fb0a3a98 50CHECKMODULE := $(BINDIR)/checkmodule
c767b14c 51SEMODULE := $(SBINDIR)/semodule
fb0a3a98 52SEMOD_PKG := $(BINDIR)/semodule_package
ea5333d1
CP
53SEMOD_LNK := $(BINDIR)/semodule_link
54SEMOD_EXP := $(BINDIR)/semodule_expand
547283e2 55LOADPOLICY := $(SBINDIR)/load_policy
b4cd1533 56SETFILES := $(SBINDIR)/setfiles
1beba1c6 57GENHOMEDIRCON := $(SBINDIR)/genhomedircon
fb0a3a98 58XMLLINT := $(BINDIR)/xmllint
8df65f13 59SECHECK := $(BINDIR)/sechecker
0447352a 60
0e686f1f
CP
61# interpreters and aux tools
62AWK ?= gawk
63GREP ?= egrep
64M4 ?= m4
65PYTHON ?= python
66SED ?= sed
f62f4c79 67SORT ?= LC_ALL=C sort
0e686f1f
CP
68
69CFLAGS += -Wall
c7b41e95 70
fb0a3a98 71# policy source layout
5b45ffb0 72POLDIR := policy
c04f2abe
CP
73MODDIR := $(POLDIR)/modules
74FLASKDIR := $(POLDIR)/flask
75SECCLASS := $(FLASKDIR)/security_classes
76ISIDS := $(FLASKDIR)/initial_sids
77AVS := $(FLASKDIR)/access_vectors
fb0a3a98 78
c9f20d5b
CP
79# local source layout
80ifdef LOCAL_ROOT
81LOCAL_POLDIR := $(LOCAL_ROOT)/policy
82LOCAL_MODDIR := $(LOCAL_POLDIR)/modules
83endif
84
fb0a3a98 85# policy building support tools
5b45ffb0 86SUPPORT := support
0e686f1f
CP
87GENXML := $(PYTHON) $(SUPPORT)/segenxml.py
88GENDOC := $(PYTHON) $(SUPPORT)/sedoctool.py
89GENPERM := $(PYTHON) $(SUPPORT)/genclassperms.py
c9f20d5b 90FCSORT := $(TMPDIR)/fc_sort
d6cf05b3 91SETBOOLS := $(AWK) -f $(SUPPORT)/set_bools_tuns.awk
3abd5ee8
CP
92get_type_attr_decl := $(SED) -r -f $(SUPPORT)/get_type_attr_decl.sed
93comment_move_decl := $(SED) -r -f $(SUPPORT)/comment_move_decl.sed
3a80ec29 94
fb0a3a98 95# documentation paths
5b45ffb0 96DOCS := doc
fb0a3a98
CP
97XMLDTD = $(DOCS)/policy.dtd
98LAYERXML = metadata.xml
fb0a3a98 99DOCTEMPLATE = $(DOCS)/templates
5bd1a703 100DOCFILES = $(DOCS)/Makefile.example $(addprefix $(DOCS)/,example.te example.if example.fc)
fb0a3a98 101
c9f20d5b
CP
102ifndef LOCAL_ROOT
103POLXML = $(DOCS)/policy.xml
3d598062
CP
104TUNXML = $(DOCS)/global_tunables.xml
105BOOLXML = $(DOCS)/global_booleans.xml
c9f20d5b
CP
106HTMLDIR = $(DOCS)/html
107else
108POLXML = $(LOCAL_ROOT)/doc/policy.xml
3d598062
CP
109TUNXML = $(LOCAL_ROOT)/doc/global_tunables.xml
110BOOLXML = $(LOCAL_ROOT)/doc/global_booleans.xml
c9f20d5b
CP
111HTMLDIR = $(LOCAL_ROOT)/doc/html
112endif
113
fb0a3a98 114# config file paths
120988c4
CP
115GLOBALTUN = $(POLDIR)/global_tunables
116GLOBALBOOL = $(POLDIR)/global_booleans
120988c4 117TUNABLES = $(POLDIR)/tunables.conf
120988c4 118ROLEMAP = $(POLDIR)/rolemap
90b331fa 119USER_FILES := $(POLDIR)/users
fb0a3a98 120
c9f20d5b
CP
121# local config file paths
122ifndef LOCAL_ROOT
123MOD_CONF = $(POLDIR)/modules.conf
124BOOLEANS = $(POLDIR)/booleans.conf
125else
126MOD_CONF = $(LOCAL_POLDIR)/modules.conf
127BOOLEANS = $(LOCAL_POLDIR)/booleans.conf
128endif
129
fb0a3a98 130# install paths
120988c4
CP
131PKGNAME ?= refpolicy-$(VERSION)
132PREFIX = $(DESTDIR)/usr
133TOPDIR = $(DESTDIR)/etc/selinux
134INSTALLDIR = $(TOPDIR)/$(NAME)
135SRCPATH = $(INSTALLDIR)/src
136USERPATH = $(INSTALLDIR)/users
137CONTEXTPATH = $(INSTALLDIR)/contexts
138FCPATH = $(CONTEXTPATH)/files/file_contexts
139SHAREDIR = $(PREFIX)/share/selinux
140MODPKGDIR = $(SHAREDIR)/$(NAME)
d6cf05b3 141HEADERDIR = $(MODPKGDIR)/include
120988c4 142DOCSDIR = $(PREFIX)/share/doc/$(PKGNAME)
c767b14c
CP
143
144# compile strict policy if requested.
145ifneq ($(findstring strict,$(TYPE)),)
3f026a90 146 M4PARAM += -D strict_policy
c767b14c
CP
147endif
148
149# compile targeted policy if requested.
150ifneq ($(findstring targeted,$(TYPE)),)
3f026a90 151 M4PARAM += -D targeted_policy
c767b14c 152endif
b4cd1533 153
134191be 154# enable MLS if requested.
a0824843 155ifneq ($(findstring -mls,$(TYPE)),)
3f026a90
CP
156 M4PARAM += -D enable_mls
157 CHECKPOLICY += -M
158 CHECKMODULE += -M
134191be
CP
159endif
160
a0824843
CP
161# enable MLS if MCS requested.
162ifneq ($(findstring -mcs,$(TYPE)),)
3f026a90
CP
163 M4PARAM += -D enable_mcs
164 CHECKPOLICY += -M
165 CHECKMODULE += -M
b67488e3
CP
166endif
167
25a0c61f
CP
168# enable distribution-specific policy
169ifneq ($(DISTRO),)
3f026a90 170 M4PARAM += -D distro_$(DISTRO)
25a0c61f
CP
171endif
172
2f1a8fbc
CP
173# rhel4 also implies redhat
174ifeq "$(DISTRO)" "rhel4"
175 M4PARAM += -D distro_redhat
176endif
177
b07eaef9
CP
178# enable polyinstantiation
179ifeq ($(POLY),y)
3f026a90 180 M4PARAM += -D enable_polyinstantiation
b07eaef9
CP
181endif
182
b67488e3 183ifneq ($(OUTPUT_POLICY),)
3f026a90 184 CHECKPOLICY += -c $(OUTPUT_POLICY)
b67488e3
CP
185endif
186
3f026a90
CP
187# if not set, use the type as the name.
188NAME ?= $(TYPE)
134191be 189
142e9f40 190ifeq ($(DIRECT_INITRC),y)
3f026a90 191 M4PARAM += -D direct_sysadm_daemon
142e9f40
CP
192endif
193
9b3756bf
CP
194ifeq ($(QUIET),y)
195 verbose = @
196endif
197
3f026a90 198M4PARAM += -D hide_broken_symptoms
ee7f66b0 199
37227dcd
CP
200# we need exuberant ctags; unfortunately it is named
201# differently on different distros
202ifeq ($(DISTRO),debian)
203 CTAGS := ctags-exuberant
204endif
205
206ifeq ($(DISTRO),gentoo)
207 CTAGS := exuberant-ctags
208endif
209
a4fae7fa 210CTAGS ?= ctags
37227dcd 211
b4cd1533 212# determine the policy version and current kernel version if possible
134191be 213PV := $(shell $(CHECKPOLICY) -V |cut -f 1 -d ' ')
b4cd1533
CP
214KV := $(shell cat /selinux/policyvers)
215
216# dont print version warnings if we are unable to determine
217# the currently running kernel's policy version
218ifeq ($(KV),)
134191be 219 KV := $(PV)
b4cd1533
CP
220endif
221
20144581
CP
222M4SUPPORT := $(wildcard $(POLDIR)/support/*.spt)
223ifdef LOCAL_ROOT
224M4SUPPORT += $(wildcard $(LOCAL_POLDIR)/support/*.spt)
225endif
0fbe15dc 226
5b45ffb0 227APPCONF := config/appconfig-$(TYPE)
ace3688a 228SEUSERS := $(APPCONF)/seusers
c9a26b3e 229APPDIR := $(CONTEXTPATH)
049e11af 230APPFILES := $(addprefix $(APPDIR)/,default_contexts default_type initrc_context failsafe_context userhelper_context removable_context dbus_contexts customizable_types) $(CONTEXTPATH)/files/media
2926f9c7 231CONTEXTFILES += $(wildcard $(APPCONF)/*_context*) $(APPCONF)/media
c9a26b3e 232
57869a68 233ALL_LAYERS := $(filter-out $(MODDIR)/CVS,$(shell find $(wildcard $(MODDIR)/*) -maxdepth 0 -type d))
c9f20d5b 234ifdef LOCAL_ROOT
e2680fb4 235ALL_LAYERS += $(filter-out $(LOCAL_MODDIR)/CVS,$(shell find $(wildcard $(LOCAL_MODDIR)/*) -maxdepth 0 -type d))
c9f20d5b 236endif
e12e5738
CP
237
238GENERATED_TE := $(basename $(foreach dir,$(ALL_LAYERS),$(wildcard $(dir)/*.te.in)))
239GENERATED_IF := $(basename $(foreach dir,$(ALL_LAYERS),$(wildcard $(dir)/*.if.in)))
240GENERATED_FC := $(basename $(foreach dir,$(ALL_LAYERS),$(wildcard $(dir)/*.fc.in)))
241
8ae194f6
CP
242# sort here since it removes duplicates, which can happen
243# when a generated file is already generated
244DETECTED_MODS := $(sort $(foreach dir,$(ALL_LAYERS),$(wildcard $(dir)/*.te)) $(GENERATED_TE))
19db6ba5 245
fb0a3a98 246# modules.conf setting for base module
e8b3e30a 247MODBASE := base
fb0a3a98 248
e0a9001b 249# modules.conf setting for loadable module
e8b3e30a 250MODMOD := module
fb0a3a98 251
e0a9001b
CP
252# modules.conf setting for unused module
253MODUNUSED := off
254
c9f20d5b 255# test for module overrides from command line
87e73c5f
CP
256MOD_TEST = $(filter $(APPS_OFF), $(APPS_BASE) $(APPS_MODS))
257MOD_TEST += $(filter $(APPS_MODS), $(APPS_BASE))
c9f20d5b 258ifneq ($(strip $(MOD_TEST)),)
3abd5ee8 259 $(error Applications must be base, module, or off, and not in more than one list! $(strip $(MOD_TEST)) found in multiple lists!)
c9f20d5b
CP
260endif
261
20144581
CP
262# add on suffix to modules specified on command line
263CMDLINE_BASE := $(addsuffix .te,$(APPS_BASE))
264CMDLINE_MODS := $(addsuffix .te,$(APPS_MODS))
265CMDLINE_OFF := $(addsuffix .te,$(APPS_OFF))
266
fb0a3a98 267# extract settings from modules.conf
20144581
CP
268MOD_CONF_BASE := $(addsuffix .te,$(sort $(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(MODBASE)") print $$1 }' $(MOD_CONF) 2> /dev/null)))
269MOD_CONF_MODS := $(addsuffix .te,$(sort $(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(MODMOD)") print $$1 }' $(MOD_CONF) 2> /dev/null)))
270MOD_CONF_OFF := $(addsuffix .te,$(sort $(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(MODUNUSED)") print $$1 }' $(MOD_CONF) 2> /dev/null)))
271
272BASE_MODS := $(CMDLINE_BASE)
273MOD_MODS := $(CMDLINE_MODS)
274OFF_MODS := $(CMDLINE_OFF)
87e73c5f 275
20144581
CP
276BASE_MODS += $(filter-out $(CMDLINE_OFF) $(CMDLINE_BASE) $(CMDLINE_MODS), $(MOD_CONF_BASE))
277MOD_MODS += $(filter-out $(CMDLINE_OFF) $(CMDLINE_BASE) $(CMDLINE_MODS), $(MOD_CONF_MODS))
278OFF_MODS += $(filter-out $(CMDLINE_OFF) $(CMDLINE_BASE) $(CMDLINE_MODS), $(MOD_CONF_OFF))
87e73c5f
CP
279
280# add modules not in modules.conf to the off list
20144581 281OFF_MODS += $(filter-out $(BASE_MODS) $(MOD_MODS) $(OFF_MODS),$(notdir $(DETECTED_MODS)))
712566ee 282
90b331fa 283# filesystems to be used in labeling targets
120988c4
CP
284FILESYSTEMS = $(shell mount | grep -v "context=" | egrep -v '\((|.*,)bind(,.*|)\)' | awk '/(ext[23]| xfs| jfs).*rw/{print $$3}';)
285
4ace0fa5
CP
286########################################
287#
288# Functions
289#
290
291# parse-rolemap modulename,outputfile
292define parse-rolemap
9b3756bf 293 $(verbose) m4 $(M4PARAM) $(ROLEMAP) | \
4ace0fa5
CP
294 awk '/^[[:blank:]]*[A-Za-z]/{ print "gen_require(type " $$3 "; role " $$1 ";)\n$1_per_userdomain_template(" $$2 "," $$3 "," $$1 ")" }' >> $2
295endef
296
297# peruser-expansion modulename,outputfile
298define peruser-expansion
9b3756bf 299 $(verbose) echo "ifdef(\`""$1""_per_userdomain_template',\`" > $2
4ace0fa5 300 $(call parse-rolemap,$1,$2)
9b3756bf 301 $(verbose) echo "')" >> $2
4ace0fa5
CP
302endef
303
b4cd1533
CP
304########################################
305#
fb0a3a98 306# Load appropriate rules
b4cd1533 307#
b4cd1533 308
fb0a3a98 309ifeq ($(MONOLITHIC),y)
5b45ffb0 310 include Rules.monolithic
fb0a3a98 311else
5b45ffb0 312 include Rules.modular
b4cd1533 313endif
b4cd1533 314
88d14a22
CP
315########################################
316#
fb0a3a98 317# Generated files
b4cd1533 318#
c9f20d5b
CP
319# NOTE: There is no "local" version of these files.
320#
fffba0ba
CP
321generate: $(GENERATED_TE) $(GENERATED_IF) $(GENERATED_FC)
322
f2e4ab3a 323$(MODDIR)/kernel/corenetwork.if: $(MODDIR)/kernel/corenetwork.if.m4 $(MODDIR)/kernel/corenetwork.if.in
61bbe531
CP
324 @echo "#" > $@
325 @echo "# This is a generated file! Instead of modifying this file, the" >> $@
326 @echo "# $(notdir $@).in or $(notdir $@).m4 file should be modified." >> $@
327 @echo "#" >> $@
9b3756bf
CP
328 $(verbose) cat $(MODDIR)/kernel/corenetwork.if.in >> $@
329 $(verbose) egrep "^[[:blank:]]*network_(interface|node|port)\(.*\)" $(@:.if=.te).in \
cf6141a7 330 | m4 -D self_contained_policy $(M4PARAM) $(MODDIR)/kernel/corenetwork.if.m4 - \
f2e4ab3a 331 | sed -e 's/dollarsone/\$$1/g' -e 's/dollarszero/\$$0/g' >> $@
f2e4ab3a
CP
332
333$(MODDIR)/kernel/corenetwork.te: $(MODDIR)/kernel/corenetwork.te.m4 $(MODDIR)/kernel/corenetwork.te.in
61bbe531
CP
334 @echo "#" > $@
335 @echo "# This is a generated file! Instead of modifying this file, the" >> $@
336 @echo "# $(notdir $@).in or $(notdir $@).m4 file should be modified." >> $@
337 @echo "#" >> $@
9b3756bf 338 $(verbose) m4 -D self_contained_policy $(M4PARAM) $^ \
61bbe531 339 | sed -e 's/dollarsone/\$$1/g' -e 's/dollarszero/\$$0/g' >> $@
f2e4ab3a 340
84eb353c
CP
341########################################
342#
343# Create config files
344#
4f9f30c8 345conf: $(MOD_CONF) $(BOOLEANS) $(GENERATED_TE) $(GENERATED_IF) $(GENERATED_FC)
d2d6c8ce 346
4f9f30c8
CP
347$(MOD_CONF) $(BOOLEANS): $(POLXML)
348 @echo "Updating $(MOD_CONF) and $(BOOLEANS)"
13a4943d 349 $(verbose) $(GENDOC) -b $(BOOLEANS) -m $(MOD_CONF) -x $(POLXML)
84eb353c 350
c9f20d5b
CP
351########################################
352#
353# Generate the fc_sort program
354#
355$(FCSORT) : $(SUPPORT)/fc_sort.c
fffba0ba 356 $(verbose) $(CC) $(CFLAGS) $(SUPPORT)/fc_sort.c -o $(FCSORT)
c9f20d5b 357
6d314fd3
CP
358########################################
359#
360# Documentation generation
361#
362
d2d6c8ce 363# minimal dependencies here, because we don't want to rebuild
84eb353c 364# this and its dependents every time the dependencies
19db6ba5
CP
365# change. Also use all .if files here, rather then just the
366# enabled modules.
1a7175a8 367xml: $(POLXML)
d233bfce 368$(POLXML): $(DETECTED_MODS:.te=.if) $(foreach dir,$(ALL_LAYERS),$(dir)/$(LAYERXML))
1a7175a8 369 @echo "Creating $(@F)"
c9f20d5b
CP
370 @test -d $(dir $(POLXML)) || mkdir -p $(dir $(POLXML))
371 @test -d $(TMPDIR) || mkdir -p $(TMPDIR)
9b3756bf
CP
372 $(verbose) echo '<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>' > $@
373 $(verbose) echo '<!DOCTYPE policy SYSTEM "$(notdir $(XMLDTD))">' >> $@
3d598062 374 $(verbose) $(GENXML) -m $(LAYERXML) -t $(GLOBALTUN) -b $(GLOBALBOOL) -o $(DOCS) $(ALL_LAYERS) >> $@
9b3756bf 375 $(verbose) if test -x $(XMLLINT) && test -f $(XMLDTD); then \
c9f20d5b 376 $(XMLLINT) --noout --path $(dir $(XMLDTD)) --dtdvalid $(XMLDTD) $@ ;\
004db90d 377 fi
6d314fd3 378
3d598062
CP
379$(TUNXML) $(BOOLXML): $(POLXML)
380
c9f20d5b 381html $(TMPDIR)/html: $(POLXML)
2de03f30 382 @echo "Building html interface reference documentation in $(HTMLDIR)"
c9f20d5b 383 @test -d $(HTMLDIR) || mkdir -p $(HTMLDIR)
81a18f87 384 @test -d $(TMPDIR) || mkdir -p $(TMPDIR)
0e686f1f 385 $(verbose) $(GENDOC) -d $(HTMLDIR) -T $(DOCTEMPLATE) -x $(POLXML)
9b3756bf 386 $(verbose) cp $(DOCTEMPLATE)/*.css $(HTMLDIR)
c9f20d5b 387 @touch $(TMPDIR)/html
20030ef5 388
c9a26b3e
CP
389########################################
390#
391# Runtime binary policy patching of users
392#
c9f20d5b
CP
393$(USERPATH)/system.users: $(M4SUPPORT) $(TMPDIR)/generated_definitions.conf $(USER_FILES)
394 @mkdir -p $(TMPDIR)
c9a26b3e
CP
395 @mkdir -p $(USERPATH)
396 @echo "Installing system.users"
c9f20d5b
CP
397 @echo "# " > $(TMPDIR)/system.users
398 @echo "# Do not edit this file. " >> $(TMPDIR)/system.users
399 @echo "# This file is replaced on reinstalls of this policy." >> $(TMPDIR)/system.users
400 @echo "# Please edit local.users to make local changes." >> $(TMPDIR)/system.users
401 @echo "#" >> $(TMPDIR)/system.users
9b3756bf 402 $(verbose) m4 -D self_contained_policy $(M4PARAM) $^ | sed -r -e 's/^[[:blank:]]+//' \
c9f20d5b
CP
403 -e '/^[[:blank:]]*($$|#)/d' >> $(TMPDIR)/system.users
404 $(verbose) install -m 644 $(TMPDIR)/system.users $@
c9a26b3e 405
1beba1c6 406$(USERPATH)/local.users: config/local.users
c9a26b3e
CP
407 @mkdir -p $(USERPATH)
408 @echo "Installing local.users"
9b3756bf 409 $(verbose) install -b -m 644 $< $@
c9a26b3e
CP
410
411########################################
412#
413# Appconfig files
414#
415install-appconfig: $(APPFILES)
416
4f9f30c8 417$(INSTALLDIR)/booleans: $(BOOLEANS)
c9f20d5b 418 @mkdir -p $(TMPDIR)
1beba1c6 419 @mkdir -p $(INSTALLDIR)
9b3756bf 420 $(verbose) sed -r -e 's/false/0/g' -e 's/true/1/g' \
c9f20d5b
CP
421 -e '/^[[:blank:]]*($$|#)/d' $(BOOLEANS) | sort > $(TMPDIR)/booleans
422 $(verbose) install -m 644 $(TMPDIR)/booleans $@
1beba1c6 423
2926f9c7 424$(CONTEXTPATH)/files/media: $(APPCONF)/media
1beba1c6 425 @mkdir -p $(CONTEXTPATH)/files/
9b3756bf 426 $(verbose) install -m 644 $< $@
c9a26b3e 427
2926f9c7 428$(APPDIR)/default_contexts: $(APPCONF)/default_contexts
1beba1c6 429 @mkdir -p $(APPDIR)
9b3756bf 430 $(verbose) install -m 644 $< $@
c9a26b3e 431
2926f9c7 432$(APPDIR)/removable_context: $(APPCONF)/removable_context
1beba1c6 433 @mkdir -p $(APPDIR)
9b3756bf 434 $(verbose) install -m 644 $< $@
c9a26b3e 435
2926f9c7 436$(APPDIR)/default_type: $(APPCONF)/default_type
1beba1c6 437 @mkdir -p $(APPDIR)
9b3756bf 438 $(verbose) install -m 644 $< $@
c9a26b3e 439
2926f9c7 440$(APPDIR)/userhelper_context: $(APPCONF)/userhelper_context
1beba1c6 441 @mkdir -p $(APPDIR)
9b3756bf 442 $(verbose) install -m 644 $< $@
c9a26b3e 443
2926f9c7 444$(APPDIR)/initrc_context: $(APPCONF)/initrc_context
1beba1c6 445 @mkdir -p $(APPDIR)
9b3756bf 446 $(verbose) install -m 644 $< $@
c9a26b3e 447
2926f9c7 448$(APPDIR)/failsafe_context: $(APPCONF)/failsafe_context
1beba1c6 449 @mkdir -p $(APPDIR)
9b3756bf 450 $(verbose) install -m 644 $< $@
c9a26b3e 451
2926f9c7 452$(APPDIR)/dbus_contexts: $(APPCONF)/dbus_contexts
1beba1c6 453 @mkdir -p $(APPDIR)
9b3756bf 454 $(verbose) install -m 644 $< $@
c9a26b3e 455
2926f9c7 456$(APPDIR)/users/root: $(APPCONF)/root_default_contexts
1beba1c6 457 @mkdir -p $(APPDIR)/users
9b3756bf
CP
458 $(verbose) install -m 644 $< $@
459
460########################################
461#
462# Install policy headers
463#
3d598062 464install-headers: $(TUNXML) $(BOOLXML)
120988c4 465 @mkdir -p $(HEADERDIR)
1a7175a8 466 @echo "Installing $(TYPE) policy headers."
3d598062 467 $(verbose) install -m 644 $(TUNXML) $(BOOLXML) $(HEADERDIR)
885b83ec
CP
468 $(verbose) m4 $(M4PARAM) $(ROLEMAP) > $(HEADERDIR)/$(notdir $(ROLEMAP))
469 $(verbose) mkdir -p $(HEADERDIR)/support
d6cf05b3 470 $(verbose) install -m 644 $(M4SUPPORT) $(word $(words $(GENXML)),$(GENXML)) $(XMLDTD) $(HEADERDIR)/support
885b83ec
CP
471 $(verbose) $(GENPERM) $(AVS) $(SECCLASS) > $(HEADERDIR)/support/all_perms.spt
472 $(verbose) for i in $(notdir $(ALL_LAYERS)); do \
473 mkdir -p $(HEADERDIR)/$$i ;\
474 install -m 644 $(MODDIR)/$$i/*.if \
475 $(MODDIR)/$$i/metadata.xml \
476 $(HEADERDIR)/$$i ;\
477 done
0f27d98d
CP
478 $(verbose) echo "TYPE ?= $(TYPE)" > $(HEADERDIR)/build.conf
479 $(verbose) echo "NAME ?= $(NAME)" >> $(HEADERDIR)/build.conf
885b83ec 480ifneq "$(DISTRO)" ""
0f27d98d 481 $(verbose) echo "DISTRO ?= $(DISTRO)" >> $(HEADERDIR)/build.conf
885b83ec 482endif
0f27d98d
CP
483 $(verbose) echo "MONOLITHIC ?= n" >> $(HEADERDIR)/build.conf
484 $(verbose) echo "DIRECT_INITRC ?= $(DIRECT_INITRC)" >> $(HEADERDIR)/build.conf
485 $(verbose) echo "POLY ?= $(POLY)" >> $(HEADERDIR)/build.conf
885b83ec 486 $(verbose) install -m 644 $(SUPPORT)/Makefile.devel $(HEADERDIR)/Makefile
c9a26b3e 487
120988c4
CP
488########################################
489#
490# Install policy documentation
491#
c9f20d5b 492install-docs: $(TMPDIR)/html
120988c4
CP
493 @mkdir -p $(DOCSDIR)/html
494 @echo "Installing policy documentation"
5bd1a703 495 $(verbose) install -m 644 $(DOCFILES) $(DOCSDIR)
120988c4
CP
496 $(verbose) install -m 644 $(wildcard $(HTMLDIR)/*) $(DOCSDIR)/html
497
c592e52e
CP
498########################################
499#
500# Install policy sources
501#
502install-src:
503 rm -rf $(SRCPATH)/policy.old
504 -mv $(SRCPATH)/policy $(SRCPATH)/policy.old
505 mkdir -p $(SRCPATH)/policy
506 cp -R . $(SRCPATH)/policy
507
37227dcd
CP
508########################################
509#
510# Generate tags file
511#
c9f20d5b
CP
512tags: $(TAGS)
513$(TAGS):
37227dcd 514 @($(CTAGS) --version | grep -q Exuberant) || (echo ERROR: Need exuberant-ctags to function!; exit 1)
c9f20d5b 515 @LC_ALL=C $(CTAGS) -f $(TAGS) --langdef=te --langmap=te:..te.if.spt \
37227dcd
CP
516 --regex-te='/^type[ \t]+(\w+)(,|;)/\1/t,type/' \
517 --regex-te='/^typealias[ \t]+\w+[ \t+]+alias[ \t]+(\w+);/\1/t,type/' \
518 --regex-te='/^attribute[ \t]+(\w+);/\1/a,attribute/' \
519 --regex-te='/^[ \t]*define\(`(\w+)/\1/d,define/' \
520 --regex-te='/^[ \t]*interface\(`(\w+)/\1/i,interface/' \
521 --regex-te='/^[ \t]*bool[ \t]+(\w+)/\1/b,bool/' policy/modules/*/*.{if,te} policy/support/*.spt
522
120988c4
CP
523########################################
524#
525# Filesystem labeling
526#
527checklabels:
528 @echo "Checking labels on filesystem types: ext2 ext3 xfs jfs"
529 @if test -z "$(FILESYSTEMS)"; then \
530 echo "No filesystems with extended attributes found!" ;\
531 false ;\
532 fi
533 $(verbose) $(SETFILES) -v -n $(FCPATH) $(FILESYSTEMS)
534
535restorelabels:
536 @echo "Restoring labels on filesystem types: ext2 ext3 xfs jfs"
537 @if test -z "$(FILESYSTEMS)"; then \
538 echo "No filesystems with extended attributes found!" ;\
539 false ;\
540 fi
541 $(verbose) $(SETFILES) -v $(FCPATH) $(FILESYSTEMS)
542
543relabel:
544 @echo "Relabeling filesystem types: ext2 ext3 xfs jfs"
545 @if test -z "$(FILESYSTEMS)"; then \
546 echo "No filesystems with extended attributes found!" ;\
547 false ;\
548 fi
549 $(verbose) $(SETFILES) $(FCPATH) $(FILESYSTEMS)
550
551resetlabels:
552 @echo "Resetting labels on filesystem types: ext2 ext3 xfs jfs"
553 @if test -z "$(FILESYSTEMS)"; then \
554 echo "No filesystems with extended attributes found!" ;\
555 false ;\
556 fi
557 $(verbose) $(SETFILES) -F $(FCPATH) $(FILESYSTEMS)
558
102a59ba
CP
559########################################
560#
561# Clean everything
562#
0fbe15dc 563bare: clean
12b559a4 564 rm -f $(POLXML)
3d598062
CP
565 rm -f $(TUNXML)
566 rm -f $(BOOLXML)
19db6ba5 567 rm -f $(MOD_CONF)
4f9f30c8 568 rm -f $(BOOLEANS)
20030ef5 569 rm -fR $(HTMLDIR)
c9f20d5b
CP
570 rm -f $(TAGS)
571# don't remove these files if we're given a local root
572ifndef LOCAL_ROOT
573 rm -f $(FCSORT)
574 rm -f $(SUPPORT)/*.pyc
c767b14c
CP
575ifneq ($(GENERATED_TE),)
576 rm -f $(GENERATED_TE)
577endif
578ifneq ($(GENERATED_IF),)
579 rm -f $(GENERATED_IF)
580endif
581ifneq ($(GENERATED_FC),)
582 rm -f $(GENERATED_FC)
583endif
c9f20d5b 584endif
0fbe15dc 585
1a7175a8 586.PHONY: install-src install-appconfig generate xml conf html bare tags
b8c79823
CP
587.SUFFIXES:
588.SUFFIXES: .c