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