1# 2# Makefile for building the checkpolicy program 3# 4PREFIX ?= $(DESTDIR)/usr 5BINDIR ?= $(PREFIX)/bin 6MANDIR ?= $(PREFIX)/share/man 7LIBDIR ?= $(PREFIX)/lib 8INCLUDEDIR ?= $(PREFIX)/include 9LIBSEPOLA ?= $(LIBDIR)/libsepol.a 10TARGETS = checkpolicy checkmodule 11 12LEX = flex 13YACC = bison -y 14 15CFLAGS ?= -g -Wall -Werror -Wshadow -O2 -pipe -fno-strict-aliasing 16 17override CFLAGS += -I. 18 19CHECKOBJS = y.tab.o lex.yy.o queue.o module_compiler.o parse_util.o \ 20 policy_define.o 21CHECKPOLOBJS = $(CHECKOBJS) checkpolicy.o 22CHECKMODOBJS = $(CHECKOBJS) checkmodule.o 23 24GENERATED=lex.yy.c y.tab.c y.tab.h 25 26all: $(TARGETS) 27 $(MAKE) -C test 28 29checkpolicy: $(CHECKPOLOBJS) $(LIBSEPOLA) 30 31checkmodule: $(CHECKMODOBJS) $(LIBSEPOLA) 32 33%.o: %.c 34 $(CC) $(CFLAGS) -o $@ -c $< 35 36y.tab.o: y.tab.c 37 $(CC) $(filter-out -Werror, $(CFLAGS)) -o $@ -c $< 38 39lex.yy.o: lex.yy.c 40 $(CC) $(filter-out -Werror, $(CFLAGS)) -o $@ -c $< 41 42y.tab.c: policy_parse.y 43 $(YACC) -d policy_parse.y 44 45lex.yy.c: policy_scan.l y.tab.c 46 $(LEX) policy_scan.l 47 48install: all 49 -mkdir -p $(BINDIR) 50 -mkdir -p $(MANDIR)/man8 51 install -m 755 $(TARGETS) $(BINDIR) 52 install -m 644 checkpolicy.8 $(MANDIR)/man8 53 install -m 644 checkmodule.8 $(MANDIR)/man8 54 55relabel: install 56 /sbin/restorecon $(BINDIR)/checkpolicy 57 /sbin/restorecon $(BINDIR)/checkmodule 58 59clean: 60 -rm -f $(TARGETS) $(CHECKPOLOBJS) $(CHECKMODOBJS) y.tab.c y.tab.h lex.yy.c 61 $(MAKE) -C test clean 62 63indent: 64 ../scripts/Lindent $(filter-out $(GENERATED),$(wildcard *.[ch])) 65