-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
108 lines (84 loc) · 2.54 KB
/
Makefile
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
MAKEFLAGS += -rR
ROOT := $(abspath $(CURDIR))
export ROOT
# Default to the all rule
all:
# Local settings and rules
-include Makefile.local
# $(xtfdir) defaults to $(ROOT) so development and testing can be done
# straight out of the working tree.
xtfdir ?= $(ROOT)
DESTDIR ?= $(ROOT)/dist
ifeq ($(filter /%,$(xtfdir)),)
$(error $$(xtfdir) must be absolute, not '$(xtfdir)')
endif
ifneq ($(DESTDIR),)
ifeq ($(filter /%,$(DESTDIR)),)
$(error $$(DESTDIR) must be absolute, not '$(DESTDIR)')
endif
endif
xtftestdir := $(xtfdir)/tests
export DESTDIR xtfdir xtftestdir
ifeq ($(LLVM),) # GCC toolchain
CC := $(CROSS_COMPILE)gcc
LD := $(CROSS_COMPILE)ld
OBJCOPY := $(CROSS_COMPILE)objcopy
else # LLVM toolchain
# Optional -$NUM version when multiple toolchains are installed
ver := $(filter -%,$(LLVM))
CC := clang$(ver) $(if $(CROSS_COMPILE),--target=$(notdir $(CROSS_COMPILE:%-=%)))
LD := ld.lld$(ver)
OBJCOPY := llvm-objcopy$(ver)
undefine ver
endif
CPP := $(CC) -E
INSTALL := install
INSTALL_DATA := $(INSTALL) -m 644 -p
INSTALL_DIR := $(INSTALL) -d -p
INSTALL_PROGRAM := $(INSTALL) -p
# Best effort attempt to find a python interpreter, defaulting to Python 3 if
# available. Fall back to just `python`.
PYTHON_INTERPRETER := $(word 1,$(shell command -v python3 || command -v python || command -v python2) python)
PYTHON ?= $(PYTHON_INTERPRETER)
export CC LD CPP INSTALL INSTALL_DATA INSTALL_DIR INSTALL_PROGRAM OBJCOPY PYTHON
# By default enable all the tests
TESTS ?= $(wildcard $(ROOT)/tests/*)
.PHONY: all
all:
@set -e; for D in $(TESTS); do \
[ ! -e $$D/Makefile ] && continue; \
$(MAKE) -C $$D build; \
done
.PHONY: install
install:
@$(INSTALL_DIR) $(DESTDIR)$(xtfdir)
$(INSTALL_PROGRAM) xtf-runner $(DESTDIR)$(xtfdir)
@set -e; for D in $(TESTS); do \
[ ! -e $$D/Makefile ] && continue; \
$(MAKE) -C $$D install; \
done
define all_sources
find include/ arch/ common/ tests/ -name "*.[hcsS]"
endef
.PHONY: cscope
cscope:
$(all_sources) > cscope.files
cscope -b -q -k
.PHONY: gtags
gtags:
$(all_sources) | gtags -f -
.PHONY: clean
clean:
find . \( -name "*.o" -o -name "*.d" -o -name "*.lds" \) -delete
find tests/ \( -perm -a=x -name "test-*" -o -name "test-*.cfg" \
-o -name "info.json" \) -delete
.PHONY: distclean
distclean: clean
find . \( -name "*~" -o -name "cscope*" \) -delete
rm -rf docs/autogenerated/ dist/
.PHONY: doxygen
doxygen: Doxyfile
doxygen Doxyfile > /dev/null
.PHONY: pylint
pylint:
-pylint --rcfile=.pylintrc xtf-runner