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