platform_external_selinux/Makefile
Nicolas Iooss 7e9d1344db 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>
2017-09-05 12:37:41 -04:00

41 lines
1 KiB
Makefile

OPT_SUBDIRS ?= dbus gui mcstrans python restorecond sandbox semodule-utils
SUBDIRS=libsepol libselinux libsemanage checkpolicy secilc policycoreutils $(OPT_SUBDIRS)
PYSUBDIRS=libselinux libsemanage
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),)
CFLAGS += -I$(DESTDIR)/usr/include
LDFLAGS += -L$(DESTDIR)/usr/lib
export CFLAGS
export LDFLAGS
endif
all install relabel clean test indent:
@for subdir in $(SUBDIRS); do \
(cd $$subdir && $(MAKE) $@) || exit 1; \
done
install-pywrap install-rubywrap swigify:
@for subdir in $(PYSUBDIRS); do \
(cd $$subdir && $(MAKE) $@) || exit 1; \
done
distclean:
@for subdir in $(DISTCLEANSUBDIRS); do \
(cd $$subdir && $(MAKE) $@) || exit 1; \
done