1
1
# Determine properties of the system and write a config.h.
2
2
#
3
3
# Oracle Linux DTrace.
4
- # Copyright (c) 2011, 2023 , Oracle and/or its affiliates. All rights reserved.
4
+ # Copyright (c) 2011, 2024 , Oracle and/or its affiliates. All rights reserved.
5
5
# Licensed under the Universal Permissive License v 1.0 as shown at
6
6
# http://oss.oracle.com/licenses/upl.
7
7
10
10
CONFIG_H = $(objdir)/config.h
11
11
CONFIG_MK = $(objdir)/config.mk
12
12
13
+ # Emit a help rule for an override.
14
+ #
15
+ # Syntax: $(call make-override-help,var,help-string)
16
+ define make-override-help
17
+ help::
18
+ width=$$$$(printf '$(1)=[yes/no]' | wc -c); \
19
+ tabs="\t\t\t\t"; \
20
+ if [[ $$$${width} -gt 31 ]]; then \
21
+ tabs=' '; \
22
+ elif [[ $$$${width} -gt 23 ]]; then \
23
+ tabs='\t'; \
24
+ elif [[ $$$${width} -gt 15 ]]; then \
25
+ tabs='\t\t'; \
26
+ elif [[ $$$${width} -gt 7 ]]; then \
27
+ tabs='\t\t\t'; \
28
+ fi; \
29
+ printf "$(1)=[yes/no]$$$${tabs}Override check for%s\n" \
30
+ "$$$$(printf "%s" "$(2)" | sed 's,(.*),,g')" >&2
31
+ endef
32
+
13
33
# Generate a makefile rule to check for the presence of FUNCTION
14
34
# in HEADER and emit an appropriate header file fragment into a
15
35
# file under $(objdir)/.config.
@@ -20,14 +40,25 @@ CONFIG_MK = $(objdir)/config.mk
20
40
# Syntax: $(call check-header-rule,name,function,header)
21
41
define check-header-rule
22
42
$(objdir)/.config/config.$(1).h $(objdir)/.config/config.$(1).mk: $(objdir)/.config/.dir.stamp
23
- if printf '#include <%s.h>\nint main(void) { %s; }' "$(3)" "$(2)" | \
24
- $(CC) $(filter-out --coverage,$(CFLAGS) $(LDFLAGS)) -D_GNU_SOURCE -Werror=implicit-function-declaration -c -o /dev/null -x c - >/dev/null 2>&1; then \
25
- echo '#define HAVE_$(1) 1' > $(objdir)/.config/config.$(1).h; \
26
- echo 'HAVE_$(1)=y' > $(objdir)/.config/config.$(1).mk; \
27
- else \
28
- echo '/* #undef HAVE_$(1) */' > $(objdir)/.config/config.$(1).h; \
29
- echo '# HAVE_$(1) undefined' > $(objdir)/.config/config.$(1).mk; \
30
- fi
43
+ val="$(HAVE_$(1))"; \
44
+ if [[ x$(HAVE_$(1)) = x ]]; then \
45
+ if printf '#include <%s.h>\nint main(void) { %s; }' "$(3)" "$(2)" | \
46
+ $(CC) $(filter-out --coverage,$(CFLAGS) $(LDFLAGS)) -D_GNU_SOURCE -Werror=implicit-function-declaration -c -o /dev/null -x c - >/dev/null 2>&1; then \
47
+ val=yes; \
48
+ else \
49
+ val=no; \
50
+ fi; \
51
+ fi; \
52
+ case $$$$val in \
53
+ yes) echo '#define HAVE_$(1) 1' > $(objdir)/.config/config.$(1).h; \
54
+ echo 'HAVE_$(1)=y' > $(objdir)/.config/config.$(1).mk;; \
55
+ no) echo '/* #undef HAVE_$(1) */' > $(objdir)/.config/config.$(1).h; \
56
+ echo '# HAVE_$(1) undefined' > $(objdir)/.config/config.$(1).mk;; \
57
+ *) echo "HAVE_$(1) must be yes or no, not $(HAVE_$(1))" >&2; \
58
+ false;; \
59
+ esac
60
+
61
+ $(eval $(call make-override-help,HAVE_$(1), presence of $(2) in $(3).h))
31
62
32
63
$(CONFIG_H): $(objdir)/.config/config.$(1).h
33
64
$(CONFIG_MK): $(objdir)/.config/config.$(1).mk
@@ -43,14 +74,25 @@ endef
43
74
# Syntax: $(call check-symbol,name,symbol,library)
44
75
define check-symbol-rule
45
76
$(objdir)/.config/config.$(1).h $(objdir)/.config/config.$(1).mk: $(objdir)/.config/.dir.stamp
46
- if echo 'void $(2)(); int main(void) { $(2)(); }' | \
47
- $(CC) $(filter-out --coverage,$(CFLAGS) $(LDFLAGS)) -o /dev/null -x c - -l$(3) >/dev/null 2>&1; then \
48
- echo '#define HAVE_$(1) 1' > $(objdir)/.config/config.$(1).h; \
49
- echo 'HAVE_$(1)=y' > $(objdir)/.config/config.$(1).mk; \
50
- else \
51
- echo '/* #undef HAVE_$(1) */' > $(objdir)/.config/config.$(1).h; \
52
- echo '# HAVE_$(1) undefined' > $(objdir)/.config/config.$(1).mk; \
53
- fi
77
+ val="$(HAVE_$(1))"; \
78
+ if [[ x$(HAVE_$(1)) = x ]]; then \
79
+ if echo 'void $(2)(); int main(void) { $(2)(); }' | \
80
+ $(CC) $(filter-out --coverage,$(CFLAGS) $(LDFLAGS)) -o /dev/null -x c - -l$(3) >/dev/null 2>&1; then \
81
+ val=yes; \
82
+ else \
83
+ val=no; \
84
+ fi; \
85
+ fi; \
86
+ case $$$$val in \
87
+ yes) echo '#define HAVE_$(1) 1' > $(objdir)/.config/config.$(1).h; \
88
+ echo 'HAVE_$(1)=y' > $(objdir)/.config/config.$(1).mk;; \
89
+ no) echo '/* #undef HAVE_$(1) */' > $(objdir)/.config/config.$(1).h; \
90
+ echo '# HAVE_$(1) undefined' > $(objdir)/.config/config.$(1).mk;; \
91
+ *) echo "HAVE_$(1) must be yes or no, not $(HAVE_$(1))" >&2; \
92
+ false;; \
93
+ esac
94
+
95
+ $(eval $(call make-override-help,HAVE_$(1), presence of $(2) in lib$(3)))
54
96
55
97
$(CONFIG_H): $(objdir)/.config/config.$(1).h
56
98
$(CONFIG_MK): $(objdir)/.config/config.$(1).mk
@@ -66,14 +108,24 @@ endef
66
108
# Syntax: $(call check-header-symbol-rule,name,symbol,library,header)
67
109
define check-header-symbol-rule
68
110
$(objdir)/.config/config.$(1).h $(objdir)/.config/config.$(1).mk: $(objdir)/.config/.dir.stamp
69
- if printf '#include <%s.h>\nint main(void) { %s; }' "$(4)" "$(2)" | \
70
- $(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 \
71
- echo '#define HAVE_$(1) 1' > $(objdir)/.config/config.$(1).h; \
72
- echo 'HAVE_$(1)=y' > $(objdir)/.config/config.$(1).mk; \
73
- else \
74
- echo '/* #undef HAVE_$(1) */' > $(objdir)/.config/config.$(1).h; \
75
- echo '# HAVE_$(1) undefined' > $(objdir)/.config/config.$(1).mk; \
76
- fi
111
+ case x$(HAVE_$(1)) in \
112
+ xyes) echo '#define HAVE_$(1) 1' > $(objdir)/.config/config.$(1).h; \
113
+ echo 'HAVE_$(1)=y' > $(objdir)/.config/config.$(1).mk;; \
114
+ xno) echo '/* #undef HAVE_$(1) */' > $(objdir)/.config/config.$(1).h; \
115
+ echo '# HAVE_$(1) undefined' > $(objdir)/.config/config.$(1).mk;; \
116
+ *) if printf '#include <%s.h>\nint main(void) { %s; }' "$(4)" "$(2)" | \
117
+ $(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 \
118
+ echo '#define HAVE_$(1) 1' > $(objdir)/.config/config.$(1).h; \
119
+ echo 'HAVE_$(1)=y' > $(objdir)/.config/config.$(1).mk; \
120
+ else \
121
+ echo '/* #undef HAVE_$(1) */' > $(objdir)/.config/config.$(1).h; \
122
+ echo '# HAVE_$(1) undefined' > $(objdir)/.config/config.$(1).mk; \
123
+ fi;; \
124
+ *) echo "HAVE_$(1) must be yes or no, not $(HAVE_$(1))" >&2; \
125
+ false;; \
126
+ esac
127
+
128
+ $(eval $(call make-override-help,HAVE_$(1), presence of $(2) in lib$(3) and $(4).h))
77
129
78
130
$(CONFIG_H): $(objdir)/.config/config.$(1).h
79
131
$(CONFIG_MK): $(objdir)/.config/config.$(1).mk
@@ -92,6 +144,9 @@ $(CONFIG_MK):
92
144
echo 'CONFIGURED := yes' >> $(objdir)/config.mk
93
145
cat $(objdir)/.config/*.mk >> $(objdir)/config.mk 2>/dev/null || true
94
146
147
+ help::
148
+ printf "Overrides for library and symbol searches:\n\n" >&2
149
+
95
150
$(eval $(call check-symbol-rule,ELF_GETSHDRSTRNDX,elf_getshdrstrndx,elf))
96
151
$(eval $(call check-symbol-rule,LIBCTF,ctf_open,ctf))
97
152
$(eval $(call check-symbol-rule,STRRSTR,strrstr,c))
@@ -103,3 +158,6 @@ endif
103
158
$(eval $(call check-header-rule,FUSE_NUMA,fuse_set_numa,fuse/fuse_lowlevel))
104
159
$(eval $(call check-header-symbol-rule,CLOSE_RANGE,close_range(3,~0U,0),c,unistd))
105
160
$(eval $(call check-header-rule,GETTID,gettid,unistd))
161
+
162
+ help::
163
+ printf "\n" >&2
0 commit comments