xref: /aosp_15_r20/external/selinux/libselinux/utils/Makefile (revision 2d543d20722ada2425b5bdab9d0d1d29470e7bba)
1# Installation directories.
2PREFIX ?= /usr
3SBINDIR ?= $(PREFIX)/sbin
4
5OS ?= $(shell uname)
6
7ifeq ($(shell $(CC) -v 2>&1 | grep "clang"),)
8COMPILER ?= gcc
9else
10COMPILER ?= clang
11endif
12
13ifeq ($(COMPILER), gcc)
14EXTRA_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
18endif
19
20MAX_STACK_SIZE=8192
21CFLAGS ?= -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 \
36          -Werror -Wno-aggregate-return -Wno-redundant-decls -Wstrict-overflow=5 \
37          $(EXTRA_CFLAGS)
38
39ifeq ($(OS), Darwin)
40override CFLAGS += -I/opt/local/include -I../../libsepol/include
41override LDFLAGS += -L../../libsepol/src -undefined dynamic_lookup
42endif
43
44override CFLAGS += -I../include -D_GNU_SOURCE $(DISABLE_FLAGS) $(PCRE_CFLAGS)
45override LDFLAGS += -L../src
46override LDLIBS += -lselinux $(FTS_LDLIBS)
47
48ifeq ($(ANDROID_HOST),y)
49TARGETS=sefcontext_compile
50else
51TARGETS=$(patsubst %.c,%,$(sort $(wildcard *.c)))
52endif
53
54sefcontext_compile: LDLIBS += ../src/libselinux.a $(PCRE_LDLIBS) -lsepol
55
56all: $(TARGETS)
57
58install: all
59	-mkdir -p $(DESTDIR)$(SBINDIR)
60	install -m 755 $(TARGETS) $(DESTDIR)$(SBINDIR)
61
62clean:
63	rm -f $(TARGETS) *.o *~
64
65distclean: clean
66
67indent:
68	../../scripts/Lindent $(wildcard *.[ch])
69
70relabel:
71
72