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