-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makeconfig
105 lines (93 loc) · 4.49 KB
/
Makeconfig
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
# Determine properties of the system and write a config.h.
#
# Oracle Linux DTrace.
# Copyright (c) 2011, 2022, 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
# 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
if printf '#include <%s.h>\nint main(void) { %s; }' "$(3)" "$(2)" | \
$(CC) $(filter-out --coverage,$(CFLAGS) $(LDFLAGS)) -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
$(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.
#
# Syntax: $(call check-symbol,name,symbol,library)
define check-symbol-rule
$(objdir)/.config/config.$(1).h $(objdir)/.config/config.$(1).mk: $(objdir)/.config/.dir.stamp
if echo 'void $(2)(); int main(void) { $(2)(); }' | \
$(CC) $(filter-out --coverage,$(CFLAGS) $(LDFLAGS)) -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
$(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
if printf '#include <%s.h>\nint main(void) { %s; }' "$(4)" "$(2)" | \
$(CC) $(filter-out --coverage,$(CFLAGS) $(LDFLAGS)) -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
$(CONFIG_H): $(objdir)/.config/config.$(1).h
$(CONFIG_MK): $(objdir)/.config/config.$(1).mk
endef
$(objdir)/.config/.dir.stamp:
mkdir -p $(objdir)/.config
touch $(objdir)/.config/.dir.stamp
$(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
$(eval $(call check-symbol-rule,ELF_GETSHDRSTRNDX,elf_getshdrstrndx,elf))
$(eval $(call check-symbol-rule,LIBCTF,ctf_open,ctf))
$(eval $(call check-symbol-rule,STRRSTR,strrstr,c))
$(eval $(call check-symbol-rule,WAITFD,waitfd,c))
$(eval $(call check-symbol-rule,LIBSYSTEMD,sd_notify,systemd))
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))
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))