diff mbox series

[XEN,48/57] libs/stat: Fix and rework perl-binding build

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

Commit Message

Anthony PERARD Dec. 6, 2021, 5:02 p.m. UTC
For PERL_FLAGS, use make's shell rather than a backquote.

Rather than relying on the VCS to create an empty directory for us,
we can create one before generating the *.c file for the bindings.

Make use of generic variable names to build a shared library from a
source file: CFLAGS, LDFLAGS, and LDLIBS.

To build a shared library, we need to build the source file with
"-fPIC", which was drop by 6d0ec05390 (tools: split libxenstat into
new tools/libs/stat directory).

The source file generated by swig seems to be missing many prototype for
many functions, so we need "-Wno-missing-prototypes" in order to
build it. Also, one of the prototype is deemed malformed, so we also
need "-Wno-strict-prototypes".

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/libs/stat/Makefile                  | 15 +++++++++++----
 tools/libs/stat/bindings/swig/perl/.empty |  1 -
 2 files changed, 11 insertions(+), 5 deletions(-)
 delete mode 100644 tools/libs/stat/bindings/swig/perl/.empty

Comments

Jürgen Groß Dec. 7, 2021, 2:46 p.m. UTC | #1
On 06.12.21 18:02, Anthony PERARD wrote:
> For PERL_FLAGS, use make's shell rather than a backquote.
> 
> Rather than relying on the VCS to create an empty directory for us,
> we can create one before generating the *.c file for the bindings.
> 
> Make use of generic variable names to build a shared library from a
> source file: CFLAGS, LDFLAGS, and LDLIBS.
> 
> To build a shared library, we need to build the source file with
> "-fPIC", which was drop by 6d0ec05390 (tools: split libxenstat into
> new tools/libs/stat directory).
> 
> The source file generated by swig seems to be missing many prototype for
> many functions, so we need "-Wno-missing-prototypes" in order to
> build it. Also, one of the prototype is deemed malformed, so we also
> need "-Wno-strict-prototypes".
> 
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>

Reviewed-by: Juergen Gross <jgross@suse.com>


Juergen
diff mbox series

Patch

diff --git a/tools/libs/stat/Makefile b/tools/libs/stat/Makefile
index d5d9cb3659..962f02090b 100644
--- a/tools/libs/stat/Makefile
+++ b/tools/libs/stat/Makefile
@@ -94,13 +94,20 @@  uninstall: uninstall-python-bindings
 endif
 
 # Perl bindings
-PERL_FLAGS=`perl -MConfig -e 'print "$$Config{ccflags} -I$$Config{archlib}/CORE";'`
+PERL_FLAGS = $(shell $(PERL) -MConfig -e 'print "$$Config{ccflags} -I$$Config{archlib}/CORE";')
 $(PERLMOD): $(PERLSRC)
 $(PERLSRC): bindings/swig/xenstat.i
-	swig -perl $(SWIG_FLAGS) -outdir $(@D) -o $(PERLSRC) $<
-
+	mkdir -p $(@D)
+	swig -perl $(SWIG_FLAGS) -outdir $(@D) -o $@ $<
+
+$(PERLLIB): CFLAGS += -fPIC
+$(PERLLIB): CFLAGS += -Wno-strict-prototypes
+$(PERLLIB): CFLAGS += -Wno-missing-prototypes
+$(PERLLIB): LDFLAGS += $(PERL_FLAGS)
+$(PERLLIB): LDFLAGS += $(SHLIB_LDFLAGS)
+$(PERLLIB): LDLIBS := $(LDLIBS_libxenstat)
 $(PERLLIB): $(PERLSRC)
-	$(CC) $(CFLAGS) $(LDFLAGS) $(PERL_FLAGS) $(SHLIB_LDFLAGS) -lxenstat -o $@ $< $(APPEND_LDFLAGS)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS) $(APPEND_LDFLAGS)
 
 .PHONY: perl-bindings
 perl-bindings: $(PERLLIB) $(PERLMOD)
diff --git a/tools/libs/stat/bindings/swig/perl/.empty b/tools/libs/stat/bindings/swig/perl/.empty
deleted file mode 100644
index 2a8dd4274d..0000000000
--- a/tools/libs/stat/bindings/swig/perl/.empty
+++ /dev/null
@@ -1 +0,0 @@ 
-This directory is empty; this file is included to prevent version control systems from removing the directory.