[XEN PATCH v7 48/51] build: Rework "headers*.chk" prerequisite in include/

Anthony PERARD posted 51 patches 4 years, 5 months ago
There is a newer version of this series
[XEN PATCH v7 48/51] build: Rework "headers*.chk" prerequisite in include/
Posted by Anthony PERARD 4 years, 5 months ago
Listing public headers when out-of-tree build are involved becomes
more annoying where every path to every headers needs to start with
"$(srctree)/$(src)", or $(wildcard ) will not work. This means more
repetition.

This patch attempt to reduce the amount of duplication and make better
use of make's meta programming capability. The filters are now listed
in a variable and don't have to repeat the path to the headers files
as this is added later as needed.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
 xen/include/Makefile | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/xen/include/Makefile b/xen/include/Makefile
index c3172f6636be..4e64a31ecab3 100644
--- a/xen/include/Makefile
+++ b/xen/include/Makefile
@@ -78,10 +78,21 @@ ifeq ($(XEN_TARGET_ARCH),$(XEN_COMPILE_ARCH))
 
 all: $(obj)/headers.chk $(obj)/headers99.chk $(obj)/headers++.chk
 
-PUBLIC_HEADERS := $(filter-out $(src)/public/arch-% $(src)/public/dom0_ops.h, $(wildcard $(src)/public/*.h $(src)/public/*/*.h))
+hdrs-path := $(srctree)/$(src)/public
 
-PUBLIC_C99_HEADERS := $(src)/public/io/9pfs.h $(src)/public/io/pvcalls.h
-PUBLIC_ANSI_HEADERS := $(filter-out $(src)/public/%ctl.h $(src)/public/xsm/% $(src)/public/%hvm/save.h $(PUBLIC_C99_HEADERS), $(PUBLIC_HEADERS))
+list-headers = $(wildcard $1/*.h $1/*/*.h)
+filter-headers = $(filter-out $(addprefix $(hdrs-path)/,$($1-filter)), $($1))
+
+c99-headers := io/9pfs.h io/pvcalls.h
+public-headers := $(call list-headers,$(hdrs-path))
+ansi-headers := $(public-headers)
+
+public-headers-filter := dom0_ops.h arch-%
+ansi-headers-filter := %ctl.h xsm/% %hvm/save.h $(public-headers-filter) $(c99-headers)
+
+PUBLIC_HEADERS := $(call filter-headers,public-headers)
+PUBLIC_ANSI_HEADERS := $(call filter-headers,ansi-headers)
+PUBLIC_C99_HEADERS := $(addprefix $(hdrs-path)/, $(c99-headers))
 
 $(src)/public/io/9pfs.h-prereq := string
 $(src)/public/io/pvcalls.h-prereq := string
-- 
Anthony PERARD


Re: [XEN PATCH v7 48/51] build: Rework "headers*.chk" prerequisite in include/
Posted by Jan Beulich 4 years, 3 months ago
On 24.08.2021 12:50, Anthony PERARD wrote:
> Listing public headers when out-of-tree build are involved becomes
> more annoying where every path to every headers needs to start with
> "$(srctree)/$(src)", or $(wildcard ) will not work. This means more
> repetition.
> 
> This patch attempt to reduce the amount of duplication and make better
> use of make's meta programming capability. The filters are now listed
> in a variable and don't have to repeat the path to the headers files
> as this is added later as needed.
> 
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>

Sorry, just one nit here:

> --- a/xen/include/Makefile
> +++ b/xen/include/Makefile
> @@ -78,10 +78,21 @@ ifeq ($(XEN_TARGET_ARCH),$(XEN_COMPILE_ARCH))
>  
>  all: $(obj)/headers.chk $(obj)/headers99.chk $(obj)/headers++.chk
>  
> -PUBLIC_HEADERS := $(filter-out $(src)/public/arch-% $(src)/public/dom0_ops.h, $(wildcard $(src)/public/*.h $(src)/public/*/*.h))
> +hdrs-path := $(srctree)/$(src)/public
>  
> -PUBLIC_C99_HEADERS := $(src)/public/io/9pfs.h $(src)/public/io/pvcalls.h
> -PUBLIC_ANSI_HEADERS := $(filter-out $(src)/public/%ctl.h $(src)/public/xsm/% $(src)/public/%hvm/save.h $(PUBLIC_C99_HEADERS), $(PUBLIC_HEADERS))

These all had / have "PUBLIC" in their names because the makefile doesn't
live in public/. I'd prefer if you could stick to this for all the new
variables/macros you add (lower case then of course).

Jan

> +list-headers = $(wildcard $1/*.h $1/*/*.h)
> +filter-headers = $(filter-out $(addprefix $(hdrs-path)/,$($1-filter)), $($1))
> +
> +c99-headers := io/9pfs.h io/pvcalls.h
> +public-headers := $(call list-headers,$(hdrs-path))
> +ansi-headers := $(public-headers)
> +
> +public-headers-filter := dom0_ops.h arch-%
> +ansi-headers-filter := %ctl.h xsm/% %hvm/save.h $(public-headers-filter) $(c99-headers)
> +
> +PUBLIC_HEADERS := $(call filter-headers,public-headers)
> +PUBLIC_ANSI_HEADERS := $(call filter-headers,ansi-headers)
> +PUBLIC_C99_HEADERS := $(addprefix $(hdrs-path)/, $(c99-headers))
>  
>  $(src)/public/io/9pfs.h-prereq := string
>  $(src)/public/io/pvcalls.h-prereq := string
>