[apparmor] [patch] fun with the toplevel Makefile

Steve Beattie steve at nxnw.org
Fri Jan 23 18:30:44 UTC 2015


On Fri, Jan 16, 2015 at 06:23:29PM +0100, Christian Boltz wrote:
> I just tried running   make   in the toplevel of a bzr trunk checkout,
> which resulted in a quite funny result:

[SNIP]

> Note that we actually have several bugs here:
> - "tarball" is the default make target, which is at least unexpected
>   (well, actually that's wrong - thanks to including common/Make.rules,
>   the "rpm" target is used, which then calls "make $${__TARBALL}")
> - needless to say that it's not really nice to hit the default target of
>   common/Make.rules ;-)

agreed.

> - common/Make.rules does
>     __TARBALL=$(NAME)-$(VERSION)-$${__REPO_VERSION}.tar.gz
>   but $(NAME) is obviously empty at this point (no idea where it is 
>   usually set)

$(NAME) was intended to be set before including Make.rules in the
subdirectory Makefiles.

So, a bit of history. When we originally organized things, it was
with the intention that individual subdirectories (parser, profiles,
utils, etc.) would get individual releases so that they would not
be tightly coupled and not require updating all pieces to get, for
example, an update to one of the shipped profiles.

A laudable goal, but meant two things: 1) much more work for
releases and for packagers. and 2) the complexity you see (things
like __TARBALL, for generating the subdirectory tarballs), with the
combined weight of both outweighing the benefit of being to just
release an update to the profiles or the utils without needing to
update everything.

Since we've gone with the single tarball approach to releases, a low
priority task has been to remove a bunch of the cruft in Make.rules
that's no longer relevant.

> - oh, and all this means "make rpm" is broken ;-)

Yes.

> The following patch adds a "common_Make.rules_is_a_bad_target" target
> to common/Make.rules to make sure nothing accidently hits the first-best
> target (well, first-not-so-good would better describe the rpm target ;-)
> 
> It also adds a dummy "all:" target to the toplevel Makefile with a 
> short hint towards README.

Acked-by: Steve Beattie <steve at nxnw.org>

> It does _not_ fix "make rpm" target. With *.spec moved to deprecated/,
> we should probably just drop that part from the Makefile. (Volunteers
> welcome - I'd have to read through the Makefile to find out if there are
> additional sections that become superfluous when deleting the rpm target.)

Yeah, I'm hoping to get around to it before we release 2.10/3.0.

Another result of moving to the single tarball release process is that
the funny game we play to symlink in the common/ directory so that the
bits in Make.rules and Make-po.rules were available when building from
the individual released tarballs, is no longer necessary.

The following is patch that gets rid of the symlink make trickery and
just includes things via relative paths.

Signed-off-by: Steve Beattie <steve at nxnw.org>
---
 changehat/mod_apparmor/Makefile               |   10 ++--------
 changehat/pam_apparmor/Makefile               |   13 +++----------
 changehat/tomcat_apparmor/tomcat_5_0/Makefile |   10 ++--------
 changehat/tomcat_apparmor/tomcat_5_5/Makefile |   10 ++--------
 common/Make.rules                             |   10 +++++-----
 deprecated/utils/Makefile                     |    9 +--------
 parser/Makefile                               |   11 +++--------
 parser/po/Makefile                            |    5 ++---
 profiles/Makefile                             |   12 +++---------
 utils/Makefile                                |   10 +---------
 utils/po/Makefile                             |    5 ++---
 utils/test/Makefile                           |   10 ++--------
 utils/vim/Makefile                            |   10 ++--------
 13 files changed, 30 insertions(+), 95 deletions(-)

Index: b/common/Make.rules
===================================================================
--- a/common/Make.rules
+++ b/common/Make.rules
@@ -19,13 +19,11 @@
 # product.
 #
 # NOTES:
-#   - must define the package NAME before including this file.
-#   - After checking in to cvs, you'll need to delele the hardlinked
-#     Make.rules files that already exist in the individual application
-#     directories
+#   - must define COMMONDIR (the location of the common/ directory)
+#     before including this file.
 
 DISTRIBUTION=AppArmor
-VERSION=$(shell cat common/Version)
+VERSION=$(shell cat $(COMMONDIR)/Version)
 
 # Convenience functions
 pathsearch = $(firstword $(wildcard $(addsuffix /$(1),$(subst :, ,$(PATH)))))
@@ -170,7 +168,9 @@ $(BUILDRPMSUBDIRS):
 	mkdir -p $(BUILDRPMSUBDIRS)
 
 .PHONY: _clean
+ifndef VERBOSE
 .SILENT: _clean
+endif
 _clean:
 	-[ -z "${NAME}" ] || rm -f ${NAME}-${VERSION}-*.tar.gz
 	-rm -f ${MANPAGES} *.[0-9].gz ${HTMLMANPAGES} pod2htm*.tmp
Index: b/parser/Makefile
===================================================================
--- a/parser/Makefile
+++ b/parser/Makefile
@@ -18,13 +18,7 @@ NAME=apparmor-parser
 all:
 COMMONDIR=../common/
 
-include common/Make.rules
-
-COMMONDIR_EXISTS=$(strip $(shell [ -d ${COMMONDIR} ] && echo true))
-ifeq ($(COMMONDIR_EXISTS), true)
-common/Make.rules: $(COMMONDIR)/Make.rules
-	ln -sf $(COMMONDIR) .
-endif
+include $(COMMONDIR)/Make.rules
 
 DESTDIR=/
 APPARMOR_BIN_PREFIX=${DESTDIR}/lib/apparmor
@@ -357,7 +351,9 @@ install-indep:
 	$(MAKE) -C po install NAME=${NAME} DESTDIR=${DESTDIR}
 	$(MAKE) install_manpages DESTDIR=${DESTDIR}
 
+ifndef VERBOSE
 .SILENT: clean
+endif
 .PHONY: clean
 clean: _clean
 	rm -f core core.* *.o *.s *.a *~ *.gcda *.gcno
@@ -373,7 +369,6 @@ clean: _clean
 	$(MAKE) -s -C $(AAREDIR) clean
 	$(MAKE) -s -C po clean
 	$(MAKE) -s -C tst clean
-	rm -f common
 
 .SILENT: dist_clean
 dist_clean:
Index: b/parser/po/Makefile
===================================================================
--- a/parser/po/Makefile
+++ b/parser/po/Makefile
@@ -12,9 +12,8 @@ all:
 
 DISABLED_LANGS=
 
-include ../common/Make-po.rules
-../common/Make-po.rules:
-	make -C .. common/Make.rules
+COMMONDIR=../../common
+include $(COMMONDIR)/Make-po.rules
 
 XGETTEXT_ARGS+=--language=C --keyword=_ $(shell if [ -f ${NAME}.pot ] ; then echo -n -j ; fi)
 
Index: b/utils/Makefile
===================================================================
--- a/utils/Makefile
+++ b/utils/Makefile
@@ -18,13 +18,7 @@ NAME 		= apparmor-utils
 all:
 COMMONDIR=../common/
 
-include common/Make.rules
-
-COMMONDIR_EXISTS=$(strip $(shell [ -d ${COMMONDIR} ] && echo true))
-ifeq ($(COMMONDIR_EXISTS), true)
-common/Make.rules: $(COMMONDIR)/Make.rules
-	ln -sf $(COMMONDIR) .
-endif
+include $(COMMONDIR)/Make.rules
 
 PERLTOOLS = aa-exec aa-notify
 PYTOOLS = aa-easyprof aa-genprof aa-logprof aa-cleanprof aa-mergeprof \
@@ -71,14 +65,12 @@ ifndef VERBOSE
 endif
 clean: _clean
 	rm -f core core.* *.o *.s *.a *~
-	rm -f Make.rules
 	$(MAKE) -C po clean
 	$(MAKE) -C vim clean
 	$(MAKE) -C test clean
 	rm -rf staging/ build/
 	rm -f apparmor/*.pyc
 	rm -rf apparmor/__pycache__/
-	rm -f common
 
 # ${CAPABILITIES} is defined in common/Make.rules
 .PHONY: check_severity_db
Index: b/utils/po/Makefile
===================================================================
--- a/utils/po/Makefile
+++ b/utils/po/Makefile
@@ -19,9 +19,8 @@ all:
 # the lang is explicitly added to DISABLED_LANGS; e.g. DISABLED_LANGS=en es
 
 DISABLED_LANGS=
+COMMONDIR=../../common
 
-include ../common/Make-po.rules
-../common/Make-po.rules:
-	make -C .. common/Make.rules
+include $(COMMONDIR)/Make-po.rules
 
 XGETTEXT_ARGS+=--language=perl --language=python
Index: b/utils/vim/Makefile
===================================================================
--- a/utils/vim/Makefile
+++ b/utils/vim/Makefile
@@ -1,13 +1,7 @@
 COMMONDIR=../../common/
 
 all:
-include common/Make.rules
-
-COMMONDIR_EXISTS=$(strip $(shell [ -d ${COMMONDIR} ] && echo true))
-ifeq ($(COMMONDIR_EXISTS), true)
-common/Make.rules: $(COMMONDIR)/Make.rules
-	ln -sf $(COMMONDIR) .
-endif
+include $(COMMONDIR)/Make.rules
 
 MANPAGES=apparmor.vim.5
 VIM_INSTALL_PATH=${DESTDIR}/usr/share/apparmor
@@ -32,4 +26,4 @@ check: check_pod_files
 	$(call pyalldo, create-apparmor.vim.py > /dev/null)
 
 clean: _clean
-	rm -f apparmor.vim common
+	rm -f apparmor.vim
Index: b/utils/test/Makefile
===================================================================
--- a/utils/test/Makefile
+++ b/utils/test/Makefile
@@ -18,13 +18,7 @@ NAME 		= apparmor-utils
 all:
 COMMONDIR=../../common/
 
-include common/Make.rules
-
-COMMONDIR_EXISTS=$(strip $(shell [ -d ${COMMONDIR} ] && echo true))
-ifeq ($(COMMONDIR_EXISTS), true)
-common/Make.rules: $(COMMONDIR)/Make.rules
-	ln -sf $(COMMONDIR) .
-endif
+include $(COMMONDIR)/Make.rules
 
 COVERAGE_OMIT=test-*.py,common_test.py
 ifneq ($(COVERAGE_OUT), )
@@ -37,7 +31,7 @@ ifndef VERBOSE
 endif
 
 clean: _clean
-	rm -rf __pycache__/ common .coverage htmlcov
+	rm -rf __pycache__/ .coverage htmlcov
 
 check:
 	export PYTHONPATH=.. ; $(foreach test, $(wildcard test-*.py), $(call pyalldo, $(test)))
Index: b/profiles/Makefile
===================================================================
--- a/profiles/Makefile
+++ b/profiles/Makefile
@@ -20,16 +20,10 @@
 # Makefile for LSM-based AppArmor profiles
 
 NAME=apparmor-profiles
-ALL: local
+all: local
 COMMONDIR=../common/
 
-include common/Make.rules
-
-COMMONDIR_EXISTS=$(strip $(shell [ -d ${COMMONDIR} ] && echo true))
-ifeq ($(COMMONDIR_EXISTS), true)
-common/Make.rules: $(COMMONDIR)/Make.rules
-	ln -sf $(COMMONDIR) .
-endif
+include $(COMMONDIR)/Make.rules
 
 DESTDIR=/
 PROFILES_DEST=${DESTDIR}/etc/apparmor.d
@@ -63,7 +57,7 @@ install: local
 LOCAL_ADDITIONS=$(filter-out ${PROFILES_SOURCE}/local/README, $(wildcard ${PROFILES_SOURCE}/local/*))
 .PHONY: clean
 clean:
-	-rm -f $(NAME)-$(VERSION)*.tar.gz Make.rules ${LOCAL_ADDITIONS} common
+	-rm -f $(NAME)-$(VERSION)*.tar.gz ${LOCAL_ADDITIONS}
 
 ifndef VERBOSE
   Q=@
Index: b/changehat/mod_apparmor/Makefile
===================================================================
--- a/changehat/mod_apparmor/Makefile
+++ b/changehat/mod_apparmor/Makefile
@@ -17,13 +17,7 @@ NAME:=apache2-mod_apparmor
 all:
 COMMONDIR=../../common/
 
-include common/Make.rules
-
-COMMONDIR_EXISTS=$(strip $(shell [ -d ${COMMONDIR} ] && echo true))
-ifeq ($(COMMONDIR_EXISTS), true)
-common/Make.rules: $(COMMONDIR)/Make.rules
-	ln -sf $(COMMONDIR) .
-endif
+include $(COMMONDIR)/Make.rules
 
 TARGET:=mod_apparmor.so
 MANPAGES=mod_apparmor.8
@@ -94,7 +88,7 @@ install: ${TARGET} ${MANPAGES}
 .PHONY: clean
 clean: _clean
 	rm -rf .libs
-	rm -f *.la *.lo *.so *.o *.slo Make.rules
+	rm -f *.la *.lo *.so *.o *.slo
 
 .PHONY: check
 check: check_pod_files
Index: b/changehat/pam_apparmor/Makefile
===================================================================
--- a/changehat/pam_apparmor/Makefile
+++ b/changehat/pam_apparmor/Makefile
@@ -16,15 +16,8 @@
 NAME=pam_apparmor
 all:
 COMMONDIR=../../common/
-MAKE_RULES=common/Make.rules
 
-include ${MAKE_RULES}
-
-COMMONDIR_EXISTS=$(strip $(shell [ -d ${COMMONDIR} ] && echo true))
-ifeq ($(COMMONDIR_EXISTS), true)
-common/Make.rules: $(COMMONDIR)/Make.rules
-	ln -sf $(COMMONDIR) .
-endif
+include $(COMMONDIR)/Make.rules
 
 ifdef USE_SYSTEM
   LIBAPPARMOR = $(shell if pkg-config --exists libapparmor ; then \
@@ -87,7 +80,7 @@ install: $(NAME).so
 	install -m 555 $(NAME).so $(SECDIR)/
 	
 .PHONY: clean
-clean: ${MAKE_RULES}
+clean:
 	rm -f core core.* *.so *.o *.s *.a *~
-	rm -f ${NAME}-*.tar.gz Make.rules
+	rm -f ${NAME}-*.tar.gz
 
Index: b/changehat/tomcat_apparmor/tomcat_5_0/Makefile
===================================================================
--- a/changehat/tomcat_apparmor/tomcat_5_0/Makefile
+++ b/changehat/tomcat_apparmor/tomcat_5_0/Makefile
@@ -17,13 +17,7 @@ NAME 		= tomcat_apparmor
 all:
 COMMONDIR=../../../common/
 
-include common/Make.rules
-
-COMMONDIR_EXISTS=$(strip $(shell [ -d ${COMMONDIR} ] && echo true))
-ifeq ($(COMMONDIR_EXISTS), true)
-common/Make.rules: $(COMMONDIR)/Make.rules
-	ln -sf $(COMMONDIR) .
-endif
+include $(COMMONDIR)/Make.rules
 
 LIB		= lib
 CATALINA_HOME 	= /usr/share/tomcat5
@@ -34,7 +28,7 @@ all:
 
 clean:
 	ant clean
-	rm -f tomcat_apparmor.spec ${NAME}-*.tar.gz Make.rules
+	rm -f tomcat_apparmor.spec ${NAME}-*.tar.gz
 
 install: $(SPECFILE)
 	 ant  -Dversion=$(VERSION) -Drelease=$(MAN_RELEASE) -Dcatalina_home=${CATALINA_HOME} -Dinstall_lib=${LIB} install_jar install_jni
Index: b/changehat/tomcat_apparmor/tomcat_5_5/Makefile
===================================================================
--- a/changehat/tomcat_apparmor/tomcat_5_5/Makefile
+++ b/changehat/tomcat_apparmor/tomcat_5_5/Makefile
@@ -17,13 +17,7 @@ NAME 		= tomcat_apparmor
 all:
 COMMONDIR=../../../common/
 
-include common/Make.rules
-
-COMMONDIR_EXISTS=$(strip $(shell [ -d ${COMMONDIR} ] && echo true))
-ifeq ($(COMMONDIR_EXISTS), true)
-common/Make.rules: $(COMMONDIR)/Make.rules
-	ln -sf $(COMMONDIR) .
-endif
+include $(COMMONDIR)/Make.rules
 
 LIB		= lib
 CATALINA_HOME 	= /usr/share/tomcat55
@@ -34,7 +28,7 @@ all:
 
 clean:
 	ant clean
-	rm -f tomcat_apparmor.spec ${NAME}-*.tar.gz Make.rules
+	rm -f tomcat_apparmor.spec ${NAME}-*.tar.gz
 
 install: $(SPECFILE)
 	 ant  -Dversion=$(VERSION) -Drelease=$(MAN_RELEASE) -Dcatalina_home=${CATALINA_HOME} -Dinstall_lib=${LIB} install_jar install_jni
Index: b/deprecated/utils/Makefile
===================================================================
--- a/deprecated/utils/Makefile
+++ b/deprecated/utils/Makefile
@@ -24,13 +24,7 @@ NAME 		= apparmor-utils
 all:
 COMMONDIR=../../common/
 
-include common/Make.rules
-
-COMMONDIR_EXISTS=$(strip $(shell [ -d ${COMMONDIR} ] && echo true))
-ifeq ($(COMMONDIR_EXISTS), true)
-common/Make.rules: $(COMMONDIR)/Make.rules
-	ln -sf $(COMMONDIR) .
-endif
+include $(COMMONDIR)/Make.rules
 
 MODDIR = Immunix
 PERLTOOLS = aa-genprof aa-logprof aa-autodep aa-audit aa-complain aa-enforce \
@@ -58,7 +52,6 @@ ifndef VERBOSE
 endif
 clean: _clean
 	rm -f core core.* *.o *.s *.a *~
-	rm -f Make.rules
 	rm -rf staging/ build/
 
 .PHONY: check
-- 
Steve Beattie
<sbeattie at ubuntu.com>
http://NxNW.org/~steve/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20150123/99e4c297/attachment.pgp>


More information about the AppArmor mailing list