1 # 2 # Makefile for building the checkpolicy program 3 # 4 LINGUAS ?= ru 5 PREFIX ?= /usr 6 BINDIR ?= $(PREFIX)/bin 7 MANDIR ?= $(PREFIX)/share/man 8 TARGETS = checkpolicy checkmodule 9 10 LEX = flex 11 YACC = bison -y 12 13 CFLAGS ?= -g -Wall -Werror -Wshadow -O2 -pipe -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 18 ifeq ($(LIBSEPOLA),) 19 LDLIBS_LIBSEPOLA := -l:libsepol.a 20 endif 21 22 CHECKOBJS = y.tab.o lex.yy.o queue.o module_compiler.o parse_util.o \ 23 policy_define.o 24 CHECKPOLOBJS = $(CHECKOBJS) checkpolicy.o 25 CHECKMODOBJS = $(CHECKOBJS) checkmodule.o 26 27 GENERATED=lex.yy.c y.tab.c y.tab.h 28 29 all: $(TARGETS) 30 $(MAKE) -C test 31 32 checkpolicy: $(CHECKPOLOBJS) $(LIBSEPOLA) 33 $(CC) -o $@ $^ $(LDFLAGS) $(LDLIBS_LIBSEPOLA) 34 35 checkmodule: $(CHECKMODOBJS) $(LIBSEPOLA) 36 $(CC) -o $@ $^ $(LDFLAGS) $(LDLIBS_LIBSEPOLA) 37 38 %.o: %.c 39 $(CC) $(CFLAGS) -o $@ -c $< 40 41 y.tab.o: y.tab.c 42 $(CC) $(filter-out -Werror, $(CFLAGS)) -o $@ -c $< 43 44 lex.yy.o: lex.yy.c 45 $(CC) $(filter-out -Werror, $(CFLAGS)) -o $@ -c $< 46 47 y.tab.c: policy_parse.y 48 $(YACC) -d policy_parse.y 49 50 lex.yy.c: policy_scan.l y.tab.c 51 $(LEX) policy_scan.l 52 53 install: 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 66 relabel: install 67 /sbin/restorecon $(DESTDIR)$(BINDIR)/checkpolicy 68 /sbin/restorecon $(DESTDIR)$(BINDIR)/checkmodule 69 70 clean: 71 -rm -f $(TARGETS) $(CHECKPOLOBJS) $(CHECKMODOBJS) y.tab.c y.tab.h lex.yy.c 72 $(MAKE) -C test clean 73 74 indent: 75 ../scripts/Lindent $(filter-out $(GENERATED),$(wildcard *.[ch])) 76