[DTrace-devel] [PATCH v4 09/25] build: add header+symbol checking
Kris Van Hees
kris.van.hees at oracle.com
Sat Oct 8 03:19:40 UTC 2022
On Fri, Oct 07, 2022 at 11:25:08AM +0100, Nick Alcock via DTrace-devel wrote:
> The new check-header-symbol-rule Makeconfig rule allows checking to see
> whether a header #inclusion plus a symbol usage plus a given -l library
> usage compiles and links successfully. It's analogous to the Autoconf
> AC_TRY_COMPILE macro.
>
> Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>
> ---
> Makeconfig | 25 ++++++++++++++++++++++++-
> 1 file changed, 24 insertions(+), 1 deletion(-)
>
> diff --git a/Makeconfig b/Makeconfig
> index 28761a4c45ce..fd2645f9ed10 100644
> --- a/Makeconfig
> +++ b/Makeconfig
> @@ -1,7 +1,7 @@
> # Determine properties of the system and write a config.h.
> #
> # Oracle Linux DTrace.
> -# Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
> +# 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.
>
> @@ -33,6 +33,29 @@ $(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
> --
> 2.35.1
>
>
> _______________________________________________
> DTrace-devel mailing list
> DTrace-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/dtrace-devel
More information about the DTrace-devel
mailing list