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