[apparmor] [RFC] [patch] Makefile automatically fallback to USE_SYSTEM=1
John Johansen
john.johansen at canonical.com
Fri Mar 7 16:19:45 UTC 2014
So this is a patch I have been using for a while to get around having
to specify USE_SYSTEM=1 every time I run the tests. Is it worth
upstreaming and applying to the other Makefiles that currently can take
USE_SYSTEM as a parameter
If USE_SYSTEM=1 is NOT specified
it tries to find a local build and if it can't find one, it sets
USE_SYSTEM=1 and issues a warning message
If USE_SYSTEM=1 is specified
it only tries building against the system libraries
---
=== modified file 'tests/regression/apparmor/Makefile'
--- tests/regression/apparmor/Makefile 2014-01-24 19:03:22 +0000
+++ tests/regression/apparmor/Makefile 2014-03-07 00:39:38 +0000
@@ -6,7 +6,33 @@
# published by the Free Software Foundation, version 2 of the
# License.
-ifdef USE_SYSTEM
+define nl
+
+
+endef
+
+ifndef USE_SYSTEM # !USE_SYSTEM
+ # use in-tree versions
+ LIBAPPARMOR_SRC := ../../../libraries/libapparmor/
+ LIBAPPARMOR_INCLUDE = $(LIBAPPARMOR_SRC)/include
+ LIBAPPARMOR_PATH := $(LIBAPPARMOR_SRC)/src/.libs/
+ ifeq ($(realpath $(LIBAPPARMOR_PATH)/libapparmor.a),)
+ $(warning ${nl}\
+ ************************************************************************${nl}\
+ WARNING: $(LIBAPPARMOR_PATH)/libapparmor.a is missing! ${nl}\
+ Attempting to build against the system libapparmor instead. ${nl}\
+ To get rid of this message either, build against the in-tree libapparmor${nl}\
+ by building it first and then running make here, or add USE_SYSTEM=1 to${nl}\
+ your make command (see the top-level README for help).${nl}\
+ ************************************************************************)
+ USE_SYSTEM=1
+ else
+ CFLAGS += -L$(LIBAPPARMOR_PATH) -I$(LIBAPPARMOR_INCLUDE)
+ LDLIBS += -Wl,-Bstatic -lapparmor -Wl,-Bdynamic -lpthread
+ endif
+endif # USE_SYSTEM
+
+ifdef USE_SYSTEM # May be automatically set by above ifndef USE_SYSTEM
# use the system libapparmor headers and library
LIBAPPARMOR = $(shell if pkg-config --exists libapparmor ; then \
pkg-config --silence-errors --libs libapparmor ; \
@@ -19,22 +45,7 @@
manually, or build against in-tree libapparmor)
endif # LIBAPPARMOR not set
LDLIBS += $(LIBAPPARMOR)
-
-else # !USE_SYSTEM
- # use in-tree versions
- LIBAPPARMOR_SRC := ../../../libraries/libapparmor/
- LIBAPPARMOR_INCLUDE = $(LIBAPPARMOR_SRC)/include
- LIBAPPARMOR_PATH := $(LIBAPPARMOR_SRC)/src/.libs/
- ifeq ($(realpath $(LIBAPPARMOR_PATH)/libapparmor.a),)
- ERROR_MESSAGE = $(LIBAPPARMOR_PATH)/libapparmor.a is missing; either build against \
- the in-tree libapparmor by building it first and then trying again \
- (see the top-level README for help) or build against the system \
- libapparmor by adding USE_SYSTEM=1 to your make command.)
- endif
-
- CFLAGS += -L$(LIBAPPARMOR_PATH) -I$(LIBAPPARMOR_INCLUDE)
- LDLIBS += -Wl,-Bstatic -lapparmor -Wl,-Bdynamic -lpthread
-endif # USE_SYSTEM
+endif
CFLAGS += -Wall -Wstrict-prototypes
More information about the AppArmor
mailing list