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