File: Makefile

package info (click to toggle)
libsepol 3.9-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,652 kB
  • sloc: ansic: 97,126; makefile: 215; lex: 65
file content (75 lines) | stat: -rw-r--r-- 2,302 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
ENV ?= env
M4 ?= m4 -E -E
MKDIR ?= mkdir
EXE ?= libsepol-tests

CFLAGS += -g3 -gdwarf-2 -O0 \
	-Werror -Wall -Wextra \
	-Wfloat-equal \
	-Wformat=2 \
	-Winit-self \
	-Wmissing-format-attribute \
	-Wmissing-noreturn \
	-Wmissing-prototypes \
	-Wnull-dereference \
	-Wpointer-arith \
	-Wshadow \
	-Wstrict-prototypes \
	-Wundef \
	-Wunused \
	-Wwrite-strings \
	-fno-common

# Statically link libsepol on the assumption that we are going to
# be testing internal functions.
LIBSEPOL := ../src/libsepol.a

# In order to load source policies we need to link in the checkpolicy/checkmodule parser and util code.
# This is less than ideal, but it makes the tests easier to maintain by allowing source policies
# to be loaded directly.
CHECKPOLICY := ../../checkpolicy/
override CPPFLAGS += -I../include/ -I$(CHECKPOLICY)

# test program object files
objs := $(patsubst %.c,%.o,$(sort $(wildcard *.c)))
parserobjs := $(CHECKPOLICY)queue.o $(CHECKPOLICY)y.tab.o \
	$(CHECKPOLICY)parse_util.o $(CHECKPOLICY)lex.yy.o \
	$(CHECKPOLICY)policy_define.o $(CHECKPOLICY)module_compiler.o

# test policy pieces
m4support := $(wildcard policies/support/*.spt)
testsuites := $(wildcard policies/test-*)
policysrc := $(foreach path,$(testsuites),$(wildcard $(path)/*.conf))
stdpol := $(addsuffix .std,$(policysrc))
mlspol := $(addsuffix .mls,$(policysrc))
policies := $(stdpol) $(mlspol)

all: $(EXE) $(policies)
policies: $(policies)

$(EXE): $(objs) $(parserobjs) $(LIBSEPOL)
	$(CC) $(LDFLAGS) $(objs) $(parserobjs) -lcunit $(LIBSEPOL) -o $@

%.conf.std: $(m4support) %.conf
	$(M4) $(M4PARAMS) $^ > $@

%.conf.mls: $(m4support) %.conf
	$(M4) $(M4PARAMS) -D enable_mls $^ > $@

clean: 
	rm -f $(objs) $(EXE)
	rm -f $(policies)
	rm -f policies/test-downgrade/policy.hi policies/test-downgrade/policy.lo

# mkdir is run in a clean environment created by env -i to avoid failing under ASan with:
#
#   ASan runtime does not come first in initial library list;
#   you should either link runtime to your application or manually preload it with LD_PRELOAD
#
# when the source code is built with ASan
test: $(EXE) $(policies)
	$(ENV) -i $(MKDIR) -p policies/test-downgrade
	../../checkpolicy/checkpolicy -M policies/test-cond/refpolicy-base.conf -o policies/test-downgrade/policy.hi	
	./$(EXE)

.PHONY: all policies clean test