apparmor/common/Make.rules

151 lines
4.6 KiB
Text
Raw Normal View History

# ------------------------------------------------------------------
#
# 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)
2012-06-11 17:56:21 +01:00
# 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
2012-06-11 17:56:21 +01:00
ifndef PYTHON_VERSIONS
utils: only use python3 during testing The apparmor python tools are written assuming python3. But the tests are still using python2. This can result in failures of the test suite on some systems, depending on how libapparmor is built. Eg. on Ubuntu 18.04 apparmor.git/utils$ PYTHON=/usr/bin/python3 make check PYFLAKES=/usr/bin/pyflakes3 LANG=C podchecker -warning -warning *.pod aa-audit.pod pod syntax OK. aa-autodep.pod pod syntax OK. aa-cleanprof.pod pod syntax OK. aa-complain.pod pod syntax OK. aa-decode.pod pod syntax OK. aa-disable.pod pod syntax OK. aa-easyprof.pod pod syntax OK. aa-enforce.pod pod syntax OK. aa-genprof.pod pod syntax OK. aa-logprof.pod pod syntax OK. aa-mergeprof.pod pod syntax OK. aa-notify.pod pod syntax OK. aa-remove-unknown.pod pod syntax OK. aa-sandbox.pod pod syntax OK. aa-status.pod pod syntax OK. aa-unconfined.pod pod syntax OK. logprof.conf.pod pod syntax OK. aa-notify syntax OK Checking aa-easyprof Checking aa-genprof Checking aa-logprof Checking aa-cleanprof Checking aa-mergeprof Checking aa-autodep Checking aa-audit Checking aa-complain Checking aa-enforce Checking aa-disable Checking aa-status Checking aa-unconfined Checking apparmor Checking test/common_test.py Checking test/minitools_test.py Checking test/test-aa-decode.py Checking test/test-aa-easyprof.py Checking test/test-aa.py Checking test/test-aamode.py Checking test/test-aare.py Checking test/test-baserule.py Checking test/test-capability.py Checking test/test-change_profile.py Checking test/test-common.py Checking test/test-config.py Checking test/test-dbus.py Checking test/test-example.py Checking test/test-file.py Checking test/test-libapparmor-test_multi.py Checking test/test-logparser.py Checking test/test-mount_parse.py Checking test/test-network.py Checking test/test-parser-simple-tests.py Checking test/test-pivot_root_parse.py Checking test/test-profile-list.py Checking test/test-profile-storage.py Checking test/test-ptrace.py Checking test/test-regex_matches.py Checking test/test-rlimit.py Checking test/test-severity.py Checking test/test-signal.py Checking test/test-translations.py Checking test/test-unix_parse.py make[1]: Entering directory '/home/jj/apparmor/apparmor-jjohansen.git/utils/test' === test-example.py === ....... ---------------------------------------------------------------------- Ran 7 tests in 0.000s OK ....... ---------------------------------------------------------------------- Ran 7 tests in 0.000s OK === test-pivot_root_parse.py === Traceback (most recent call last): File "test-pivot_root_parse.py", line 12, in <module> import apparmor.aa as aa File "/home/jj/apparmor/apparmor-jjohansen.git/utils/apparmor/aa.py", line 28, in <module> import apparmor.logparser File "/home/jj/apparmor/apparmor-jjohansen.git/utils/apparmor/logparser.py", line 19, in <module> import LibAppArmor ImportError: No module named LibAppArmor Makefile:81: recipe for target 'check' failed make[1]: *** [check] Error 1 make[1]: Leaving directory '/home/jj/apparmor/apparmor-jjohansen.git/utils/test' Makefile:95: recipe for target 'check' failed make: *** [check] Error 2 Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-03-19 09:17:33 -07:00
PYTHON_VERSIONS = $(call map, pathsearch, python3)
2012-06-11 17:56:21 +01:00
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);)
# Common set of compiler warnings
_EXTRA_WARNINGS = -Wall -Wsign-compare -Wmissing-field-initializers -Wformat -Wformat-security -Wunused-parameter -Wimplicit-fallthrough
EXTRA_WARNINGS := $(shell for warning in ${_EXTRA_WARNINGS} ; do \
if ${CC} $${warning} -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then \
echo "$${warning}"; \
else \
echo "***" >&2 ; \
echo "WARNING: unable to use $${warning} with ${CC}, dropping" >&2 ; \
echo "***" >&2 ; \
fi ; \
done)
.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
# =====================
# 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}; \
)
2010-11-04 11:32:06 -07:00
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 $@ $<
manpages: incorporate podchecker; fix errors and (most) warnings This patch adds a 'check_pod_files' make target to the common make rules, and then fixes the errors it highlighted as well as most of the warnings. It will cause 'make check' in most of the directories to fail if there are errors in a pod file (but not if there are warnings). Common issues were: - using an '=over/=back' pair for code-like snippets that did not contain any =items therein; the =over keyword is intended for indenting lists of =item entries, and generates a warning if there isn't any. - not escaping '<' or '>' - blank lines that contained spaces or tabs The second -warnings flag passed to podchecker is to add additional warnings, un-escaped '<' and '>' being of them. I did not fix all of the warnings in apparmor.d.pod, as I have not come up with a good warning-free way to express the BNF of the language similar in format to what is currently generated. The existing libapparmor warnings (complaints about duplicate =item definition names) are actually a result of passing the second -warnings flag. The integration into libapparmor is suboptimal due to automake's expectation that there will be a test driver program(s) for make check targets; that's why I added the podchecker call to the manpage generation point. Signed-off-by: Steve Beattie <steve@nxnw.org> Acked-by: Seth Arnold <seth.arnold@canonical.com> --- changehat/mod_apparmor/Makefile | 3 changehat/mod_apparmor/mod_apparmor.pod | 28 ++- common/Make.rules | 4 libraries/libapparmor/doc/Makefile.am | 7 parser/Makefile | 2 parser/apparmor.d.pod | 275 +++++++++++++------------------- utils/Makefile | 3 utils/aa-cleanprof.pod | 2 utils/aa-complain.pod | 2 utils/aa-decode.pod | 2 utils/aa-easyprof.pod | 69 +++----- utils/aa-enforce.pod | 2 utils/aa-genprof.pod | 2 utils/aa-logprof.pod | 6 utils/aa-sandbox.pod | 64 ++----- utils/logprof.conf.pod | 2 utils/vim/Makefile | 2 17 files changed, 212 insertions(+), 263 deletions(-)
2014-09-15 11:30:47 -07:00
.PHONY: check_pod_files
check_pod_files:
LANG=C podchecker -warning -warning *.pod