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