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