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