]> git.ipfire.org Git - people/stevee/selinux-policy.git/blame - Makefile
forgot to bump policy vers
[people/stevee/selinux-policy.git] / 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 34# refpolicy version
c634db20 35version = $(shell cat VERSION)
120988c4 36
c9f20d5b 37ifdef LOCAL_ROOT
c634db20
CP
38builddir := $(LOCAL_ROOT)/
39tmpdir := $(LOCAL_ROOT)/tmp
40tags := $(LOCAL_ROOT)/tags
c9f20d5b 41else
c634db20
CP
42tmpdir := tmp
43tags := tags
c9f20d5b
CP
44endif
45
b4cd1533 46# executable paths
906f1084
CP
47BINDIR ?= /usr/bin
48SBINDIR ?= /usr/sbin
e2ae0861 49ifdef TEST_TOOLCHAIN
75beb950
CP
50tc_usrbindir := env LD_LIBRARY_PATH="$(TEST_TOOLCHAIN)/lib" $(TEST_TOOLCHAIN)$(BINDIR)
51tc_usrsbindir := env LD_LIBRARY_PATH="$(TEST_TOOLCHAIN)/lib" $(TEST_TOOLCHAIN)$(SBINDIR)
52tc_sbindir := env LD_LIBRARY_PATH="$(TEST_TOOLCHAIN)/lib" $(TEST_TOOLCHAIN)/sbin
e2ae0861 53else
75beb950
CP
54tc_usrbindir := $(BINDIR)
55tc_usrsbindir := $(SBINDIR)
56tc_sbindir := /sbin
e2ae0861 57endif
75beb950
CP
58CHECKPOLICY ?= $(tc_usrbindir)/checkpolicy
59CHECKMODULE ?= $(tc_usrbindir)/checkmodule
60SEMODULE ?= $(tc_usrsbindir)/semodule
61SEMOD_PKG ?= $(tc_usrbindir)/semodule_package
62SEMOD_LNK ?= $(tc_usrbindir)/semodule_link
63SEMOD_EXP ?= $(tc_usrbindir)/semodule_expand
64LOADPOLICY ?= $(tc_usrsbindir)/load_policy
e2ae0861 65SETFILES ?= $(tc_sbindir)/setfiles
906f1084
CP
66XMLLINT ?= $(BINDIR)/xmllint
67SECHECK ?= $(BINDIR)/sechecker
0447352a 68
0e686f1f
CP
69# interpreters and aux tools
70AWK ?= gawk
71GREP ?= egrep
cfd5c5e1 72INSTALL ?= install
0e686f1f
CP
73M4 ?= m4
74PYTHON ?= python
75SED ?= sed
f62f4c79 76SORT ?= LC_ALL=C sort
0e686f1f
CP
77
78CFLAGS += -Wall
c7b41e95 79
fb0a3a98 80# policy source layout
c634db20
CP
81poldir := policy
82moddir := $(poldir)/modules
83flaskdir := $(poldir)/flask
84secclass := $(flaskdir)/security_classes
85isids := $(flaskdir)/initial_sids
86avs := $(flaskdir)/access_vectors
fb0a3a98 87
c9f20d5b
CP
88# local source layout
89ifdef LOCAL_ROOT
c634db20
CP
90local_poldir := $(LOCAL_ROOT)/policy
91local_moddir := $(local_poldir)/modules
c9f20d5b
CP
92endif
93
fb0a3a98 94# policy building support tools
c634db20
CP
95support := support
96genxml := $(PYTHON) $(support)/segenxml.py
97gendoc := $(PYTHON) $(support)/sedoctool.py
98genperm := $(PYTHON) $(support)/genclassperms.py
99fcsort := $(tmpdir)/fc_sort
100setbools := $(AWK) -f $(support)/set_bools_tuns.awk
101get_type_attr_decl := $(SED) -r -f $(support)/get_type_attr_decl.sed
102comment_move_decl := $(SED) -r -f $(support)/comment_move_decl.sed
103gennetfilter := $(PYTHON) $(support)/gennetfilter.py
fc47b34c
CP
104# use our own genhomedircon to make sure we have a known usable one,
105# so policycoreutils updates are not required (RHEL4)
c634db20 106genhomedircon := $(PYTHON) $(support)/genhomedircon
3a80ec29 107
fb0a3a98 108# documentation paths
c634db20
CP
109docs := doc
110xmldtd = $(docs)/policy.dtd
111layerxml = metadata.xml
112doctemplate = $(docs)/templates
113docfiles = $(docs)/Makefile.example $(addprefix $(docs)/,example.te example.if example.fc)
fb0a3a98 114
c9f20d5b 115ifndef LOCAL_ROOT
c634db20
CP
116polxml = $(docs)/policy.xml
117tunxml = $(docs)/global_tunables.xml
118boolxml = $(docs)/global_booleans.xml
119htmldir = $(docs)/html
c9f20d5b 120else
c634db20
CP
121polxml = $(LOCAL_ROOT)/doc/policy.xml
122tunxml = $(LOCAL_ROOT)/doc/global_tunables.xml
123boolxml = $(LOCAL_ROOT)/doc/global_booleans.xml
124htmldir = $(LOCAL_ROOT)/doc/html
c9f20d5b
CP
125endif
126
fb0a3a98 127# config file paths
c634db20
CP
128globaltun = $(poldir)/global_tunables
129globalbool = $(poldir)/global_booleans
130rolemap = $(poldir)/rolemap
131user_files := $(poldir)/users
fb0a3a98 132
c9f20d5b
CP
133# local config file paths
134ifndef LOCAL_ROOT
c634db20
CP
135mod_conf = $(poldir)/modules.conf
136booleans = $(poldir)/booleans.conf
137tunables = $(poldir)/tunables.conf
c9f20d5b 138else
c634db20
CP
139mod_conf = $(local_poldir)/modules.conf
140booleans = $(local_poldir)/booleans.conf
141tunables = $(local_poldir)/tunables.conf
c9f20d5b
CP
142endif
143
fb0a3a98 144# install paths
c634db20
CP
145PKGNAME ?= refpolicy-$(version)
146prefix = $(DESTDIR)/usr
147topdir = $(DESTDIR)/etc/selinux
148installdir = $(topdir)/$(strip $(NAME))
149srcpath = $(installdir)/src
150userpath = $(installdir)/users
151contextpath = $(installdir)/contexts
152fcpath = $(contextpath)/files/file_contexts
153ncpath = $(contextpath)/netfilter_contexts
154sharedir = $(prefix)/share/selinux
155modpkgdir = $(sharedir)/$(strip $(NAME))
156headerdir = $(modpkgdir)/include
157docsdir = $(prefix)/share/doc/$(PKGNAME)
c767b14c
CP
158
159# compile strict policy if requested.
160ifneq ($(findstring strict,$(TYPE)),)
3f026a90 161 M4PARAM += -D strict_policy
c767b14c
CP
162endif
163
164# compile targeted policy if requested.
165ifneq ($(findstring targeted,$(TYPE)),)
3f026a90 166 M4PARAM += -D targeted_policy
c767b14c 167endif
b4cd1533 168
134191be 169# enable MLS if requested.
a0824843 170ifneq ($(findstring -mls,$(TYPE)),)
3f026a90
CP
171 M4PARAM += -D enable_mls
172 CHECKPOLICY += -M
173 CHECKMODULE += -M
6962bb32 174 gennetfilter += -m
134191be
CP
175endif
176
a0824843
CP
177# enable MLS if MCS requested.
178ifneq ($(findstring -mcs,$(TYPE)),)
3f026a90
CP
179 M4PARAM += -D enable_mcs
180 CHECKPOLICY += -M
181 CHECKMODULE += -M
6962bb32 182 gennetfilter += -c
b67488e3
CP
183endif
184
25a0c61f
CP
185# enable distribution-specific policy
186ifneq ($(DISTRO),)
3f026a90 187 M4PARAM += -D distro_$(DISTRO)
25a0c61f
CP
188endif
189
2f1a8fbc
CP
190# rhel4 also implies redhat
191ifeq "$(DISTRO)" "rhel4"
192 M4PARAM += -D distro_redhat
193endif
194
b07eaef9
CP
195# enable polyinstantiation
196ifeq ($(POLY),y)
3f026a90 197 M4PARAM += -D enable_polyinstantiation
b07eaef9
CP
198endif
199
b67488e3 200ifneq ($(OUTPUT_POLICY),)
3f026a90 201 CHECKPOLICY += -c $(OUTPUT_POLICY)
b67488e3
CP
202endif
203
3f026a90
CP
204# if not set, use the type as the name.
205NAME ?= $(TYPE)
134191be 206
142e9f40 207ifeq ($(DIRECT_INITRC),y)
3f026a90 208 M4PARAM += -D direct_sysadm_daemon
142e9f40
CP
209endif
210
9b3756bf
CP
211ifeq ($(QUIET),y)
212 verbose = @
213endif
214
3f026a90 215M4PARAM += -D hide_broken_symptoms
ee7f66b0 216
37227dcd
CP
217# we need exuberant ctags; unfortunately it is named
218# differently on different distros
219ifeq ($(DISTRO),debian)
220 CTAGS := ctags-exuberant
221endif
222
223ifeq ($(DISTRO),gentoo)
224 CTAGS := exuberant-ctags
225endif
226
a4fae7fa 227CTAGS ?= ctags
37227dcd 228
c634db20 229m4support := $(wildcard $(poldir)/support/*.spt)
20144581 230ifdef LOCAL_ROOT
c634db20 231m4support += $(wildcard $(local_poldir)/support/*.spt)
20144581 232endif
0fbe15dc 233
c634db20
CP
234appconf := config/appconfig-$(TYPE)
235seusers := $(appconf)/seusers
236appdir := $(contextpath)
237appfiles := $(addprefix $(appdir)/,default_contexts default_type initrc_context failsafe_context userhelper_context removable_context dbus_contexts customizable_types) $(contextpath)/files/media
238net_contexts := $(builddir)net_contexts
c9a26b3e 239
c634db20 240all_layers := $(filter-out $(moddir)/CVS,$(shell find $(wildcard $(moddir)/*) -maxdepth 0 -type d))
c9f20d5b 241ifdef LOCAL_ROOT
c634db20 242all_layers += $(filter-out $(local_moddir)/CVS,$(shell find $(wildcard $(local_moddir)/*) -maxdepth 0 -type d))
c9f20d5b 243endif
e12e5738 244
c634db20
CP
245generated_te := $(basename $(foreach dir,$(all_layers),$(wildcard $(dir)/*.te.in)))
246generated_if := $(basename $(foreach dir,$(all_layers),$(wildcard $(dir)/*.if.in)))
247generated_fc := $(basename $(foreach dir,$(all_layers),$(wildcard $(dir)/*.fc.in)))
e12e5738 248
8ae194f6
CP
249# sort here since it removes duplicates, which can happen
250# when a generated file is already generated
c634db20 251detected_mods := $(sort $(foreach dir,$(all_layers),$(wildcard $(dir)/*.te)) $(generated_te))
19db6ba5 252
fb0a3a98 253# modules.conf setting for base module
c634db20 254configbase := base
fb0a3a98 255
e0a9001b 256# modules.conf setting for loadable module
c634db20 257configmod := module
fb0a3a98 258
e0a9001b 259# modules.conf setting for unused module
c634db20 260configoff := off
e0a9001b 261
c9f20d5b 262# test for module overrides from command line
c634db20
CP
263mod_test = $(filter $(APPS_OFF), $(APPS_BASE) $(APPS_MODS))
264mod_test += $(filter $(APPS_MODS), $(APPS_BASE))
265ifneq "$(strip $(mod_test))" ""
266 $(error Applications must be base, module, or off, and not in more than one list! $(strip $(mod_test)) found in multiple lists!)
c9f20d5b
CP
267endif
268
20144581 269# add on suffix to modules specified on command line
c634db20
CP
270cmdline_base := $(addsuffix .te,$(APPS_BASE))
271cmdline_mods := $(addsuffix .te,$(APPS_MODS))
272cmdline_off := $(addsuffix .te,$(APPS_OFF))
20144581 273
fb0a3a98 274# extract settings from modules.conf
c634db20
CP
275mod_conf_base := $(addsuffix .te,$(sort $(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(configbase)") print $$1 }' $(mod_conf) 2> /dev/null)))
276mod_conf_mods := $(addsuffix .te,$(sort $(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(configmod)") print $$1 }' $(mod_conf) 2> /dev/null)))
277mod_conf_off := $(addsuffix .te,$(sort $(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(configoff)") print $$1 }' $(mod_conf) 2> /dev/null)))
20144581 278
c634db20
CP
279base_mods := $(cmdline_base)
280mod_mods := $(cmdline_mods)
281off_mods := $(cmdline_off)
87e73c5f 282
c634db20
CP
283base_mods += $(filter-out $(cmdline_off) $(cmdline_base) $(cmdline_mods), $(mod_conf_base))
284mod_mods += $(filter-out $(cmdline_off) $(cmdline_base) $(cmdline_mods), $(mod_conf_mods))
285off_mods += $(filter-out $(cmdline_off) $(cmdline_base) $(cmdline_mods), $(mod_conf_off))
87e73c5f
CP
286
287# add modules not in modules.conf to the off list
c634db20 288off_mods += $(filter-out $(base_mods) $(mod_mods) $(off_mods),$(notdir $(detected_mods)))
712566ee 289
90b331fa 290# filesystems to be used in labeling targets
c634db20 291filesystems = $(shell mount | grep -v "context=" | egrep -v '\((|.*,)bind(,.*|)\)' | awk '/(ext[23]| xfs| jfs).*rw/{print $$3}';)
120988c4 292
4ace0fa5
CP
293########################################
294#
295# Functions
296#
297
bbcd3c97
CP
298# parse-rolemap-compat modulename,outputfile
299define parse-rolemap-compat
300 $(verbose) $(M4) $(M4PARAM) $(rolemap) | \
301 $(AWK) '/^[[:blank:]]*[A-Za-z]/{ print "gen_require(type " $$3 "; role " $$1 ";)\n$1_per_userdomain_template(" $$2 "," $$3 "," $$1 ")" }' >> $2
302endef
303
4ace0fa5
CP
304# parse-rolemap modulename,outputfile
305define parse-rolemap
c634db20 306 $(verbose) $(M4) $(M4PARAM) $(rolemap) | \
bbcd3c97 307 $(AWK) '/^[[:blank:]]*[A-Za-z]/{ print "gen_require(type " $$3 "; role " $$1 ";)\n$1_per_role_template(" $$2 "," $$3 "," $$1 ")" }' >> $2
4ace0fa5
CP
308endef
309
bbcd3c97
CP
310# perrole-expansion modulename,outputfile
311define perrole-expansion
312 $(verbose) echo "ifdef(\`""$1""_per_role_template',\`" > $2
4ace0fa5 313 $(call parse-rolemap,$1,$2)
9b3756bf 314 $(verbose) echo "')" >> $2
bbcd3c97
CP
315
316 $(verbose) echo "ifdef(\`""$1""_per_userdomain_template',\`" >> $2
317 $(verbose) echo "errprint(\`Warning: per_userdomain_templates have been renamed to per_role_templates (""$1""_per_userdomain_template)'__endline__)" >> $2
318 $(call parse-rolemap-compat,$1,$2)
319 $(verbose) echo "')" >> $2
320endef
321
322# create-base-per-role-tmpl modulenames,outputfile
323define create-base-per-role-tmpl
324 $(verbose) echo "define(\`base_per_role_template',\`" >> $2
325
326 $(verbose) for i in $1; do \
327 echo "ifdef(\`""$$i""_per_role_template',\`""$$i""_per_role_template("'$$*'")')" \
328 >> $2 ;\
329 done
330
331 $(verbose) for i in $1; do \
332 echo "ifdef(\`""$$i""_per_userdomain_template',\`" >> $2 ;\
333 echo "errprint(\`Warning: per_userdomain_templates have been renamed to per_role_templates (""$$i""_per_userdomain_template)'__endline__)" >> $2 ;\
334 echo """$$i""_per_userdomain_template("'$$*'")')" >> $2 ;\
335 done
336 $(verbose) echo "')" >> $@
337
4ace0fa5
CP
338endef
339
b4cd1533
CP
340########################################
341#
fb0a3a98 342# Load appropriate rules
b4cd1533 343#
b4cd1533 344
fb0a3a98 345ifeq ($(MONOLITHIC),y)
5b45ffb0 346 include Rules.monolithic
fb0a3a98 347else
5b45ffb0 348 include Rules.modular
b4cd1533 349endif
b4cd1533 350
88d14a22
CP
351########################################
352#
fb0a3a98 353# Generated files
b4cd1533 354#
c9f20d5b
CP
355# NOTE: There is no "local" version of these files.
356#
c634db20 357generate: $(generated_te) $(generated_if) $(generated_fc)
fffba0ba 358
686f11c2 359$(moddir)/kernel/corenetwork.if: $(moddir)/kernel/corenetwork.te.in $(moddir)/kernel/corenetwork.if.m4 $(moddir)/kernel/corenetwork.if.in
61bbe531
CP
360 @echo "#" > $@
361 @echo "# This is a generated file! Instead of modifying this file, the" >> $@
362 @echo "# $(notdir $@).in or $(notdir $@).m4 file should be modified." >> $@
363 @echo "#" >> $@
686f11c2
CP
364 $(verbose) cat $@.in >> $@
365 $(verbose) $(GREP) "^[[:blank:]]*network_(interface|node|port|packet)\(.*\)" $< \
366 | $(M4) -D self_contained_policy $(M4PARAM) $@.m4 - \
cfd5c5e1 367 | $(SED) -e 's/dollarsone/\$$1/g' -e 's/dollarszero/\$$0/g' >> $@
f2e4ab3a 368
c634db20 369$(moddir)/kernel/corenetwork.te: $(moddir)/kernel/corenetwork.te.m4 $(moddir)/kernel/corenetwork.te.in
61bbe531
CP
370 @echo "#" > $@
371 @echo "# This is a generated file! Instead of modifying this file, the" >> $@
372 @echo "# $(notdir $@).in or $(notdir $@).m4 file should be modified." >> $@
373 @echo "#" >> $@
cfd5c5e1
CP
374 $(verbose) $(M4) -D self_contained_policy $(M4PARAM) $^ \
375 | $(SED) -e 's/dollarsone/\$$1/g' -e 's/dollarszero/\$$0/g' >> $@
f2e4ab3a 376
6962bb32
CP
377########################################
378#
379# Network packet labeling
380#
c634db20 381$(net_contexts): $(moddir)/kernel/corenetwork.te.in
6962bb32
CP
382 @echo "Creating netfilter network labeling rules"
383 $(verbose) $(gennetfilter) $^ > $@
384
84eb353c
CP
385########################################
386#
387# Create config files
388#
c634db20 389conf: $(mod_conf) $(booleans) $(generated_te) $(generated_if) $(generated_fc)
d2d6c8ce 390
c634db20
CP
391$(mod_conf) $(booleans): $(polxml)
392 @echo "Updating $(mod_conf) and $(booleans)"
393 $(verbose) $(gendoc) -b $(booleans) -m $(mod_conf) -x $(polxml)
84eb353c 394
c9f20d5b
CP
395########################################
396#
397# Generate the fc_sort program
398#
c634db20
CP
399$(fcsort) : $(support)/fc_sort.c
400 $(verbose) $(CC) $(CFLAGS) $(support)/fc_sort.c -o $(fcsort)
c9f20d5b 401
6d314fd3
CP
402########################################
403#
404# Documentation generation
405#
406
d2d6c8ce 407# minimal dependencies here, because we don't want to rebuild
84eb353c 408# this and its dependents every time the dependencies
19db6ba5
CP
409# change. Also use all .if files here, rather then just the
410# enabled modules.
c634db20
CP
411xml: $(polxml)
412$(polxml): $(detected_mods:.te=.if) $(foreach dir,$(all_layers),$(dir)/$(layerxml))
1a7175a8 413 @echo "Creating $(@F)"
c634db20
CP
414 @test -d $(dir $(polxml)) || mkdir -p $(dir $(polxml))
415 @test -d $(tmpdir) || mkdir -p $(tmpdir)
9b3756bf 416 $(verbose) echo '<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>' > $@
c634db20
CP
417 $(verbose) echo '<!DOCTYPE policy SYSTEM "$(notdir $(xmldtd))">' >> $@
418 $(verbose) $(genxml) -w -m $(layerxml) -t $(globaltun) -b $(globalbool) -o $(docs) $(all_layers) >> $@
419 $(verbose) if test -x $(XMLLINT) && test -f $(xmldtd); then \
420 $(XMLLINT) --noout --path $(dir $(xmldtd)) --dtdvalid $(xmldtd) $@ ;\
004db90d 421 fi
6d314fd3 422
c634db20 423$(tunxml) $(boolxml): $(polxml)
3d598062 424
c634db20
CP
425html $(tmpdir)/html: $(polxml)
426 @echo "Building html interface reference documentation in $(htmldir)"
427 @test -d $(htmldir) || mkdir -p $(htmldir)
428 @test -d $(tmpdir) || mkdir -p $(tmpdir)
429 $(verbose) $(gendoc) -d $(htmldir) -T $(doctemplate) -x $(polxml)
430 $(verbose) cp $(doctemplate)/*.css $(htmldir)
431 @touch $(tmpdir)/html
20030ef5 432
c9a26b3e
CP
433########################################
434#
435# Runtime binary policy patching of users
436#
c634db20
CP
437$(userpath)/system.users: $(m4support) $(tmpdir)/generated_definitions.conf $(user_files)
438 @mkdir -p $(tmpdir)
439 @mkdir -p $(userpath)
c9a26b3e 440 @echo "Installing system.users"
c634db20
CP
441 @echo "# " > $(tmpdir)/system.users
442 @echo "# Do not edit this file. " >> $(tmpdir)/system.users
443 @echo "# This file is replaced on reinstalls of this policy." >> $(tmpdir)/system.users
444 @echo "# Please edit local.users to make local changes." >> $(tmpdir)/system.users
445 @echo "#" >> $(tmpdir)/system.users
cfd5c5e1 446 $(verbose) $(M4) -D self_contained_policy $(M4PARAM) $^ | $(SED) -r -e 's/^[[:blank:]]+//' \
c634db20
CP
447 -e '/^[[:blank:]]*($$|#)/d' >> $(tmpdir)/system.users
448 $(verbose) $(INSTALL) -m 644 $(tmpdir)/system.users $@
c9a26b3e 449
c634db20
CP
450$(userpath)/local.users: config/local.users
451 @mkdir -p $(userpath)
c9a26b3e 452 @echo "Installing local.users"
cfd5c5e1 453 $(verbose) $(INSTALL) -b -m 644 $< $@
c9a26b3e
CP
454
455########################################
456#
457# Appconfig files
458#
c634db20 459install-appconfig: $(appfiles)
c9a26b3e 460
c634db20
CP
461$(installdir)/booleans: $(booleans)
462 @mkdir -p $(tmpdir)
463 @mkdir -p $(installdir)
cfd5c5e1 464 $(verbose) $(SED) -r -e 's/false/0/g' -e 's/true/1/g' \
c634db20
CP
465 -e '/^[[:blank:]]*($$|#)/d' $(booleans) | $(SORT) > $(tmpdir)/booleans
466 $(verbose) $(INSTALL) -m 644 $(tmpdir)/booleans $@
1beba1c6 467
c634db20
CP
468$(contextpath)/files/media: $(appconf)/media
469 @mkdir -p $(contextpath)/files/
cfd5c5e1 470 $(verbose) $(INSTALL) -m 644 $< $@
c9a26b3e 471
c634db20
CP
472$(appdir)/default_contexts: $(appconf)/default_contexts
473 @mkdir -p $(appdir)
cfd5c5e1 474 $(verbose) $(INSTALL) -m 644 $< $@
c9a26b3e 475
c634db20
CP
476$(appdir)/removable_context: $(appconf)/removable_context
477 @mkdir -p $(appdir)
cfd5c5e1 478 $(verbose) $(INSTALL) -m 644 $< $@
c9a26b3e 479
c634db20
CP
480$(appdir)/default_type: $(appconf)/default_type
481 @mkdir -p $(appdir)
cfd5c5e1 482 $(verbose) $(INSTALL) -m 644 $< $@
c9a26b3e 483
c634db20
CP
484$(appdir)/userhelper_context: $(appconf)/userhelper_context
485 @mkdir -p $(appdir)
cfd5c5e1 486 $(verbose) $(INSTALL) -m 644 $< $@
c9a26b3e 487
c634db20
CP
488$(appdir)/initrc_context: $(appconf)/initrc_context
489 @mkdir -p $(appdir)
cfd5c5e1 490 $(verbose) $(INSTALL) -m 644 $< $@
c9a26b3e 491
c634db20
CP
492$(appdir)/failsafe_context: $(appconf)/failsafe_context
493 @mkdir -p $(appdir)
cfd5c5e1 494 $(verbose) $(INSTALL) -m 644 $< $@
c9a26b3e 495
c634db20
CP
496$(appdir)/dbus_contexts: $(appconf)/dbus_contexts
497 @mkdir -p $(appdir)
cfd5c5e1 498 $(verbose) $(INSTALL) -m 644 $< $@
c9a26b3e 499
c634db20
CP
500$(appdir)/users/root: $(appconf)/root_default_contexts
501 @mkdir -p $(appdir)/users
cfd5c5e1 502 $(verbose) $(INSTALL) -m 644 $< $@
9b3756bf
CP
503
504########################################
505#
506# Install policy headers
507#
c634db20
CP
508install-headers: $(tunxml) $(boolxml)
509 @mkdir -p $(headerdir)
1a7175a8 510 @echo "Installing $(TYPE) policy headers."
c634db20
CP
511 $(verbose) $(INSTALL) -m 644 $(tunxml) $(boolxml) $(headerdir)
512 $(verbose) $(M4) $(M4PARAM) $(rolemap) > $(headerdir)/$(notdir $(rolemap))
513 $(verbose) mkdir -p $(headerdir)/support
514 $(verbose) $(INSTALL) -m 644 $(m4support) $(word $(words $(genxml)),$(genxml)) $(xmldtd) $(headerdir)/support
515 $(verbose) $(genperm) $(avs) $(secclass) > $(headerdir)/support/all_perms.spt
516 $(verbose) for i in $(notdir $(all_layers)); do \
517 mkdir -p $(headerdir)/$$i ;\
518 $(INSTALL) -m 644 $(moddir)/$$i/*.if \
519 $(moddir)/$$i/metadata.xml \
520 $(headerdir)/$$i ;\
885b83ec 521 done
c634db20
CP
522 $(verbose) echo "TYPE ?= $(TYPE)" > $(headerdir)/build.conf
523 $(verbose) echo "NAME ?= $(NAME)" >> $(headerdir)/build.conf
885b83ec 524ifneq "$(DISTRO)" ""
c634db20 525 $(verbose) echo "DISTRO ?= $(DISTRO)" >> $(headerdir)/build.conf
885b83ec 526endif
c634db20
CP
527 $(verbose) echo "MONOLITHIC ?= n" >> $(headerdir)/build.conf
528 $(verbose) echo "DIRECT_INITRC ?= $(DIRECT_INITRC)" >> $(headerdir)/build.conf
529 $(verbose) echo "POLY ?= $(POLY)" >> $(headerdir)/build.conf
530 $(verbose) $(INSTALL) -m 644 $(support)/Makefile.devel $(headerdir)/Makefile
c9a26b3e 531
120988c4
CP
532########################################
533#
534# Install policy documentation
535#
c634db20
CP
536install-docs: $(tmpdir)/html
537 @mkdir -p $(docsdir)/html
120988c4 538 @echo "Installing policy documentation"
c634db20
CP
539 $(verbose) $(INSTALL) -m 644 $(docfiles) $(docsdir)
540 $(verbose) $(INSTALL) -m 644 $(wildcard $(htmldir)/*) $(docsdir)/html
120988c4 541
c592e52e
CP
542########################################
543#
544# Install policy sources
545#
546install-src:
c634db20
CP
547 rm -rf $(srcpath)/policy.old
548 -mv $(srcpath)/policy $(srcpath)/policy.old
549 mkdir -p $(srcpath)/policy
550 cp -R . $(srcpath)/policy
c592e52e 551
37227dcd
CP
552########################################
553#
554# Generate tags file
555#
c634db20
CP
556tags: $(tags)
557$(tags):
37227dcd 558 @($(CTAGS) --version | grep -q Exuberant) || (echo ERROR: Need exuberant-ctags to function!; exit 1)
c634db20 559 @LC_ALL=C $(CTAGS) -f $(tags) --langdef=te --langmap=te:..te.if.spt \
37227dcd
CP
560 --regex-te='/^type[ \t]+(\w+)(,|;)/\1/t,type/' \
561 --regex-te='/^typealias[ \t]+\w+[ \t+]+alias[ \t]+(\w+);/\1/t,type/' \
562 --regex-te='/^attribute[ \t]+(\w+);/\1/a,attribute/' \
563 --regex-te='/^[ \t]*define\(`(\w+)/\1/d,define/' \
564 --regex-te='/^[ \t]*interface\(`(\w+)/\1/i,interface/' \
565 --regex-te='/^[ \t]*bool[ \t]+(\w+)/\1/b,bool/' policy/modules/*/*.{if,te} policy/support/*.spt
566
120988c4
CP
567########################################
568#
569# Filesystem labeling
570#
571checklabels:
572 @echo "Checking labels on filesystem types: ext2 ext3 xfs jfs"
c634db20 573 @if test -z "$(filesystems)"; then \
120988c4
CP
574 echo "No filesystems with extended attributes found!" ;\
575 false ;\
576 fi
c634db20 577 $(verbose) $(SETFILES) -v -n $(fcpath) $(filesystems)
120988c4
CP
578
579restorelabels:
580 @echo "Restoring labels on filesystem types: ext2 ext3 xfs jfs"
c634db20 581 @if test -z "$(filesystems)"; then \
120988c4
CP
582 echo "No filesystems with extended attributes found!" ;\
583 false ;\
584 fi
c634db20 585 $(verbose) $(SETFILES) -v $(fcpath) $(filesystems)
120988c4
CP
586
587relabel:
588 @echo "Relabeling filesystem types: ext2 ext3 xfs jfs"
c634db20 589 @if test -z "$(filesystems)"; then \
120988c4
CP
590 echo "No filesystems with extended attributes found!" ;\
591 false ;\
592 fi
c634db20 593 $(verbose) $(SETFILES) $(fcpath) $(filesystems)
120988c4
CP
594
595resetlabels:
596 @echo "Resetting labels on filesystem types: ext2 ext3 xfs jfs"
c634db20 597 @if test -z "$(filesystems)"; then \
120988c4
CP
598 echo "No filesystems with extended attributes found!" ;\
599 false ;\
600 fi
c634db20 601 $(verbose) $(SETFILES) -F $(fcpath) $(filesystems)
120988c4 602
102a59ba
CP
603########################################
604#
605# Clean everything
606#
0fbe15dc 607bare: clean
c634db20
CP
608 rm -f $(polxml)
609 rm -f $(tunxml)
610 rm -f $(boolxml)
611 rm -f $(mod_conf)
612 rm -f $(booleans)
613 rm -fR $(htmldir)
614 rm -f $(tags)
c9f20d5b
CP
615# don't remove these files if we're given a local root
616ifndef LOCAL_ROOT
c634db20
CP
617 rm -f $(fcsort)
618 rm -f $(support)/*.pyc
619ifneq ($(generated_te),)
620 rm -f $(generated_te)
c767b14c 621endif
c634db20
CP
622ifneq ($(generated_if),)
623 rm -f $(generated_if)
c767b14c 624endif
c634db20
CP
625ifneq ($(generated_fc),)
626 rm -f $(generated_fc)
c767b14c 627endif
c9f20d5b 628endif
0fbe15dc 629
1a7175a8 630.PHONY: install-src install-appconfig generate xml conf html bare tags
b8c79823
CP
631.SUFFIXES:
632.SUFFIXES: .c