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