1PYTHON ?= python3
2SECILC ?= secilc
3
4# Installation directories.
5LINGUAS ?= ru
6PREFIX ?= /usr
7BINDIR ?= $(PREFIX)/bin
8MANDIR ?= $(PREFIX)/share/man
9
10CFLAGS ?= -Werror -Wall -W
11
12# If no specific libsepol.a is specified, fall back on LDFLAGS search path
13# Otherwise, as $(LIBSEPOLA) already appears in the dependencies, there
14# is no need to define a value for LDLIBS_LIBSEPOLA
15ifeq ($(LIBSEPOLA),)
16        LDLIBS_LIBSEPOLA := -l:libsepol.a
17endif
18
19all: audit2why sepolgen-ifgen-attr-helper
20
21sepolgen-ifgen-attr-helper: sepolgen-ifgen-attr-helper.o $(LIBSEPOLA)
22	$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS_LIBSEPOLA)
23
24audit2why:
25	ln -sf audit2allow audit2why
26
27test: all test_dummy_policy
28	@$(PYTHON) test_audit2allow.py -v
29
30test_dummy_policy: test_dummy_policy.cil
31	$(SECILC) -o $@ -f /dev/null $<
32
33install: all
34	-mkdir -p $(DESTDIR)$(BINDIR)
35	install -m 755 audit2allow $(DESTDIR)$(BINDIR)
36	(cd $(DESTDIR)$(BINDIR); ln -sf audit2allow audit2why)
37	install -m 755 sepolgen-ifgen-attr-helper $(DESTDIR)$(BINDIR)
38	install -m 755 sepolgen-ifgen $(DESTDIR)$(BINDIR)
39	-mkdir -p $(DESTDIR)$(MANDIR)/man1
40	install -m 644 audit2allow.1 $(DESTDIR)$(MANDIR)/man1/
41	install -m 644 audit2why.1 $(DESTDIR)$(MANDIR)/man1/
42	for lang in $(LINGUAS) ; do \
43		if [ -e $${lang} ] ; then \
44			mkdir -p $(DESTDIR)$(MANDIR)/$${lang}/man1 ; \
45			install -m 644 $${lang}/*.1 $(DESTDIR)$(MANDIR)/$${lang}/man1/ ; \
46		fi ; \
47	done
48
49clean:
50	rm -f *~ *.o sepolgen-ifgen-attr-helper test_dummy_policy
51
52indent:
53	../../scripts/Lindent $(wildcard *.[ch])
54
55relabel: ;
56