[DTrace-devel] [PATCH 1/2] config: add rule to check gcc option
Kris Van Hees
kris.van.hees at oracle.com
Thu Feb 22 14:49:22 UTC 2024
Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
---
Makeconfig | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/Makeconfig b/Makeconfig
index 0f7c4364..332e9519 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -163,6 +163,39 @@ $(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 gcc 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-gcc-option-rule,name,option)
+define check-gcc-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 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 gcc))
+
+$(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; \
--
2.42.0
More information about the DTrace-devel
mailing list