2008-08-19 19:30:36 +00:00
|
|
|
#
|
|
|
|
# Makefile for building the checkpolicy program
|
|
|
|
#
|
2023-08-14 12:57:37 +00:00
|
|
|
LINGUAS ?=
|
2018-02-14 09:57:06 +00:00
|
|
|
PREFIX ?= /usr
|
2008-08-19 19:30:36 +00:00
|
|
|
BINDIR ?= $(PREFIX)/bin
|
|
|
|
MANDIR ?= $(PREFIX)/share/man
|
|
|
|
TARGETS = checkpolicy checkmodule
|
|
|
|
|
2016-05-16 21:53:12 +00:00
|
|
|
LEX = flex
|
2008-08-19 19:30:36 +00:00
|
|
|
YACC = bison -y
|
|
|
|
|
2021-07-06 17:54:22 +00:00
|
|
|
CFLAGS ?= -g -Wall -Werror -Wshadow -O2 -fno-strict-aliasing
|
2008-08-19 19:30:36 +00:00
|
|
|
|
2018-02-14 09:57:06 +00:00
|
|
|
# If no specific libsepol.a is specified, fall back on LDFLAGS search path
|
|
|
|
# Otherwise, as $(LIBSEPOLA) already appears in the dependencies, there
|
|
|
|
# is no need to define a value for LDLIBS_LIBSEPOLA
|
|
|
|
ifeq ($(LIBSEPOLA),)
|
|
|
|
LDLIBS_LIBSEPOLA := -l:libsepol.a
|
|
|
|
endif
|
2008-08-19 19:30:36 +00:00
|
|
|
|
|
|
|
CHECKOBJS = y.tab.o lex.yy.o queue.o module_compiler.o parse_util.o \
|
|
|
|
policy_define.o
|
|
|
|
CHECKPOLOBJS = $(CHECKOBJS) checkpolicy.o
|
|
|
|
CHECKMODOBJS = $(CHECKOBJS) checkmodule.o
|
|
|
|
|
|
|
|
GENERATED=lex.yy.c y.tab.c y.tab.h
|
|
|
|
|
|
|
|
all: $(TARGETS)
|
|
|
|
$(MAKE) -C test
|
|
|
|
|
2017-01-14 14:38:25 +00:00
|
|
|
checkpolicy: $(CHECKPOLOBJS) $(LIBSEPOLA)
|
2023-12-04 16:49:54 +00:00
|
|
|
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LDLIBS_LIBSEPOLA)
|
2008-08-19 19:30:36 +00:00
|
|
|
|
2017-01-14 14:38:25 +00:00
|
|
|
checkmodule: $(CHECKMODOBJS) $(LIBSEPOLA)
|
2023-12-04 16:49:54 +00:00
|
|
|
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LDLIBS_LIBSEPOLA)
|
2008-08-19 19:30:36 +00:00
|
|
|
|
|
|
|
%.o: %.c
|
2023-12-04 16:49:54 +00:00
|
|
|
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<
|
2008-08-19 19:30:36 +00:00
|
|
|
|
|
|
|
y.tab.o: y.tab.c
|
2023-12-04 16:49:54 +00:00
|
|
|
$(CC) $(filter-out -Werror, $(CPPFLAGS) $(CFLAGS)) -o $@ -c $<
|
2008-08-19 19:30:36 +00:00
|
|
|
|
|
|
|
lex.yy.o: lex.yy.c
|
2023-12-04 16:49:54 +00:00
|
|
|
$(CC) $(filter-out -Werror, $(CPPFLAGS) $(CFLAGS)) -o $@ -c $<
|
2008-08-19 19:30:36 +00:00
|
|
|
|
|
|
|
y.tab.c: policy_parse.y
|
|
|
|
$(YACC) -d policy_parse.y
|
|
|
|
|
|
|
|
lex.yy.c: policy_scan.l y.tab.c
|
|
|
|
$(LEX) policy_scan.l
|
|
|
|
|
2023-11-01 16:37:00 +00:00
|
|
|
.PHONY: test
|
|
|
|
test: checkpolicy
|
|
|
|
./tests/test_roundtrip.sh
|
|
|
|
|
2024-01-22 13:54:53 +00:00
|
|
|
# helper target for fuzzing
|
|
|
|
checkobjects: $(CHECKOBJS)
|
|
|
|
|
2008-08-19 19:30:36 +00:00
|
|
|
install: all
|
2018-02-14 09:57:06 +00:00
|
|
|
-mkdir -p $(DESTDIR)$(BINDIR)
|
|
|
|
-mkdir -p $(DESTDIR)$(MANDIR)/man8
|
|
|
|
install -m 755 $(TARGETS) $(DESTDIR)$(BINDIR)
|
|
|
|
install -m 644 checkpolicy.8 $(DESTDIR)$(MANDIR)/man8
|
|
|
|
install -m 644 checkmodule.8 $(DESTDIR)$(MANDIR)/man8
|
2018-12-25 15:25:05 +00:00
|
|
|
for lang in $(LINGUAS) ; do \
|
|
|
|
if [ -e $${lang} ] ; then \
|
|
|
|
mkdir -p $(DESTDIR)$(MANDIR)/$${lang}/man8 ; \
|
|
|
|
install -m 644 $${lang}/*.8 $(DESTDIR)$(MANDIR)/$${lang}/man8 ; \
|
|
|
|
fi ; \
|
|
|
|
done
|
2008-08-19 19:30:36 +00:00
|
|
|
|
|
|
|
relabel: install
|
2018-02-14 09:57:06 +00:00
|
|
|
/sbin/restorecon $(DESTDIR)$(BINDIR)/checkpolicy
|
|
|
|
/sbin/restorecon $(DESTDIR)$(BINDIR)/checkmodule
|
2008-08-19 19:30:36 +00:00
|
|
|
|
|
|
|
clean:
|
2023-11-01 16:37:00 +00:00
|
|
|
-rm -f $(TARGETS) $(CHECKPOLOBJS) $(CHECKMODOBJS) y.tab.c y.tab.h lex.yy.c tests/testpol.conf tests/testpol.bin
|
2008-08-19 19:30:36 +00:00
|
|
|
$(MAKE) -C test clean
|
|
|
|
|
|
|
|
indent:
|
|
|
|
../scripts/Lindent $(filter-out $(GENERATED),$(wildcard *.[ch]))
|