Makefiles: add ${nl} for errors, apply when failing to find libapparmor

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
Steve Beattie 2014-03-11 14:42:23 -07:00
parent 757cc25163
commit 61fb0e9cea
4 changed files with 51 additions and 36 deletions

View file

@ -48,9 +48,12 @@ ifdef USE_SYSTEM
echo -lapparmor ; \
fi )
ifeq ($(strip $(LIBAPPARMOR)),)
ERROR_MESSAGE = Unable to find libapparmor installed on this system; either \
install libapparmor devel packages, set the LIBAPPARMOR variable \
manually, or build against in-tree libapparmor)
ERROR_MESSAGE = $(error ${nl}\
************************************************************************${nl}\
Unable to find libapparmor installed on this system; either${nl}\
install libapparmor devel packages, set the LIBAPPARMOR variable${nl}\
manually, or build against in-tree libapparmor.${nl}\
************************************************************************${nl})
endif # LIBAPPARMOR not set
LDLIBS += $(LIBAPPARMOR)
else
@ -58,10 +61,13 @@ else
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.)
ERROR_MESSAGE = $(error ${nl}\
************************************************************************${nl}\
$(LIBAPPARMOR_PATH)/libapparmor.a is missing; either build against${nl}\
the in-tree libapparmor by building it first and then trying again${nl}\
(see the top-level README for help) or build against the system${nl}\
libapparmor by adding USE_SYSTEM=1 to your make command.${nl}\
************************************************************************${nl})
endif
# Need to pass -Wl twice here to get past both apxs2 and libtool, as
# libtool will add the path to the RPATH of the library if passed -L/some/path
@ -71,11 +77,7 @@ endif
.PHONY: libapparmor_check
.SILENT: libapparmor_check
libapparmor_check:
@if [ -n "$(ERROR_MESSAGE)" ] ; then \
echo "$(ERROR_MESSAGE)" 1>&2 ; \
return 1 ; \
fi
libapparmor_check: ; $(ERROR_MESSAGE)
all: libapparmor_check $(TARGET) ${MANPAGES} ${HTMLMANPAGES}

View file

@ -33,9 +33,12 @@ ifdef USE_SYSTEM
echo -lapparmor ; \
fi )
ifeq ($(strip $(LIBAPPARMOR)),)
ERROR_MESSAGE = Unable to find libapparmor installed on this system; either \
install libapparmor devel packages, set the LIBAPPARMOR variable \
manually, or build against in-tree libapparmor)
ERROR_MESSAGE = $(error ${nl}\
************************************************************************${nl}\
Unable to find libapparmor installed on this system; either${nl}\
install libapparmor devel packages, set the LIBAPPARMOR variable${nl}\
manually, or build against in-tree libapparmor.${nl}\
************************************************************************${nl})
endif
LIBAPPARMOR_INCLUDE =
AA_LDLIBS = $(LIBAPPARMOR)
@ -45,10 +48,13 @@ else
LIBAPPARMOR_INCLUDE_PATH = $(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.)
ERROR_MESSAGE = $(error ${nl}\
************************************************************************${nl}\
$(LIBAPPARMOR_PATH)/libapparmor.a is missing; either build against${nl}\
the in-tree libapparmor by building it first and then trying again${nl}\
(see the top-level README for help) or build against the system${nl}\
libapparmor by adding USE_SYSTEM=1 to your make command.${nl}\
************************************************************************${nl})
endif
LIBAPPARMOR_INCLUDE = -I$(LIBAPPARMOR_INCLUDE_PATH)
AA_LINK_FLAGS = -L$(LIBAPPARMOR_PATH)
@ -61,11 +67,7 @@ OBJECTS=${NAME}.o get_options.o
.PHONY: libapparmor_check
.SILENT: libapparmor_check
libapparmor_check:
@if [ -n "$(ERROR_MESSAGE)" ] ; then \
echo "$(ERROR_MESSAGE)" 1>&2 ; \
return 1 ; \
fi
libapparmor_check: ; $(ERROR_MESSAGE)
all: libapparmor_check $(NAME).so

View file

@ -36,6 +36,11 @@ ifndef AWK
$(error awk utility required for build but not available)
endif
define nl
endef
# OVERRIDABLE variables
# Set these variables before including Make.rules to change its behavior
# SPECFILE - for packages that have a non-standard specfile name

View file

@ -6,6 +6,10 @@
# published by the Free Software Foundation, version 2 of the
# License.
all:
COMMONDIR=../../../common/
include $(COMMONDIR)/Make.rules
ifdef USE_SYSTEM
# use the system libapparmor headers and library
LIBAPPARMOR = $(shell if pkg-config --exists libapparmor ; then \
@ -14,9 +18,12 @@ ifdef USE_SYSTEM
echo -lapparmor ; \
fi )
ifeq ($(strip $(LIBAPPARMOR)),)
ERROR_MESSAGE = Unable to find libapparmor installed on this system; either \
install libapparmor devel packages, set the LIBAPPARMOR variable \
manually, or build against in-tree libapparmor)
ERROR_MESSAGE = $(error ${nl}\
************************************************************************${nl}\
Unable to find libapparmor installed on this system; either${nl}\
install libapparmor devel packages, set the LIBAPPARMOR variable${nl}\
manually, or build against in-tree libapparmor.${nl}\
************************************************************************${nl})
endif # LIBAPPARMOR not set
LDLIBS += $(LIBAPPARMOR)
@ -26,10 +33,13 @@ else # !USE_SYSTEM
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.)
ERROR_MESSAGE = $(error ${nl}\
************************************************************************${nl}\
$(LIBAPPARMOR_PATH)/libapparmor.a is missing; either build against${nl}\
the in-tree libapparmor by building it first and then trying again${nl}\
(see the top-level README for help) or build against the system${nl}\
libapparmor by adding USE_SYSTEM=1 to your make command.${nl}\
************************************************************************${nl})
endif
CFLAGS += -L$(LIBAPPARMOR_PATH) -I$(LIBAPPARMOR_INCLUDE)
@ -174,11 +184,7 @@ RISKY_TESTS=
.PHONY: libapparmor_check
.SILENT: libapparmor_check
libapparmor_check:
@if [ -n "$(ERROR_MESSAGE)" ] ; then \
echo "$(ERROR_MESSAGE)" 1>&2 ; \
return 1 ; \
fi
libapparmor_check: ; $(ERROR_MESSAGE)
all: libapparmor_check $(EXEC) changehat.h uservars.inc