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