diff mbox series

[XEN,v4,17/32] tools: Introduce $(xenlibs-ldflags, ) macro

Message ID 20220811164845.38083-18-anthony.perard@citrix.com (mailing list archive)
State Superseded
Headers show
Series Toolstack build system improvement, toward non-recursive makefiles | expand

Commit Message

Anthony PERARD Aug. 11, 2022, 4:48 p.m. UTC
This avoid the need to open-coding the list of flags needed to link
with an in-tree Xen library when using -lxen*.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Reviewed-by: Henry Wang <Henry.Wang@arm.com>
---
 tools/golang/xenlight/Makefile | 2 +-
 tools/Rules.mk                 | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

Comments

Anthony PERARD Aug. 19, 2022, 1:09 p.m. UTC | #1
Hi Nick, George,

Could you give a ack or review this patch?

Also sorry George, it seems that the use of "--remove-duplicates" with
`get_maintainer.pl` have removed your email from CC the list.

Thanks,

On Thu, Aug 11, 2022 at 05:48:30PM +0100, Anthony PERARD wrote:
> This avoid the need to open-coding the list of flags needed to link
> with an in-tree Xen library when using -lxen*.
> 
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
> Reviewed-by: Henry Wang <Henry.Wang@arm.com>
> ---
>  tools/golang/xenlight/Makefile | 2 +-
>  tools/Rules.mk                 | 8 ++++++++
>  2 files changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/golang/xenlight/Makefile b/tools/golang/xenlight/Makefile
> index 64671f246c..00e6d17f2b 100644
> --- a/tools/golang/xenlight/Makefile
> +++ b/tools/golang/xenlight/Makefile
> @@ -27,7 +27,7 @@ GOXL_GEN_FILES = types.gen.go helpers.gen.go
>  # so that it can find the actual library.
>  .PHONY: build
>  build: xenlight.go $(GOXL_GEN_FILES)
> -	CGO_CFLAGS="$(CFLAGS_libxenlight) $(CFLAGS_libxentoollog) $(APPEND_CFLAGS)" CGO_LDFLAGS="$(LDLIBS_libxenlight) $(LDLIBS_libxentoollog) -L$(XEN_libxenlight) -L$(XEN_libxentoollog) $(APPEND_LDFLAGS)" $(GO) build -x
> +	CGO_CFLAGS="$(CFLAGS_libxenlight) $(CFLAGS_libxentoollog) $(APPEND_CFLAGS)" CGO_LDFLAGS="$(call xenlibs-ldflags,light toollog) $(APPEND_LDFLAGS)" $(GO) build -x
>  
>  .PHONY: install
>  install: build
> diff --git a/tools/Rules.mk b/tools/Rules.mk
> index ce77dd2eb1..26958b2948 100644
> --- a/tools/Rules.mk
> +++ b/tools/Rules.mk
> @@ -105,6 +105,14 @@ define xenlibs-ldlibs
>      $(foreach lib,$(1),$(xenlibs-ldlibs-$(lib)))
>  endef
>  
> +# Provide needed flags for linking an in-tree Xen library by an external
> +# project (or when it is necessary to link with "-lxen$(1)" instead of using
> +# the full path to the library).
> +define xenlibs-ldflags
> +    $(call xenlibs-rpath,$(1)) \
> +    $(foreach lib,$(1),-L$(XEN_ROOT)/tools/libs/$(lib))
> +endef
> +
>  define LIB_defs
>   FILENAME_$(1) ?= xen$(1)
>   XEN_libxen$(1) = $$(XEN_ROOT)/tools/libs/$(1)
> -- 
> Anthony PERARD
>
diff mbox series

Patch

diff --git a/tools/golang/xenlight/Makefile b/tools/golang/xenlight/Makefile
index 64671f246c..00e6d17f2b 100644
--- a/tools/golang/xenlight/Makefile
+++ b/tools/golang/xenlight/Makefile
@@ -27,7 +27,7 @@  GOXL_GEN_FILES = types.gen.go helpers.gen.go
 # so that it can find the actual library.
 .PHONY: build
 build: xenlight.go $(GOXL_GEN_FILES)
-	CGO_CFLAGS="$(CFLAGS_libxenlight) $(CFLAGS_libxentoollog) $(APPEND_CFLAGS)" CGO_LDFLAGS="$(LDLIBS_libxenlight) $(LDLIBS_libxentoollog) -L$(XEN_libxenlight) -L$(XEN_libxentoollog) $(APPEND_LDFLAGS)" $(GO) build -x
+	CGO_CFLAGS="$(CFLAGS_libxenlight) $(CFLAGS_libxentoollog) $(APPEND_CFLAGS)" CGO_LDFLAGS="$(call xenlibs-ldflags,light toollog) $(APPEND_LDFLAGS)" $(GO) build -x
 
 .PHONY: install
 install: build
diff --git a/tools/Rules.mk b/tools/Rules.mk
index ce77dd2eb1..26958b2948 100644
--- a/tools/Rules.mk
+++ b/tools/Rules.mk
@@ -105,6 +105,14 @@  define xenlibs-ldlibs
     $(foreach lib,$(1),$(xenlibs-ldlibs-$(lib)))
 endef
 
+# Provide needed flags for linking an in-tree Xen library by an external
+# project (or when it is necessary to link with "-lxen$(1)" instead of using
+# the full path to the library).
+define xenlibs-ldflags
+    $(call xenlibs-rpath,$(1)) \
+    $(foreach lib,$(1),-L$(XEN_ROOT)/tools/libs/$(lib))
+endef
+
 define LIB_defs
  FILENAME_$(1) ?= xen$(1)
  XEN_libxen$(1) = $$(XEN_ROOT)/tools/libs/$(1)