mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-30 05:47:59 +00:00
build: add and use global EXTRA_WARNINGS from common/Make.rules
Define EXTRA_WARNINGS in the common/Make.rules helper so that adding additional warnings can be done in one(-ish) location, and replace locally defined C compiler warning flags with EXTRA_WARNINGS in most locations in the build tree. v2: issue a warning for any compiler option that the compiler does not support Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
This commit is contained in:
parent
d29bf02d7b
commit
e093815ab1
@ -24,7 +24,6 @@ LOCALEDIR=/usr/share/locale
|
|||||||
MANPAGES=aa-enabled.1 aa-exec.1 aa-status.8
|
MANPAGES=aa-enabled.1 aa-exec.1 aa-status.8
|
||||||
|
|
||||||
WARNINGS = -Wall
|
WARNINGS = -Wall
|
||||||
EXTRA_WARNINGS = -Wsign-compare -Wmissing-field-initializers -Wformat -Wformat-security -Wunused-parameter
|
|
||||||
CPP_WARNINGS =
|
CPP_WARNINGS =
|
||||||
ifndef CFLAGS
|
ifndef CFLAGS
|
||||||
CFLAGS = -g -O2 -pipe
|
CFLAGS = -g -O2 -pipe
|
||||||
|
@ -70,7 +70,7 @@ libapparmor by adding USE_SYSTEM=1 to your make command.${nl}\
|
|||||||
LDLIBS = -lapparmor
|
LDLIBS = -lapparmor
|
||||||
endif
|
endif
|
||||||
|
|
||||||
APXS_CFLAGS="-Wc,-Wsign-compare -Wmissing-field-initializers -Wformat -Wformat-security -Wunused-parameter"
|
APXS_CFLAGS="-Wc,$(EXTRA_WARNINGS)"
|
||||||
|
|
||||||
.PHONY: libapparmor_check
|
.PHONY: libapparmor_check
|
||||||
.SILENT: libapparmor_check
|
.SILENT: libapparmor_check
|
||||||
|
@ -54,7 +54,7 @@ libapparmor by adding USE_SYSTEM=1 to your make command.${nl}\
|
|||||||
AA_LINK_FLAGS = -L$(LIBAPPARMOR_PATH)
|
AA_LINK_FLAGS = -L$(LIBAPPARMOR_PATH)
|
||||||
AA_LDLIBS = -lapparmor
|
AA_LDLIBS = -lapparmor
|
||||||
endif
|
endif
|
||||||
EXTRA_CFLAGS=$(CFLAGS) $(CPPFLAGS) -fPIC -shared -Wall -Wsign-compare -Wmissing-field-initializers -Wformat -Wformat-security -Wunused-parameter $(LIBAPPARMOR_INCLUDE)
|
EXTRA_CFLAGS=$(CFLAGS) $(CPPFLAGS) -fPIC -shared -Wall $(EXTRA_WARNINGS) $(LIBAPPARMOR_INCLUDE)
|
||||||
LINK_FLAGS=-Xlinker -x $(AA_LINK_FLAGS) $(LDFLAGS)
|
LINK_FLAGS=-Xlinker -x $(AA_LINK_FLAGS) $(LDFLAGS)
|
||||||
LIBS=-lpam $(AA_LDLIBS)
|
LIBS=-lpam $(AA_LDLIBS)
|
||||||
OBJECTS=${NAME}.o get_options.o
|
OBJECTS=${NAME}.o get_options.o
|
||||||
|
@ -57,6 +57,18 @@ endif
|
|||||||
#Helper function to be used with $(call pyalldo, run_test_with_all.py)
|
#Helper function to be used with $(call pyalldo, run_test_with_all.py)
|
||||||
pyalldo=set -e; $(foreach py, $(PYTHON_VERSIONS), $(py) $(1);)
|
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
|
||||||
|
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
|
.PHONY: version
|
||||||
.SILENT: version
|
.SILENT: version
|
||||||
version:
|
version:
|
||||||
|
@ -32,10 +32,13 @@ AA_LIB_AGE = 6
|
|||||||
|
|
||||||
SUFFIXES = .pc.in .pc
|
SUFFIXES = .pc.in .pc
|
||||||
|
|
||||||
|
COMMONDIR=$(top_srcdir)/../../common/
|
||||||
|
include $(COMMONDIR)/Make.rules
|
||||||
|
|
||||||
BUILT_SOURCES = grammar.h scanner.h af_protos.h
|
BUILT_SOURCES = grammar.h scanner.h af_protos.h
|
||||||
AM_LFLAGS = -v
|
AM_LFLAGS = -v
|
||||||
AM_YFLAGS = -d -p aalogparse_
|
AM_YFLAGS = -d -p aalogparse_
|
||||||
AM_CFLAGS = -Wall -Wsign-compare -Wmissing-field-initializers -Wformat -Wformat-security -Wunused-parameter -fPIC
|
AM_CFLAGS = -Wall $(EXTRA_WARNINGS) -fPIC
|
||||||
AM_CPPFLAGS = -D_GNU_SOURCE -I$(top_srcdir)/include/
|
AM_CPPFLAGS = -D_GNU_SOURCE -I$(top_srcdir)/include/
|
||||||
scanner.h: scanner.l
|
scanner.h: scanner.l
|
||||||
$(LEX) -v $<
|
$(LEX) -v $<
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
if HAVE_PYTHON
|
if HAVE_PYTHON
|
||||||
|
|
||||||
|
COMMONDIR = $(top_srcdir)/../../common/
|
||||||
|
include $(COMMONDIR)/Make.rules
|
||||||
|
|
||||||
EXTRA_DIST = libapparmor_wrap.c
|
EXTRA_DIST = libapparmor_wrap.c
|
||||||
|
|
||||||
SUBDIRS = test
|
SUBDIRS = test
|
||||||
@ -11,7 +14,7 @@ MOSTLYCLEANFILES=libapparmor_wrap.c LibAppArmor.py
|
|||||||
|
|
||||||
all-local: libapparmor_wrap.c setup.py
|
all-local: libapparmor_wrap.c setup.py
|
||||||
if test ! -f libapparmor_wrap.c; then cp $(srcdir)/libapparmor_wrap.c . ; fi
|
if test ! -f libapparmor_wrap.c; then cp $(srcdir)/libapparmor_wrap.c . ; fi
|
||||||
CC="$(CC)" CFLAGS="$(PYTHON_CPPFLAGS)" LDSHARED="$(CC) -shared" LDFLAGS="$(PYTHON_LDFLAGS)" $(PYTHON) setup.py build
|
CC="$(CC)" CFLAGS="$(PYTHON_CPPFLAGS) $(EXTRA_WARNINGS)" LDSHARED="$(CC) -shared" LDFLAGS="$(PYTHON_LDFLAGS)" $(PYTHON) setup.py build
|
||||||
|
|
||||||
install-exec-local:
|
install-exec-local:
|
||||||
$(PYTHON) setup.py install --root="/$(DESTDIR)" --prefix="$(prefix)"
|
$(PYTHON) setup.py install --root="/$(DESTDIR)" --prefix="$(prefix)"
|
||||||
|
@ -2,6 +2,9 @@ SUBDIRS = lib config libaalogparse.test
|
|||||||
PACKAGE = libaalogparse
|
PACKAGE = libaalogparse
|
||||||
AUTOMAKE_OPTIONS = dejagnu
|
AUTOMAKE_OPTIONS = dejagnu
|
||||||
|
|
||||||
|
COMMONDIR=$(top_srcdir)/../../common
|
||||||
|
include $(COMMONDIR)/Make.rules
|
||||||
|
|
||||||
INCLUDES = -I. -I$(top_srcdir)/include
|
INCLUDES = -I. -I$(top_srcdir)/include
|
||||||
|
|
||||||
AM_CPPFLAGS = $(DEBUG_FLAGS) -DLOCALEDIR=\"${localedir}\"
|
AM_CPPFLAGS = $(DEBUG_FLAGS) -DLOCALEDIR=\"${localedir}\"
|
||||||
@ -10,7 +13,7 @@ AM_CFLAGS = -Wall
|
|||||||
noinst_PROGRAMS = test_multi.multi
|
noinst_PROGRAMS = test_multi.multi
|
||||||
|
|
||||||
test_multi_multi_SOURCES = test_multi.c
|
test_multi_multi_SOURCES = test_multi.c
|
||||||
test_multi_multi_CFLAGS = -Wall
|
test_multi_multi_CFLAGS = -Wall $(EXTRA_WARNINGS)
|
||||||
test_multi_multi_LDADD = -L../src/.libs -lapparmor
|
test_multi_multi_LDADD = -L../src/.libs -lapparmor
|
||||||
|
|
||||||
clean-local:
|
clean-local:
|
||||||
|
@ -37,12 +37,7 @@ YFLAGS := -d
|
|||||||
LEX := flex
|
LEX := flex
|
||||||
LEXFLAGS = -B -v
|
LEXFLAGS = -B -v
|
||||||
WARNINGS = -Wall
|
WARNINGS = -Wall
|
||||||
EXTRA_WARNINGS = -Wsign-compare -Wmissing-field-initializers -Wformat -Wformat-security -Wunused-parameter
|
CXX_WARNINGS = ${WARNINGS} ${EXTRA_WARNINGS}
|
||||||
CXX_WARNINGS = ${WARNINGS} $(shell for warning in ${EXTRA_WARNINGS} ; do \
|
|
||||||
if ${CXX} $${warning} -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then \
|
|
||||||
echo "$${warning}"; \
|
|
||||||
fi ; \
|
|
||||||
done)
|
|
||||||
CPP_WARNINGS =
|
CPP_WARNINGS =
|
||||||
ifndef CFLAGS
|
ifndef CFLAGS
|
||||||
CFLAGS = -g -O2 -pipe
|
CFLAGS = -g -O2 -pipe
|
||||||
|
@ -67,7 +67,7 @@ system aa-exec by adding USE_SYSTEM=1 to your make command.${nl}\
|
|||||||
LDLIBS += -Wl,-Bstatic -lapparmor -Wl,-Bdynamic -lpthread
|
LDLIBS += -Wl,-Bstatic -lapparmor -Wl,-Bdynamic -lpthread
|
||||||
endif # USE_SYSTEM
|
endif # USE_SYSTEM
|
||||||
|
|
||||||
CFLAGS += -g -O0 -Wall -Wstrict-prototypes -Wsign-compare -Wmissing-field-initializers -Wformat -Wformat-security -Wunused-parameter
|
CFLAGS += -g -O0 $(EXTRA_WARNINGS)
|
||||||
|
|
||||||
SRC=access.c \
|
SRC=access.c \
|
||||||
at_secure.c \
|
at_secure.c \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user