-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathMakeconfig
More file actions
274 lines (248 loc) · 11 KB
/
Makeconfig
File metadata and controls
274 lines (248 loc) · 11 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
# Determine properties of the system and write a config.h.
#
# Oracle Linux DTrace.
# Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
# Licensed under the Universal Permissive License v 1.0 as shown at
# http://oss.oracle.com/licenses/upl.
# The configuration header file.
CONFIG_H = $(objdir)/config.h
CONFIG_MK = $(objdir)/config.mk
# Emit a help rule for an override.
#
# Syntax: $(call make-override-help,var,help-string)
define make-override-help
help-overrides::
width=$$$$(printf '$(1)=[yes/no]' | wc -c); \
tabs="\t\t\t\t"; \
if [[ $$$${width} -gt 31 ]]; then \
tabs=' '; \
elif [[ $$$${width} -gt 23 ]]; then \
tabs='\t'; \
elif [[ $$$${width} -gt 15 ]]; then \
tabs='\t\t'; \
elif [[ $$$${width} -gt 7 ]]; then \
tabs='\t\t\t'; \
fi; \
printf "$(1)=[yes/no]$$$${tabs}Override check for%s\n" \
"$$$$(printf "%s" "$(2)" | sed 's,(.*),,g')" >&2
endef
# Emit a help rule for an override's config option.
#
# Syntax: $(call make-overrride-option-help,var,help-string)
define make-override-option-help
help-overrides-option::
width=$$$$(printf -- '--with-$(1)=[yes/no]' | wc -c); \
tabs=""; \
if [[ $$$${width} -gt 31 ]]; then \
tabs=' '; \
elif [[ $$$${width} -gt 23 ]]; then \
tabs='\t'; \
elif [[ $$$${width} -gt 15 ]]; then \
tabs='\t\t'; \
fi; \
printf -- "--with-%s=[yes/no]$$$${tabs}Override check for$(2)\n" "$$$$(printf -- '$(1)' | LC_COLLATE=C tr '[A-Z_]' '[a-z-]')" >&2
endef
# Generate a makefile rule to check for the presence of FUNCTION
# in HEADER and emit an appropriate header file fragment into a
# file under $(objdir)/.config.
#
# The first argument must be suitable for a filename fragment,
# for a makefile rule name and for a #define.
#
# Syntax: $(call check-header-rule,name,function,header)
define check-header-rule
$(objdir)/.config/config.$(1).h $(objdir)/.config/config.$(1).mk: $(objdir)/.config/.dir.stamp
val="$(HAVE_$(1))"; \
if [[ x$(HAVE_$(1)) = x ]]; then \
if printf '#include <%s.h>\nint main(void) { %s; }' "$(3)" "$(2)" | \
$(CC) $(filter-out --coverage,$(CFLAGS) $(LDFLAGS)) -Iinclude -D_GNU_SOURCE -Werror=implicit-function-declaration -c -o /dev/null -x c - >/dev/null 2>&1; then \
val=yes; \
else \
val=no; \
fi; \
fi; \
case $$$$val in \
yes) echo '#define HAVE_$(1) 1' > $(objdir)/.config/config.$(1).h; \
echo 'HAVE_$(1)=y' > $(objdir)/.config/config.$(1).mk;; \
no) echo '/* #undef HAVE_$(1) */' > $(objdir)/.config/config.$(1).h; \
echo '# HAVE_$(1) undefined' > $(objdir)/.config/config.$(1).mk;; \
*) echo "HAVE_$(1) must be yes or no, not $(HAVE_$(1))" >&2; \
false;; \
esac
rm -f $(CONFIG_H)
rm -f $(CONFIG_MK)
$(eval $(call make-override-help,HAVE_$(1), presence of $(2) in $(3).h))
$(CONFIG_H): $(objdir)/.config/config.$(1).h
$(CONFIG_MK): $(objdir)/.config/config.$(1).mk
endef
# Generate a makefile rule to check for the presence of SYMBOL
# in LIBRARY and emit an appropriate header file fragment into
# a file under $(objdir)/.config.
#
# The first argument must be suitable for a filename fragment,
# for a makefile rule name and for a #define.
#
# Also emit a rule to print help for this override to standard
# error, and (if OPTION) is set, a rule to print help for
# this override in standard configure --with-* form. (This is
# used for options relating to things for which we do not have
# compatibility fallbacks, for which configure-style --with-*
# options seem particularly desirable.)
#
# Syntax: $(call check-symbol-rule,name,symbol,library,option)
define check-symbol-rule
$(objdir)/.config/config.$(1).h $(objdir)/.config/config.$(1).mk: $(objdir)/.config/.dir.stamp
val="$(HAVE_$(1))"; \
if [[ x$(HAVE_$(1)) = x ]]; then \
if echo 'void $(2)(); int main(void) { $(2)(); }' | \
$(CC) $(filter-out --coverage,$(CFLAGS) $(LDFLAGS)) -Iinclude -o /dev/null -x c - -l$(3) >/dev/null 2>&1; then \
val=yes; \
else \
val=no; \
fi; \
fi; \
case $$$$val in \
yes) echo '#define HAVE_$(1) 1' > $(objdir)/.config/config.$(1).h; \
echo 'HAVE_$(1)=y' > $(objdir)/.config/config.$(1).mk;; \
no) echo '/* #undef HAVE_$(1) */' > $(objdir)/.config/config.$(1).h; \
echo '# HAVE_$(1) undefined' > $(objdir)/.config/config.$(1).mk;; \
*) echo "HAVE_$(1) must be yes or no, not $(HAVE_$(1))" >&2; \
false;; \
esac
rm -f $(CONFIG_H)
rm -f $(CONFIG_MK)
$(eval $(call make-override-help,HAVE_$(1), presence of $(2) in lib$(3)))
$(if $(4),
$(eval $(call make-override-option-help,$(1), presence of $(2) in $(3).h)),)
$(CONFIG_H): $(objdir)/.config/config.$(1).h
$(CONFIG_MK): $(objdir)/.config/config.$(1).mk
endef
# Generate a makefile rule to check for the presence of SYMBOL
# in HEADER and LIBRARY and emit an appropriate header file
# fragment into a file under $(objdir)/.config.
#
# The first argument must be suitable for a filename fragment,
# for a makefile rule name and for a #define.
#
# Syntax: $(call check-header-symbol-rule,name,symbol,library,header)
define check-header-symbol-rule
$(objdir)/.config/config.$(1).h $(objdir)/.config/config.$(1).mk: $(objdir)/.config/.dir.stamp
case x$(HAVE_$(1)) in \
xyes) echo '#define HAVE_$(1) 1' > $(objdir)/.config/config.$(1).h; \
echo 'HAVE_$(1)=y' > $(objdir)/.config/config.$(1).mk;; \
xno) echo '/* #undef HAVE_$(1) */' > $(objdir)/.config/config.$(1).h; \
echo '# HAVE_$(1) undefined' > $(objdir)/.config/config.$(1).mk;; \
*) if printf '#include <%s.h>\nint main(void) { %s; }' "$(4)" "$(2)" | \
$(CC) $(filter-out --coverage,$(CFLAGS) $(LDFLAGS)) -Iinclude -D_GNU_SOURCE -Werror=implicit-function-declaration -o /dev/null -x c - -l$(3) >/dev/null 2>&1; then \
echo '#define HAVE_$(1) 1' > $(objdir)/.config/config.$(1).h; \
echo 'HAVE_$(1)=y' > $(objdir)/.config/config.$(1).mk; \
else \
echo '/* #undef HAVE_$(1) */' > $(objdir)/.config/config.$(1).h; \
echo '# HAVE_$(1) undefined' > $(objdir)/.config/config.$(1).mk; \
fi;; \
*) echo "HAVE_$(1) must be yes or no, not $(HAVE_$(1))" >&2; \
false;; \
esac
rm -f $(CONFIG_H)
rm -f $(CONFIG_MK)
$(eval $(call make-override-help,HAVE_$(1), presence of $(2) in lib$(3) and $(4).h))
$(CONFIG_H): $(objdir)/.config/config.$(1).h
$(CONFIG_MK): $(objdir)/.config/config.$(1).mk
endef
# Generate a makefile rule to check for the presence of MACRO
# in HEADER and emit an appropriate header file fragment into a file
# under $(objdir)/.config.
#
# The first argument must be suitable for a filename fragment,
# for a makefile rule name and for a #define.
#
# Syntax: $(call check-header-macro-rule,name,macro,header)
define check-header-macro-rule
$(objdir)/.config/config.$(1).h $(objdir)/.config/config.$(1).mk: $(objdir)/.config/.dir.stamp
case x$(HAVE_$(1)) in \
xyes) echo '#define HAVE_$(1) 1' > $(objdir)/.config/config.$(1).h; \
echo 'HAVE_$(1)=y' > $(objdir)/.config/config.$(1).mk;; \
xno) echo '/* #undef HAVE_$(1) */' > $(objdir)/.config/config.$(1).h; \
echo '# HAVE_$(1) undefined' > $(objdir)/.config/config.$(1).mk;; \
*) if printf '#include <%s.h>\n#ifndef %s\n#error %s not found.\n#endif' "$(3)" "$(2)" "$(2)" | \
$(CC) $(filter-out --coverage,$(CFLAGS) $(LDFLAGS)) -Iinclude -D_GNU_SOURCE -Werror=implicit-function-declaration -c -o /dev/null -x c - >/dev/null 2>&1; then \
echo '#define HAVE_$(1) 1' > $(objdir)/.config/config.$(1).h; \
echo 'HAVE_$(1)=y' > $(objdir)/.config/config.$(1).mk; \
else \
echo '/* #undef HAVE_$(1) */' > $(objdir)/.config/config.$(1).h; \
echo '# HAVE_$(1) undefined' > $(objdir)/.config/config.$(1).mk; \
fi;; \
*) echo "HAVE_$(1) must be yes or no, not $(HAVE_$(1))" >&2; \
false;; \
esac
rm -f $(CONFIG_H)
rm -f $(CONFIG_MK)
$(eval $(call make-override-help,HAVE_$(1), presence of preprocessor macro $(2) in $(3).h))
$(CONFIG_H): $(objdir)/.config/config.$(1).h
$(CONFIG_MK): $(objdir)/.config/config.$(1).mk
endef
# Generate a makefile rule to check for support for OPTION in BPFC and emit an
# appropriate header file fragment into a file under $(objdir)/.config.
#
# The first argument must be suitable for a filename fragment, for a makefile
# rule name and for a #define.
#
# Syntax: $(call check-bpfc-option-rule,name,option)
define check-bpfc-option-rule
$(objdir)/.config/config.$(1).h $(objdir)/.config/config.$(1).mk: $(objdir)/.config/.dir.stamp
case x$(HAVE_$(1)) in \
xyes) echo '#define HAVE_$(1) 1' > $(objdir)/.config/config.$(1).h; \
echo 'HAVE_$(1)=y' > $(objdir)/.config/config.$(1).mk;; \
xno) echo '/* #undef HAVE_$(1) */' > $(objdir)/.config/config.$(1).h; \
echo '# HAVE_$(1) undefined' > $(objdir)/.config/config.$(1).mk;; \
*) if $(BPFC) --help $(2) 2>&1 >/dev/null | grep -q error; then \
echo '/* #undef HAVE_$(1) */' > $(objdir)/.config/config.$(1).h; \
echo '# HAVE_$(1) undefined' > $(objdir)/.config/config.$(1).mk; \
else \
echo '#define HAVE_$(1) 1' > $(objdir)/.config/config.$(1).h; \
echo 'HAVE_$(1)=y' > $(objdir)/.config/config.$(1).mk; \
fi;; \
*) echo "HAVE_$(1) must be yes or no, not $(HAVE_$(1))" >&2; \
false;; \
esac
rm -f $(CONFIG_H)
rm -f $(CONFIG_MK)
$(eval $(call make-override-help,HAVE_$(1), presence of option $(2) in $(BPFC)))
$(CONFIG_H): $(objdir)/.config/config.$(1).h
$(CONFIG_MK): $(objdir)/.config/config.$(1).mk
endef
$(objdir)/.config/.dir.stamp:
if [[ ! -f $(objdir)/.config/.dir.stamp ]]; then \
mkdir -p $(objdir)/.config; \
touch $(objdir)/.config/.dir.stamp; \
fi
$(CONFIG_H):
echo '/* This file is automatically generated. */' > $(objdir)/config.h
cat $(objdir)/.config/*.h >> $(objdir)/config.h 2>/dev/null || true
$(CONFIG_MK):
echo '# This file is automatically generated.' > $(objdir)/config.mk
echo 'CONFIGURED := yes' >> $(objdir)/config.mk
cat $(objdir)/.config/*.mk >> $(objdir)/config.mk 2>/dev/null || true
help-overrides-header::
printf "Overrides for library and symbol searches:\n\n" >&2
$(eval $(call check-symbol-rule,ELF_GETSHDRSTRNDX,elf_getshdrstrndx,elf))
$(eval $(call check-symbol-rule,LIBCTF,ctf_open,ctf,t))
$(eval $(call check-symbol-rule,STRRSTR,strrstr,c))
$(eval $(call check-symbol-rule,PTHREAD_ATFORK,pthread_atfork,c))
ifndef WANTS_LIBFUSE2
$(eval $(call check-symbol-rule,FUSE_LOG,fuse_set_log_func,fuse3))
$(eval $(call check-symbol-rule,LIBFUSE3,fuse_session_receive_buf,fuse3,t))
endif
$(eval $(call check-header-rule,FUSE_NUMA,fuse_set_numa,fuse/fuse_lowlevel))
$(eval $(call check-header-symbol-rule,CLOSE_RANGE,close_range(3,~0U,0),c,unistd))
$(eval $(call check-header-rule,GETTID,gettid,unistd))
$(eval $(call check-header-rule,DIS1,disassembler(NULL),disasm))
$(eval $(call check-header-rule,DIS4,disassembler(0,0,0,NULL),disasm))
$(eval $(call check-header-rule,INITDISINFO3,init_disassemble_info(NULL,NULL,NULL),disasm))
$(eval $(call check-header-rule,INITDISINFO4,init_disassemble_info(NULL,NULL,NULL,NULL),disasm))
$(eval $(call check-header-macro-rule,VALGRIND,VALGRIND_NON_SIMD_CALL0,valgrind/valgrind))
$(eval $(call check-bpfc-option-rule,BPFV3,-mcpu=v3))
$(eval $(call check-bpfc-option-rule,BPFMASM,-masm=normal))
help-overrides::
printf "\n" >&2
help:: help-overrides-header help-overrides