-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathMakefile.config
More file actions
157 lines (144 loc) · 5.53 KB
/
Makefile.config
File metadata and controls
157 lines (144 loc) · 5.53 KB
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
150
151
152
153
154
155
156
157
# Only test the currently used features and
# display them.
FEATURE_TESTS ?= libelf lzma zlib btf-vmlinux cplus-demangle cxa-demangle libtcmalloc rpmalloc libunwind
FEATURE_DISPLAY := $(FEATURE_TESTS) demangle
FEATURE_GROUP_MEMBERS-libunwind = libunwind-x86 libunwind-x86_64 libunwind-arm libunwind-aarch64
FEATURE_GROUP_MEMBERS-demangle = cplus-demangle cxa-demangle
# Python embedding flags
ifndef NO_LIBPYTHON
PYTHON ?= python3
PYTHON_CONFIG ?= $(PYTHON)-config
PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG) --includes 2>/dev/null)
PYTHON_EMBED_LDOPTS := $(shell ($(PYTHON_CONFIG) --libs --embed &>/dev/null && $(PYTHON_CONFIG) --libs --embed 2>/dev/null) || $(PYTHON_CONFIG) --libs 2>/dev/null)
PYTHON_EMBED_LDFLAGS := $(shell ($(PYTHON_CONFIG) --ldflags --embed &>/dev/null && $(PYTHON_CONFIG) --ldflags --embed 2>/dev/null) || $(PYTHON_CONFIG) --ldflags 2>/dev/null)
# python-build-standalone support: add rpath and PYTHONHOME when PYTHON= is specified
ifeq ($(origin PYTHON),command line)
PYTHON_HOME ?= $(shell $(PYTHON_CONFIG) --prefix 2>/dev/null)
PYTHON_LIBDIR := $(PYTHON_HOME)/lib
ifneq ($(wildcard $(PYTHON_LIBDIR)/libpython3*.so),)
PYTHON_EMBED_LDFLAGS += -Wl,-rpath,$(PYTHON_LIBDIR)
endif
endif
FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS)
FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDFLAGS) $(PYTHON_EMBED_LDOPTS)
FEATURE_TESTS += libpython
FEATURE_DISPLAY += libpython
endif
# libunwind feature detection
ifndef NO_LIBUNWIND
ifeq ($(SRCARCH),x86)
ifeq ($(IS_64_BIT),1)
FEATURE_TESTS += libunwind-x86_64
FEATURE_CHECK_LDFLAGS-libunwind := -lunwind -lunwind-x86_64
FEATURE_CHECK_LDFLAGS-libunwind-x86_64 := -lunwind -lunwind-x86_64
else
FEATURE_TESTS += libunwind-x86
FEATURE_CHECK_LDFLAGS-libunwind := -lunwind -lunwind-x86
FEATURE_CHECK_LDFLAGS-libunwind-x86 := -lunwind -lunwind-x86 -lelf
endif
else ifeq ($(SRCARCH),arm64)
FEATURE_TESTS += libunwind-aarch64
FEATURE_CHECK_LDFLAGS-libunwind := -lunwind -lunwind-aarch64
FEATURE_CHECK_LDFLAGS-libunwind-aarch64 := -lunwind -lunwind-aarch64 -lelf
else ifeq ($(SRCARCH),arm)
FEATURE_TESTS += libunwind-arm
FEATURE_CHECK_LDFLAGS-libunwind := -lunwind -lunwind-arm
FEATURE_CHECK_LDFLAGS-libunwind-arm := -lunwind -lunwind-arm
endif
endif
include $(srctree)/build/Makefile.feature
$(shell printf "" > $(OUTPUT).config-detected)
detected = $(shell echo "$(1)=y" >> $(OUTPUT).config-detected)
detected_var = $(shell echo "$(1)=$($(1))" >> $(OUTPUT).config-detected)
detected_override = $(shell echo "override $(1)=y" >> $(OUTPUT).config-detected)
################################
ifeq ($(feature-libelf), 1)
$(call detected,CONFIG_LIBELF)
else
$(error ERROR: No libelf found. Please install libelf-dev, libelf-devel, elfutils-libelf-devel.)
endif
ifeq ($(feature-lzma), 1)
override CFLAGS += -DHAVE_LZMA_SUPPORT
override CXXFLAGS += -DHAVE_LZMA_SUPPORT
$(call detected,CONFIG_LZMA)
else
$(warning No liblzma found, disables MiniDebugInfo decompression, please install xz-devel/liblzma-dev)
endif
ifeq ($(feature-zlib), 1)
$(call detected,CONFIG_ZLIB)
endif
ifeq ($(feature-btf-vmlinux), 1)
override CFLAGS += -DCONFIG_LIBBPF
# Overrides the make command line option
# `make CONFIG_LIBBPF=1`.
$(call detected_override,CONFIG_LIBBPF)
endif
ifeq ($(feature-cplus-demangle), 1)
override CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
override CXXFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
$(call detected,CONFIG_CPLUS_DEMANGLE)
else
ifeq ($(feature-cxa-demangle), 1)
override CFLAGS += -DHAVE_CXA_DEMANGLE_SUPPORT
override CXXFLAGS += -DHAVE_CXA_DEMANGLE_SUPPORT
$(call detected,CONFIG_CXX_DEMANGLE)
endif
endif
ifeq ($(feature-libtcmalloc), 1)
override CFLAGS += -DHAVE_LIBTCMALLOC
override CXXFLAGS += -DHAVE_LIBTCMALLOC
$(call detected,CONFIG_LIBTCMALLOC)
else ifeq ($(feature-rpmalloc), 1)
override CFLAGS += -DHAVE_RPMALLOC
override CXXFLAGS += -DHAVE_RPMALLOC
$(call detected,CONFIG_RPMALLOC)
endif
ifndef NO_LIBPYTHON
ifeq ($(feature-libpython), 1)
override CFLAGS += -DHAVE_LIBPYTHON
override CFLAGS += $(PYTHON_EMBED_CCOPTS)
$(call detected,CONFIG_LIBPYTHON)
$(call detected_var,PYTHON_EMBED_LDOPTS)
$(call detected_var,PYTHON_EMBED_LDFLAGS)
ifneq ($(PYTHON_HOME),)
$(call detected_var,PYTHON_HOME)
endif
else
$(warning No libpython found, disables Python profiler, please install python3-devel/python3-dev)
endif
else
$(warning Disabling Python profiler per NO_LIBPYTHON=1)
endif
ifndef NO_LIBUNWIND
ifeq ($(feature-libunwind), 1)
# Determine arch-specific libunwind library
ifeq ($(SRCARCH),x86)
ifeq ($(IS_64_BIT),1)
ifeq ($(feature-libunwind-x86_64), 1)
LIBUNWIND_ARCH := x86_64
endif
else
ifeq ($(feature-libunwind-x86), 1)
LIBUNWIND_ARCH := x86
endif
endif
else ifeq ($(SRCARCH),arm64)
ifeq ($(feature-libunwind-aarch64), 1)
LIBUNWIND_ARCH := aarch64
endif
else ifeq ($(SRCARCH),arm)
ifeq ($(feature-libunwind-arm), 1)
LIBUNWIND_ARCH := arm
endif
endif
ifneq ($(LIBUNWIND_ARCH),)
override CFLAGS += -DHAVE_LIBUNWIND
$(call detected,CONFIG_LIBUNWIND)
$(call detected_var,LIBUNWIND_ARCH)
else
$(warning libunwind found but arch-specific library missing, disables DWARF unwind)
endif
else
$(warning No libunwind found, disables DWARF unwind, please install libunwind-devel/libunwind-dev)
endif
endif