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