1
# ------------------------------------------------------------------
3
# Copyright (C) 2002-2005 Novell/SUSE
4
# Copyright (C) 2010 Canonical, Ltd.
6
# This program is free software; you can redistribute it and/or
7
# modify it under the terms of version 2 of the GNU General Public
8
# License published by the Free Software Foundation.
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, contact Novell, Inc.
17
# ------------------------------------------------------------------
18
# Make.rules - common make targets and variables for building the SHASS
22
# - must define the package NAME before including this file.
23
# - After checking in to cvs, you'll need to delele the hardlinked
24
# Make.rules files that already exist in the individual application
28
VERSION=$(shell cat common/Version)
30
# OVERRIDABLE variables
31
# Set these variables before including Make.rules to change its behavior
32
# SPECFILE - for packages that have a non-standard specfile name
33
# EXTERNAL_PACKAGE - for packages that have upstream versions that
34
# we're locally modifying (e.g. imnxcerttool/gnutls).
36
# use 'make BUILDIR=/some/where/else/' to override the /usr/src/redhat
37
# location -- it *should* pick out the right thing to do based on the
38
# .rpmmacros file, but you can still use BUILDDIR to override that.
39
TESTBUILDDIR=$(shell [ -f ${HOME}/.rpmmacros ] && awk '/^%_topdir/ {print $$2}' ${HOME}/.rpmmacros)
41
BUILDDIR=$(shell if [ -d "${TESTBUILDDIR}" ] ; then \
42
echo ${TESTBUILDDIR} | sed "s^/$$^^" ; \
43
elif [ -d "/usr/src/redhat" ] ; then \
44
echo "/usr/src/redhat" ; \
45
elif [ -d "/usr/src/packages" ] ; then \
46
echo "/usr/src/packages" ; \
48
echo "/tmp/${NAME}" ; \
52
DISTRO=$(shell if [ -f /etc/slackware-version ] ; then \
54
elif [ -f /etc/debian_version ] ; then \
56
elif which rpm > /dev/null ; then \
57
if [ "$(rpm --eval '0%{?suse_version}')" != "0" ] ; then \
59
elif [ "$(rpm --eval '%{_host_vendor}')" = redhat ] ; then \
61
elif [ "$(rpm --eval '0%{?fedora}')" != "0" ] ; then \
70
RPMARG=--define "_topdir $(BUILDDIR:/=)" \
71
--define "vendor NOVELL, Inc." \
72
--define "distribution ${DISTRIBUTION}" \
73
--define "debug_package %{nil}" \
74
--define "immunix_version ${VERSION}" \
75
$(shell [ -d ${BUILDDIR}/BUILDROOT ] && echo --define \"buildroot $(BUILDDIR:/=)/BUILDROOT\") \
76
$(shell [ -n "${DISTRO}" ] && echo --define \"distro ${DISTRO}\")
78
REPO_VERSION_CMD=([ -x /usr/bin/bzr ] && /usr/bin/bzr version-info . 2> /dev/null || awk '{ print "revno: "$2 }' common/.stamp_rev) | awk '/^revno:/ { print $2 }'
80
ifdef EXTERNAL_PACKAGE
81
RPMARG+=--define "_sourcedir $(shell pwd)"
85
SPECFILE = $(NAME).spec
87
RELEASE_DIR = $(NAME)-$(VERSION)
88
TAR = /bin/tar czvp -h --exclude .svn --exclude .bzr --exclude .bzrignore --exclude ${RELEASE_DIR}/${RELEASE_DIR} $(shell test -f ${NAME}.exclude && echo "-X ${NAME}.exclude")
89
LDCONFIG = /sbin/ldconfig
91
RPMSUBDIRS=SOURCES SPECS BUILD BUILDROOT SRPMS RPMS/i386 RPMS/i586 \
92
RPMS/i686 RPMS/athlon RPMS/noarch RPMS/x86_64
93
BUILDRPMSUBDIRS=$(foreach subdir, $(RPMSUBDIRS), $(BUILDDIR:/=)/$(subdir))
95
ifdef EXTERNAL_PACKAGE
97
rpm: clean $(BUILDRPMSUBDIRS)
98
rpmbuild -ba ${RPMARG} ${SPECFILE}
102
rpm: clean $(BUILDRPMSUBDIRS)
103
__REPO_VERSION=`$(value REPO_VERSION_CMD)` ; \
104
__TARBALL=$(NAME)-$(VERSION)-$${__REPO_VERSION}.tar.gz ; \
105
make $${__TARBALL} ; \
106
cp $${__TARBALL} $(BUILDDIR)/SOURCES/
107
cp ${SPECFILE} $(BUILDDIR)/SPECS/
108
rpmbuild -ba ${RPMARG} ${SPECFILE}
111
${SPECFILE}: ${SPECFILE}.in
112
__REPO_VERSION=`$(value REPO_VERSION_CMD)` ; \
113
sed -e "s/@@immunix_version@@/${VERSION}/g" \
114
-e "s/@@repo_version@@/$${__REPO_VERSION}/g" $< > $@
116
%.tar.gz: clean ${SPECFILE}
117
-rm -rf $(RELEASE_DIR)
119
$(TAR) --exclude $@ . | tar xz -C $(RELEASE_DIR)
120
$(TAR) --exclude $@ -f $@ $(RELEASE_DIR)
121
rm -rf $(RELEASE_DIR)
123
ifndef OVERRIDE_TARBALL
125
tarball: clean $(TARBALL)
133
rpm -q --define "_sourcedir ." ${RPMARG} --specfile ${SPECFILE}
136
.SILENT: repo_version
138
$(value REPO_VERSION_CMD)
142
build_dir: $(BUILDRPMSUBDIRS)
145
mkdir -p $(BUILDRPMSUBDIRS)
150
-rm -f ${NAME}-${VERSION}-*.tar.gz
151
-rm -f ${MANPAGES} *.[0-9].gz ${HTMLMANPAGES} pod2htm*.tmp
153
# =====================
154
# generate list of capabilities based on
155
# /usr/include/linux/capabilities.h for use in multiple locations in
157
# =====================
159
# emits defined capabilities in a simple list, e.g. "CAP_NAME CAP_NAME2"
160
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' | sort)
162
.PHONY: list_capabilities
163
list_capabilities: /usr/include/linux/capability.h
164
@echo "$(CAPABILITIES)"
166
# =====================
167
# generate list of network protocols based on
168
# sys/socket.h for use in multiple locations in
170
# =====================
172
# These are the families that it doesn't make sense for apparmor
173
# to mediate. We use PF_ here since that is what is required in
174
# bits/socket.h, but we will rewrite these as AF_.
176
FILTER_FAMILIES=PF_UNSPEC PF_UNIX PF_LOCAL PF_NETLINK
178
__FILTER=$(shell echo $(strip $(FILTER_FAMILIES)) | sed -e 's/ /\\\|/g')
180
# emits the AF names in a "AF_NAME NUMBER," pattern
181
AF_NAMES=$(shell echo "\#include <sys/socket.h>" | cpp -dM | LC_ALL=C sed -n -e '/$(__FILTER)/d' -e 's/^\#define[ \t]\+PF_\([A-Z0-9_]\+\)[ \t]\+\([0-9]\+\).*$$/AF_\1 \2,/p' | sort -n -k2)
183
.PHONY: list_af_names
187
# =====================
189
# =====================
191
POD2MAN = /usr/bin/pod2man
192
POD2HTML = /usr/bin/pod2html
193
MANDIR = /usr/share/man
194
DOCDIR = /usr/share/doc/${NAME}-${VERSION}
196
# get list of directory numbers based on definition of MANPAGES variable
197
MANDIRS=$(sort $(foreach dir, 1 2 3 4 5 6 7 8, $(patsubst %.${dir}, ${dir}, $(filter %.${dir}, ${MANPAGES}))))
198
HTMLMANPAGES=$(foreach manpage, ${MANPAGES}, ${manpage}.html)
200
.PHONY: install_manpages
201
install_manpages: $(MANPAGES)
202
$(foreach dir, ${MANDIRS}, \
203
install -d ${DESTDIR}/${MANDIR}/man${dir} ; \
204
install -m 644 $(filter %.${dir}, ${MANPAGES}) ${DESTDIR}/${MANDIR}/man${dir}; \
207
MAN_RELEASE="AppArmor ${VERSION}"
210
$(POD2MAN) $< --release=$(MAN_RELEASE) --center=AppArmor --section=1 > $@
213
$(POD2MAN) $< --release=$(MAN_RELEASE) --center=AppArmor --section=2 > $@
216
$(POD2MAN) $< --release=$(MAN_RELEASE) --center=AppArmor --section=3 > $@
219
$(POD2MAN) $< --release=$(MAN_RELEASE) --center=AppArmor --section=4 > $@
222
$(POD2MAN) $< --release=$(MAN_RELEASE) --center=AppArmor --section=5 > $@
225
$(POD2MAN) $< --release=$(MAN_RELEASE) --center=AppArmor --section=6 > $@
228
$(POD2MAN) $< --release=$(MAN_RELEASE) --center=AppArmor --section=7 > $@
231
$(POD2MAN) $< --release=$(MAN_RELEASE) --center=AppArmor --section=8 > $@
234
$(POD2HTML) --header --css apparmor.css --infile=$< --outfile=$@
237
$(POD2HTML) --header --css apparmor.css --infile=$< --outfile=$@
240
$(POD2HTML) --header --css apparmor.css --infile=$< --outfile=$@
243
$(POD2HTML) --header --css apparmor.css --infile=$< --outfile=$@
246
$(POD2HTML) --header --css apparmor.css --infile=$< --outfile=$@
249
$(POD2HTML) --header --css apparmor.css --infile=$< --outfile=$@
252
$(POD2HTML) --header --css apparmor.css --infile=$< --outfile=$@
255
$(POD2HTML) --header --css apparmor.css --infile=$< --outfile=$@
257
A2PS_ARGS=-Ec -g --line-numbers=1
258
ENSCRIPT_ARGS=-C -2jGr -f Courier6 -E
260
#a2ps ${A2PS_ARGS} $< -o $@
261
enscript ${ENSCRIPT_ARGS} -o $@ $<
264
enscript ${ENSCRIPT_ARGS} -o $@ $<