File: Make.rules

package info (click to toggle)
apparmor 2.13.2-10
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 28,404 kB
  • sloc: python: 19,093; ansic: 17,037; perl: 11,105; sh: 10,442; cpp: 5,323; yacc: 1,933; makefile: 1,679; pascal: 1,097; lex: 1,088; ruby: 374; exp: 250; java: 212; xml: 159
file content (171 lines) | stat: -rw-r--r-- 5,567 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# ------------------------------------------------------------------
#
#    Copyright (C) 2002-2005 Novell/SUSE
#    Copyright (C) 2010-2015 Canonical, Ltd.
#
#    This program is free software; you can redistribute it and/or
#    modify it under the terms of version 2 of the GNU General Public 
#    License published by the Free Software Foundation.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, contact Novell, Inc.
# ------------------------------------------------------------------
# Make.rules - common make targets and variables for building AppArmor
#
# NOTES:
#   Before including this file in your Makefile, you should
#   - define COMMONDIR (the location of the common/ directory)
#   - define the default rule (usually 'all:'). (Note: you can redefine
#     it later in your Makefile)

.PHONY: common_Make.rules_is_a_bad_target
common_Make.rules_is_a_bad_target:
	@echo "*** default target in common/Make.rules hit - either you did something strange, or something is broken... ***"
	exit 1

DISTRIBUTION=AppArmor
VERSION=$(shell cat $(COMMONDIR)/Version)

# Convenience functions
pathsearch = $(firstword $(wildcard $(addsuffix /$(1),$(subst :, ,$(PATH)))))
map = $(foreach a,$(2),$(call $(1),$(a)))

AWK:=$(shell which awk)
ifndef AWK
$(error awk utility required for build but not available)
endif

define nl

endef

REPO_VERSION_CMD=[ -x /usr/bin/git ] && /usr/bin/git describe --tags --long --abbrev=16 --match 'v*' 2> /dev/null || awk '{ print $2 }' common/.stamp_rev

ifndef PYTHON_VERSIONS
PYTHON_VERSIONS = $(call map, pathsearch, python2 python3)
endif

ifndef PYTHON
PYTHON = $(firstword ${PYTHON_VERSIONS})
endif

#Helper function to be used with $(call pyalldo, run_test_with_all.py)
pyalldo=set -e; $(foreach py, $(PYTHON_VERSIONS), $(py) $(1);)

.PHONY: version
.SILENT: version
version:
	echo $(VERSION)

.PHONY: repo_version
.SILENT: repo_version
repo_version:
	echo $(shell $(value REPO_VERSION_CMD))

.PHONY: pod_clean
ifndef VERBOSE
.SILENT: pod_clean
endif
pod_clean:
	-rm -f ${MANPAGES} *.[0-9].gz ${HTMLMANPAGES} pod2htm*.tmp

# =====================
# generate list of capabilities based on
# /usr/include/linux/capabilities.h for use in multiple locations in
# the source tree
# =====================

# emits defined capabilities in a simple list, e.g. "CAP_NAME CAP_NAME2"
CAPABILITIES=$(shell echo "\#include <linux/capability.h>" | cpp -dM | LC_ALL=C sed -n -e '/CAP_EMPTY_SET/d' -e 's/^\#define[ \t]\+CAP_\([A-Z0-9_]\+\)[ \t]\+\([0-9xa-f]\+\)\(.*\)$$/CAP_\1/p' | LC_ALL=C sort)

.PHONY: list_capabilities
list_capabilities:
	@echo "$(CAPABILITIES)"

# =====================
# generate list of network protocols based on
# sys/socket.h for use in multiple locations in
# the source tree
# =====================

# These are the families that it doesn't make sense for apparmor
# to mediate. We use PF_ here since that is what is required in
# bits/socket.h, but we will rewrite these as AF_.

FILTER_FAMILIES=PF_UNIX

__FILTER=$(shell echo $(strip $(FILTER_FAMILIES)) | sed -e 's/ /\\\|/g')

# emits the AF names in a "AF_NAME NUMBER," pattern
AF_NAMES=$(shell echo "\#include <sys/socket.h>" | cpp -dM | LC_ALL=C sed -n -e '/$(__FILTER)/d' -e 's/PF_LOCAL/PF_UNIX/' -e 's/^\#define[ \t]\+PF_\([A-Z0-9_]\+\)[ \t]\+\([0-9]\+\).*$$/AF_\1 \2,/p' | sort -n -k2)

.PHONY: list_af_names
list_af_names:
	@echo "$(AF_NAMES)"

# =====================
# manpages
# =====================

POD2MAN                         = /usr/bin/pod2man
POD2HTML                        = /usr/bin/pod2html
MANDIR                          = /usr/share/man
DOCDIR                          = /usr/share/doc/${NAME}-${VERSION}

# get list of directory numbers based on definition of MANPAGES variable
MANDIRS=$(sort $(foreach dir, 1 2 3 4 5 6 7 8, $(patsubst %.${dir}, ${dir}, $(filter %.${dir}, ${MANPAGES}))))
HTMLMANPAGES=$(foreach manpage, ${MANPAGES}, ${manpage}.html)

.PHONY: install_manpages
install_manpages: $(MANPAGES)
	$(foreach dir, ${MANDIRS}, \
	     install -d ${DESTDIR}/${MANDIR}/man${dir} ; \
	     install -m 644 $(filter %.${dir}, ${MANPAGES}) ${DESTDIR}/${MANDIR}/man${dir}; \
	)

MAN_RELEASE="AppArmor ${VERSION}"

%.1 %.2 %.3 %.4 %.5 %.6 %.7 %.8: %.pod
	$(POD2MAN) $< --release=$(MAN_RELEASE) --center=AppArmor --stderr --section=$(subst .,,$(suffix $@)) > $@

%.1.html: %.pod
	$(POD2HTML) --header --css apparmor.css --infile=$< --outfile=$@

%.2.html: %.pod
	$(POD2HTML) --header --css apparmor.css --infile=$< --outfile=$@

%.3.html: %.pod
	$(POD2HTML) --header --css apparmor.css --infile=$< --outfile=$@

%.4.html: %.pod
	$(POD2HTML) --header --css apparmor.css --infile=$< --outfile=$@

%.5.html: %.pod
	$(POD2HTML) --header --css apparmor.css --infile=$< --outfile=$@

%.6.html: %.pod
	$(POD2HTML) --header --css apparmor.css --infile=$< --outfile=$@

%.7.html: %.pod
	$(POD2HTML) --header --css apparmor.css --infile=$< --outfile=$@

%.8.html: %.pod
	$(POD2HTML) --header --css apparmor.css --infile=$< --outfile=$@

A2PS_ARGS=-Ec -g --line-numbers=1
ENSCRIPT_ARGS=-C -2jGr -f Courier6 -E
%.c.ps: %.c
	#a2ps ${A2PS_ARGS} $< -o $@
	enscript ${ENSCRIPT_ARGS} -o $@ $<

%.pm.ps: %.pm
	enscript ${ENSCRIPT_ARGS} -o $@ $<

.PHONY: check_pod_files
check_pod_files:
	LANG=C podchecker -warning -warning *.pod