2008-08-19 19:30:36 +00:00
|
|
|
# Installation directories.
|
2018-02-14 09:57:04 +00:00
|
|
|
PREFIX ?= /usr
|
2017-06-20 14:49:57 +00:00
|
|
|
SBINDIR ?= $(PREFIX)/sbin
|
2008-08-19 19:30:36 +00:00
|
|
|
|
2016-11-14 18:05:09 +00:00
|
|
|
OS ?= $(shell uname)
|
|
|
|
|
|
|
|
ifeq ($(shell $(CC) -v 2>&1 | grep "clang"),)
|
|
|
|
COMPILER ?= gcc
|
|
|
|
else
|
|
|
|
COMPILER ?= clang
|
|
|
|
endif
|
|
|
|
|
2017-05-09 14:47:39 +00:00
|
|
|
ifeq ($(COMPILER), gcc)
|
|
|
|
EXTRA_CFLAGS = -fipa-pure-const -Wpacked-bitfield-compat -Wsync-nand -Wcoverage-mismatch \
|
|
|
|
-Wcpp -Wformat-contains-nul -Wnormalized=nfc -Wsuggest-attribute=const \
|
|
|
|
-Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wtrampolines -Wjump-misses-init \
|
|
|
|
-Wno-suggest-attribute=pure -Wno-suggest-attribute=const
|
|
|
|
endif
|
|
|
|
|
2012-01-23 15:41:21 +00:00
|
|
|
MAX_STACK_SIZE=8192
|
2012-05-25 11:11:51 +00:00
|
|
|
CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k -Wformat-security -Winit-self -Wmissing-include-dirs \
|
2012-01-23 15:41:21 +00:00
|
|
|
-Wunused -Wunknown-pragmas -Wstrict-aliasing -Wshadow -Wpointer-arith \
|
2016-10-17 20:24:08 +00:00
|
|
|
-Wbad-function-cast -Wcast-align -Wwrite-strings -Waggregate-return \
|
2012-01-23 15:41:21 +00:00
|
|
|
-Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes \
|
|
|
|
-Wmissing-declarations -Wmissing-noreturn -Wmissing-format-attribute \
|
|
|
|
-Wredundant-decls -Wnested-externs -Winline -Winvalid-pch -Wvolatile-register-var \
|
2016-10-17 20:24:08 +00:00
|
|
|
-Wdisabled-optimization -Wbuiltin-macro-redefined \
|
|
|
|
-Wattributes -Wmultichar \
|
2012-01-23 15:41:21 +00:00
|
|
|
-Wdeprecated-declarations -Wdiv-by-zero -Wdouble-promotion -Wendif-labels -Wextra \
|
2016-10-17 20:24:08 +00:00
|
|
|
-Wformat-extra-args -Wformat-zero-length -Wformat=2 -Wmultichar \
|
|
|
|
-Woverflow -Wpointer-to-int-cast -Wpragmas \
|
|
|
|
-Wno-missing-field-initializers -Wno-sign-compare \
|
2018-12-26 14:48:20 +00:00
|
|
|
-Wno-format-nonliteral -Wframe-larger-than=$(MAX_STACK_SIZE) -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 \
|
2012-01-23 15:41:21 +00:00
|
|
|
-fstack-protector-all --param=ssp-buffer-size=4 -fexceptions \
|
|
|
|
-fasynchronous-unwind-tables -fdiagnostics-show-option -funit-at-a-time \
|
2018-12-13 21:30:44 +00:00
|
|
|
-Werror -Wno-aggregate-return -Wno-redundant-decls -Wstrict-overflow=5 \
|
2017-05-09 14:47:39 +00:00
|
|
|
$(EXTRA_CFLAGS)
|
2016-10-17 20:24:08 +00:00
|
|
|
|
|
|
|
LD_SONAME_FLAGS=-soname,$(LIBSO),-z,defs,-z,relro
|
|
|
|
|
|
|
|
ifeq ($(OS), Darwin)
|
|
|
|
override CFLAGS += -I/opt/local/include -I../../libsepol/include
|
|
|
|
override LDFLAGS += -L../../libsepol/src -undefined dynamic_lookup
|
|
|
|
endif
|
|
|
|
|
2017-04-24 17:59:56 +00:00
|
|
|
override CFLAGS += -I../include -D_GNU_SOURCE $(DISABLE_FLAGS) $(PCRE_CFLAGS)
|
2017-06-18 07:41:49 +00:00
|
|
|
override LDFLAGS += -L../src
|
|
|
|
override LDLIBS += -lselinux
|
2017-04-24 17:59:55 +00:00
|
|
|
PCRE_LDLIBS ?= -lpcre
|
2008-08-19 19:30:36 +00:00
|
|
|
|
2016-09-28 16:17:59 +00:00
|
|
|
ifeq ($(ANDROID_HOST),y)
|
|
|
|
TARGETS=sefcontext_compile
|
|
|
|
else
|
2017-05-30 14:21:32 +00:00
|
|
|
TARGETS=$(patsubst %.c,%,$(sort $(wildcard *.c)))
|
2016-09-28 16:17:59 +00:00
|
|
|
endif
|
2009-05-07 20:05:05 +00:00
|
|
|
|
2017-04-24 17:59:55 +00:00
|
|
|
sefcontext_compile: LDLIBS += $(PCRE_LDLIBS) ../src/libselinux.a -lsepol
|
2016-09-15 16:14:33 +00:00
|
|
|
|
|
|
|
sefcontext_compile: sefcontext_compile.o ../src/regex.o
|
2009-05-07 20:05:05 +00:00
|
|
|
|
2012-01-27 19:41:58 +00:00
|
|
|
all: $(TARGETS)
|
2008-08-19 19:30:36 +00:00
|
|
|
|
|
|
|
install: all
|
2018-02-14 09:57:04 +00:00
|
|
|
-mkdir -p $(DESTDIR)$(SBINDIR)
|
|
|
|
install -m 755 $(TARGETS) $(DESTDIR)$(SBINDIR)
|
2016-12-21 21:09:51 +00:00
|
|
|
|
2008-08-19 19:30:36 +00:00
|
|
|
clean:
|
2012-01-27 19:41:58 +00:00
|
|
|
rm -f $(TARGETS) *.o *~
|
2008-08-19 19:30:36 +00:00
|
|
|
|
2012-01-27 19:00:34 +00:00
|
|
|
distclean: clean
|
|
|
|
|
2008-08-19 19:30:36 +00:00
|
|
|
indent:
|
|
|
|
../../scripts/Lindent $(wildcard *.[ch])
|
|
|
|
|
|
|
|
relabel:
|
|
|
|
|