forked from kvm-unit-tests/kvm-unit-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
149 lines (117 loc) · 4.42 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
SHELL := /usr/bin/env bash
ifeq ($(wildcard config.mak),)
$(error run ./configure first. See ./configure -h)
endif
include config.mak
# Set search path for all sources
VPATH = $(SRCDIR)
libdirs-get = $(shell [ -d "lib/$(1)" ] && echo "lib/$(1) lib/$(1)/asm")
ARCH_LIBDIRS := $(call libdirs-get,$(ARCH_LIBDIR)) $(call libdirs-get,$(TEST_DIR))
OBJDIRS := $(ARCH_LIBDIRS)
DESTDIR := $(PREFIX)/share/kvm-unit-tests/
.PHONY: arch_clean clean distclean cscope
# cc-option
# Usage: OP_CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0)
cc-option = $(shell if $(CC) -Werror $(1) -S -o /dev/null -xc /dev/null \
> /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
libcflat := lib/libcflat.a
cflatobjs := \
lib/argv.o \
lib/printf.o \
lib/string.o \
lib/abort.o \
lib/report.o \
lib/stack.o
# libfdt paths
LIBFDT_objdir = lib/libfdt
LIBFDT_srcdir = $(SRCDIR)/lib/libfdt
LIBFDT_archive = $(LIBFDT_objdir)/libfdt.a
OBJDIRS += $(LIBFDT_objdir)
# EFI App
ifeq ($(CONFIG_EFI),y)
EFI_CFLAGS := -DCONFIG_EFI -DCONFIG_RELOC
# The following CFLAGS and LDFLAGS come from:
# - GNU-EFI/Makefile.defaults
# - GNU-EFI/apps/Makefile
# GCC defines wchar to be 32 bits, but EFI expects 16 bits
EFI_CFLAGS += -fshort-wchar
# EFI applications use PIC as they are loaded to dynamic addresses, not a fixed
# starting address
EFI_CFLAGS += -fPIC
# Create shared library
EFI_LDFLAGS := -Bsymbolic -shared -nostdlib
endif
#include architecture specific make rules
include $(SRCDIR)/$(TEST_DIR)/Makefile
COMMON_CFLAGS += -g $(autodepend-flags) -fno-strict-aliasing -fno-common
COMMON_CFLAGS += -Wall -Wwrite-strings -Wempty-body -Wuninitialized
COMMON_CFLAGS += -Wignored-qualifiers -Wno-missing-braces $(CONFIG_WERROR)
frame-pointer-flag=-f$(if $(KEEP_FRAME_POINTER),no-,)omit-frame-pointer
fomit_frame_pointer := $(call cc-option, $(frame-pointer-flag), "")
fno_stack_protector := $(call cc-option, -fno-stack-protector, "")
fno_stack_protector_all := $(call cc-option, -fno-stack-protector-all, "")
wno_frame_address := $(call cc-option, -Wno-frame-address, "")
fno_pic := $(call cc-option, -fno-pic, "")
no_pie := $(call cc-option, -no-pie, "")
wclobbered := $(call cc-option, -Wclobbered, "")
wunused_but_set_parameter := $(call cc-option, -Wunused-but-set-parameter, "")
wmissing_parameter_type := $(call cc-option, -Wmissing-parameter-type, "")
wold_style_declaration := $(call cc-option, -Wold-style-declaration, "")
COMMON_CFLAGS += $(fomit_frame_pointer)
COMMON_CFLAGS += $(fno_stack_protector)
COMMON_CFLAGS += $(fno_stack_protector_all)
COMMON_CFLAGS += $(wno_frame_address)
COMMON_CFLAGS += $(if $(U32_LONG_FMT),-D__U32_LONG_FMT__,)
ifeq ($(CONFIG_EFI),y)
COMMON_CFLAGS += $(EFI_CFLAGS)
else
COMMON_CFLAGS += $(fno_pic)
endif
COMMON_CFLAGS += $(wclobbered)
COMMON_CFLAGS += $(wunused_but_set_parameter)
CFLAGS += $(COMMON_CFLAGS)
CFLAGS += $(wmissing_parameter_type)
CFLAGS += $(wold_style_declaration)
CFLAGS += -Woverride-init -Wmissing-prototypes -Wstrict-prototypes
autodepend-flags = -MMD -MP -MF $(dir $*).$(notdir $*).d
LDFLAGS += -nostdlib $(no_pie) -z noexecstack
$(libcflat): $(cflatobjs)
$(AR) rcs $@ $^
include $(LIBFDT_srcdir)/Makefile.libfdt
$(LIBFDT_archive): CFLAGS += -ffreestanding -I $(SRCDIR)/lib -I $(SRCDIR)/lib/libfdt -Wno-sign-compare
$(LIBFDT_archive): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS))
$(AR) rcs $@ $^
libfdt_clean: VECHO = echo " "
libfdt_clean: STD_CLEANFILES = *.o .*.d
libfdt_clean: LIBFDT_dir = $(LIBFDT_objdir)
libfdt_clean: SHAREDLIB_EXT = so
# Build directory target
.PHONY: directories
directories:
@mkdir -p $(OBJDIRS)
%.o: %.S
$(CC) $(CFLAGS) -c -nostdlib -o $@ $<
-include */.*.d */*/.*.d
all: directories $(shell (cd $(SRCDIR) && git rev-parse --verify --short=8 HEAD) >build-head 2>/dev/null)
standalone: all
@scripts/mkstandalone.sh
install: standalone
mkdir -p $(DESTDIR)
install tests/* $(DESTDIR)
clean: arch_clean libfdt_clean
$(RM) $(LIBFDT_archive)
$(RM) lib/.*.d $(libcflat) $(cflatobjs)
distclean: clean
$(RM) lib/asm lib/config.h config.mak $(TEST_DIR)-run msr.out cscope.* build-head
$(RM) -r tests logs logs.old efi-tests
cscope: cscope_dirs = lib lib/libfdt lib/linux $(TEST_DIR) $(ARCH_LIBDIRS) lib/asm-generic
cscope:
$(RM) ./cscope.*
find -L $(cscope_dirs) -maxdepth 1 \
-name '*.[chsS]' -exec realpath --relative-base=$(CURDIR) {} \; | sort -u > ./cscope.files
cscope -bk
.PHONY: tags
tags:
ctags -R
check-kerneldoc:
find . -name '*.[ch]' -exec scripts/kernel-doc -none {} +