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