Makefile: define a default value for CFLAGS
When building the project with "make DESTDIR=... install", the root Makefile defines CFLAGS and LDFLAGS without any warning flags ("CFLAGS += -I$(DESTDIR)/usr/include" and "LDFLAGS += -L$(DESTDIR)/usr/lib"). As the Makefiles in subdirectories do not override the flags with warning flags, the code gets compiled without any enabled warning. This leads for example to code being introduced which breaks building libsepol from its directory, while building it from the root Makefile still works fine. This issue can be fixed by defining a set of flags in the root Makefile which are used by all Makefiles in subdirectories. The flags have been chosen following these principles: * they are compatible with both clang and gcc, * they already appear in at least one Makefile, and * they are not triggered with the current git master version. Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
This commit is contained in:
parent
04fb15deb7
commit
7e9d1344db
1 changed files with 10 additions and 0 deletions
10
Makefile
10
Makefile
|
@ -6,6 +6,16 @@ DISTCLEANSUBDIRS=libselinux libsemanage
|
|||
ifeq ($(DEBUG),1)
|
||||
export CFLAGS = -g3 -O0 -gdwarf-2 -fno-strict-aliasing -Wall -Wshadow -Werror
|
||||
export LDFLAGS = -g
|
||||
else
|
||||
export CFLAGS ?= -O2 -Werror -Wall -Wextra \
|
||||
-Wmissing-format-attribute \
|
||||
-Wmissing-noreturn \
|
||||
-Wpointer-arith \
|
||||
-Wshadow \
|
||||
-Wstrict-prototypes \
|
||||
-Wundef \
|
||||
-Wunused \
|
||||
-Wwrite-strings
|
||||
endif
|
||||
|
||||
ifneq ($(DESTDIR),)
|
||||
|
|
Loading…
Reference in a new issue