1PREFIX ?= /usr 2BINDIR ?= $(PREFIX)/bin 3MANDIR ?= $(PREFIX)/share/man 4 5SECILC = secilc 6SECILC_SRCS := secilc.c 7SECILC_OBJS := $(patsubst %.c,%.o,$(SECILC_SRCS)) 8 9SECIL2CONF = secil2conf 10SECIL2CONF_SRCS := secil2conf.c 11SECIL2CONF_OBJS := $(patsubst %.c,%.o,$(SECIL2CONF_SRCS)) 12 13SECIL2TREE = secil2tree 14SECIL2TREE_SRCS := secil2tree.c 15SECIL2TREE_OBJS := $(patsubst %.c,%.o,$(SECIL2TREE_SRCS)) 16 17SECILC_MANPAGE = secilc.8 18SECIL2CONF_MANPAGE = secil2conf.8 19SECIL2TREE_MANPAGE = secil2tree.8 20XMLTO = xmlto 21DIFF = diff 22 23CHECKPOLICY = checkpolicy 24POL_VERS = $(shell $(CHECKPOLICY) -V | cut -f 1 -d ' ') 25 26CFLAGS ?= -Wall -Wshadow -Wextra -Wundef -Wmissing-format-attribute -Wcast-align -Wstrict-prototypes -Wpointer-arith -Wunused 27 28override CFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 29override LDLIBS += -lsepol 30 31all: $(SECILC) $(SECIL2CONF) $(SECIL2TREE) man 32 33$(SECILC): $(SECILC_OBJS) 34 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS) 35 36test: $(SECILC) 37 ./$(SECILC) test/policy.cil 38 ./$(SECILC) -c $(POL_VERS) -O -M 1 -f /dev/null -o opt-actual.bin test/opt-input.cil 39 $(CHECKPOLICY) -b -C -M -o opt-actual.cil opt-actual.bin >/dev/null 40 $(DIFF) test/opt-expected.cil opt-actual.cil 41 42$(SECIL2CONF): $(SECIL2CONF_OBJS) 43 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS) 44 45$(SECIL2TREE): $(SECIL2TREE_OBJS) 46 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS) 47 48man: $(SECILC_MANPAGE) $(SECIL2CONF_MANPAGE) $(SECIL2TREE_MANPAGE) 49 50$(SECILC_MANPAGE): $(SECILC_MANPAGE).xml 51 $(XMLTO) man $(SECILC_MANPAGE).xml 52 53$(SECIL2CONF_MANPAGE): $(SECIL2CONF_MANPAGE).xml 54 $(XMLTO) man $(SECIL2CONF_MANPAGE).xml 55 56$(SECIL2TREE_MANPAGE): $(SECIL2TREE_MANPAGE).xml 57 $(XMLTO) man $(SECIL2TREE_MANPAGE).xml 58 59install: all man 60 -mkdir -p $(DESTDIR)$(BINDIR) 61 -mkdir -p $(DESTDIR)$(MANDIR)/man8 62 install -m 755 $(SECILC) $(DESTDIR)$(BINDIR) 63 install -m 755 $(SECIL2CONF) $(DESTDIR)$(BINDIR) 64 install -m 755 $(SECIL2TREE) $(DESTDIR)$(BINDIR) 65 install -m 644 $(SECILC_MANPAGE) $(DESTDIR)$(MANDIR)/man8 66 install -m 644 $(SECIL2CONF_MANPAGE) $(DESTDIR)$(MANDIR)/man8 67 install -m 644 $(SECIL2TREE_MANPAGE) $(DESTDIR)$(MANDIR)/man8 68 69doc: 70 $(MAKE) -C docs 71 72clean: 73 rm -f $(SECILC) 74 rm -f $(SECILC_OBJS) 75 rm -f $(SECIL2CONF) 76 rm -f $(SECIL2CONF_OBJS) 77 rm -f $(SECIL2TREE) 78 rm -f $(SECIL2TREE_OBJS) 79 rm -f policy.* 80 rm -f file_contexts 81 rm -f $(SECILC_MANPAGE) 82 rm -f $(SECIL2CONF_MANPAGE) 83 rm -f $(SECIL2TREE_MANPAGE) 84 rm -f opt-actual.cil 85 rm -f opt-actual.bin 86 $(MAKE) -C docs clean 87 88relabel: 89 90.PHONY: all clean test install doc relabel man 91