1# 2# Makefile for building the checkpolicy program 3# 4LINGUAS ?= ru 5PREFIX ?= /usr 6BINDIR ?= $(PREFIX)/bin 7MANDIR ?= $(PREFIX)/share/man 8TARGETS = checkpolicy checkmodule 9 10LEX = flex 11YACC = bison -y 12 13CFLAGS ?= -g -Wall -Werror -Wshadow -O2 -fno-strict-aliasing 14 15# If no specific libsepol.a is specified, fall back on LDFLAGS search path 16# Otherwise, as $(LIBSEPOLA) already appears in the dependencies, there 17# is no need to define a value for LDLIBS_LIBSEPOLA 18ifeq ($(LIBSEPOLA),) 19 LDLIBS_LIBSEPOLA := -l:libsepol.a 20endif 21 22CHECKOBJS = y.tab.o lex.yy.o queue.o module_compiler.o parse_util.o \ 23 policy_define.o 24CHECKPOLOBJS = $(CHECKOBJS) checkpolicy.o 25CHECKMODOBJS = $(CHECKOBJS) checkmodule.o 26 27GENERATED=lex.yy.c y.tab.c y.tab.h 28 29all: $(TARGETS) 30 $(MAKE) -C test 31 32checkpolicy: $(CHECKPOLOBJS) $(LIBSEPOLA) 33 $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LDLIBS_LIBSEPOLA) 34 35checkmodule: $(CHECKMODOBJS) $(LIBSEPOLA) 36 $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LDLIBS_LIBSEPOLA) 37 38%.o: %.c 39 $(CC) $(CFLAGS) -o $@ -c $< 40 41y.tab.o: y.tab.c 42 $(CC) $(filter-out -Werror, $(CFLAGS)) -o $@ -c $< 43 44lex.yy.o: lex.yy.c 45 $(CC) $(filter-out -Werror, $(CFLAGS)) -o $@ -c $< 46 47y.tab.c: policy_parse.y 48 $(YACC) -d policy_parse.y 49 50lex.yy.c: policy_scan.l y.tab.c 51 $(LEX) policy_scan.l 52 53install: all 54 -mkdir -p $(DESTDIR)$(BINDIR) 55 -mkdir -p $(DESTDIR)$(MANDIR)/man8 56 install -m 755 $(TARGETS) $(DESTDIR)$(BINDIR) 57 install -m 644 checkpolicy.8 $(DESTDIR)$(MANDIR)/man8 58 install -m 644 checkmodule.8 $(DESTDIR)$(MANDIR)/man8 59 for lang in $(LINGUAS) ; do \ 60 if [ -e $${lang} ] ; then \ 61 mkdir -p $(DESTDIR)$(MANDIR)/$${lang}/man8 ; \ 62 install -m 644 $${lang}/*.8 $(DESTDIR)$(MANDIR)/$${lang}/man8 ; \ 63 fi ; \ 64 done 65 66relabel: install 67 /sbin/restorecon $(DESTDIR)$(BINDIR)/checkpolicy 68 /sbin/restorecon $(DESTDIR)$(BINDIR)/checkmodule 69 70clean: 71 -rm -f $(TARGETS) $(CHECKPOLOBJS) $(CHECKMODOBJS) y.tab.c y.tab.h lex.yy.c 72 $(MAKE) -C test clean 73 74indent: 75 ../scripts/Lindent $(filter-out $(GENERATED),$(wildcard *.[ch])) 76