1M4 ?= m4 2MKDIR ?= mkdir 3EXE ?= libsepol-tests 4 5CFLAGS += -g3 -gdwarf-2 -O0 -Wall -W -Wundef -Wmissing-noreturn -Wmissing-format-attribute -Wno-unused-parameter -Werror 6 7# Statically link libsepol on the assumption that we are going to 8# be testing internal functions. 9LIBSEPOL := ../src/libsepol.a 10 11# In order to load source policies we need to link in the checkpolicy/checkmodule parser and util code. 12# This is less than ideal, but it makes the tests easier to maintain by allowing source policies 13# to be loaded directly. 14CHECKPOLICY := ../../checkpolicy/ 15override CPPFLAGS += -I../include/ -I$(CHECKPOLICY) 16 17# test program object files 18objs := $(patsubst %.c,%.o,$(sort $(wildcard *.c))) 19parserobjs := $(CHECKPOLICY)queue.o $(CHECKPOLICY)y.tab.o \ 20 $(CHECKPOLICY)parse_util.o $(CHECKPOLICY)lex.yy.o \ 21 $(CHECKPOLICY)policy_define.o $(CHECKPOLICY)module_compiler.o 22 23# test policy pieces 24m4support := $(wildcard policies/support/*.spt) 25testsuites := $(wildcard policies/test-*) 26policysrc := $(foreach path,$(testsuites),$(wildcard $(path)/*.conf)) 27stdpol := $(addsuffix .std,$(policysrc)) 28mlspol := $(addsuffix .mls,$(policysrc)) 29policies := $(stdpol) $(mlspol) 30 31all: $(EXE) $(policies) 32policies: $(policies) 33 34$(EXE): $(objs) $(parserobjs) $(LIBSEPOL) 35 $(CC) $(LDFLAGS) $(objs) $(parserobjs) -lcunit -lcurses $(LIBSEPOL) -o $@ 36 37%.conf.std: $(m4support) %.conf 38 $(M4) $(M4PARAMS) $^ > $@ 39 40%.conf.mls: $(m4support) %.conf 41 $(M4) $(M4PARAMS) -D enable_mls $^ > $@ 42 43clean: 44 rm -f $(objs) $(EXE) 45 rm -f $(policies) 46 rm -f policies/test-downgrade/policy.hi policies/test-downgrade/policy.lo 47 48 49test: $(EXE) $(policies) 50 $(MKDIR) -p policies/test-downgrade 51 ../../checkpolicy/checkpolicy -M policies/test-cond/refpolicy-base.conf -o policies/test-downgrade/policy.hi 52 ./$(EXE) 53 54.PHONY: all policies clean test 55