2008-08-19 19:30:36 +00:00
|
|
|
# Installation directories.
|
|
|
|
PREFIX ?= $(DESTDIR)/usr
|
|
|
|
LIBDIR ?= $(PREFIX)/lib
|
2016-12-21 21:09:51 +00:00
|
|
|
USRSBINDIR ?= $(PREFIX)/sbin
|
2016-08-04 12:44:06 +00:00
|
|
|
INCLUDEDIR ?= $(PREFIX)/include
|
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
|
|
|
|
|
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 \
|
2012-01-23 15:41:21 +00:00
|
|
|
-Wno-format-nonliteral -Wframe-larger-than=$(MAX_STACK_SIZE) -Wp,-D_FORTIFY_SOURCE=2 \
|
|
|
|
-fstack-protector-all --param=ssp-buffer-size=4 -fexceptions \
|
|
|
|
-fasynchronous-unwind-tables -fdiagnostics-show-option -funit-at-a-time \
|
|
|
|
-Werror -Wno-aggregate-return -Wno-redundant-decls
|
2016-10-17 20:24:08 +00:00
|
|
|
|
|
|
|
LD_SONAME_FLAGS=-soname,$(LIBSO),-z,defs,-z,relro
|
|
|
|
|
|
|
|
ifeq ($(COMPILER), gcc)
|
2016-11-14 18:05:09 +00:00
|
|
|
CFLAGS += -fipa-pure-const -Wpacked-bitfield-compat -Wsync-nand -Wcoverage-mismatch \
|
2016-10-17 20:24:08 +00:00
|
|
|
-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
|
|
|
|
|
|
|
|
ifeq ($(OS), Darwin)
|
|
|
|
override CFLAGS += -I/opt/local/include -I../../libsepol/include
|
|
|
|
override LDFLAGS += -L../../libsepol/src -undefined dynamic_lookup
|
|
|
|
endif
|
|
|
|
|
2016-09-28 16:00:23 +00:00
|
|
|
override CFLAGS += -I../include -I$(INCLUDEDIR) -D_GNU_SOURCE $(DISABLE_FLAGS) $(PCRE_CFLAGS)
|
2008-08-19 19:30:36 +00:00
|
|
|
LDLIBS += -L../src -lselinux -L$(LIBDIR)
|
2016-09-15 16:14:33 +00:00
|
|
|
PCRE_LDFLAGS ?= -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
|
2008-08-19 19:30:36 +00:00
|
|
|
TARGETS=$(patsubst %.c,%,$(wildcard *.c))
|
2016-09-28 16:17:59 +00:00
|
|
|
endif
|
2009-05-07 20:05:05 +00:00
|
|
|
|
2016-09-15 16:14:33 +00:00
|
|
|
sefcontext_compile: LDLIBS += $(PCRE_LDFLAGS) ../src/libselinux.a -lsepol
|
|
|
|
|
|
|
|
sefcontext_compile: sefcontext_compile.o ../src/regex.o
|
2009-05-07 20:05:05 +00:00
|
|
|
|
2015-10-23 13:30:27 +00:00
|
|
|
selinux_restorecon: LDLIBS += -lsepol
|
|
|
|
|
2012-01-27 19:41:58 +00:00
|
|
|
all: $(TARGETS)
|
2008-08-19 19:30:36 +00:00
|
|
|
|
|
|
|
install: all
|
2016-12-21 21:09:51 +00:00
|
|
|
-mkdir -p $(USRSBINDIR)
|
|
|
|
install -m 755 $(TARGETS) $(USRSBINDIR)
|
|
|
|
|
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:
|
|
|
|
|