1PREFIX ?= /usr
2OPT_SUBDIRS ?= dbus gui mcstrans python restorecond sandbox semodule-utils
3SUBDIRS=libsepol libselinux libsemanage checkpolicy secilc policycoreutils $(OPT_SUBDIRS)
4PYSUBDIRS=libselinux libsemanage
5DISTCLEANSUBDIRS=libselinux libsemanage
6
7ifeq ($(DEBUG),1)
8	export CFLAGS = -g3 -O0 -gdwarf-2 -fno-strict-aliasing -Wall -Wshadow -Werror
9	export LDFLAGS = -g
10else
11	export CFLAGS ?= -O2 -Werror -Wall -Wextra \
12		-Wmissing-format-attribute \
13		-Wmissing-noreturn \
14		-Wpointer-arith \
15		-Wshadow \
16		-Wstrict-prototypes \
17		-Wundef \
18		-Wunused \
19		-Wwrite-strings
20endif
21
22ifneq ($(DESTDIR),)
23	LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
24	LIBSEPOLA ?= $(LIBDIR)/libsepol.a
25
26	CFLAGS += -I$(DESTDIR)$(PREFIX)/include
27	LDFLAGS += -L$(DESTDIR)$(PREFIX)/lib -L$(LIBDIR)
28	export CFLAGS
29	export LDFLAGS
30	export LIBSEPOLA
31endif
32
33all install relabel clean test indent:
34	@for subdir in $(SUBDIRS); do \
35		(cd $$subdir && $(MAKE) $@) || exit 1; \
36	done
37
38install-pywrap install-rubywrap swigify:
39	@for subdir in $(PYSUBDIRS); do \
40		(cd $$subdir && $(MAKE) $@) || exit 1; \
41	done
42
43distclean:
44	@for subdir in $(DISTCLEANSUBDIRS); do \
45		(cd $$subdir && $(MAKE) $@) || exit 1; \
46	done
47