Message ID | 20211206170241.13165-48-anthony.perard@citrix.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Toolstack build system improvement, toward non-recursive makefiles | expand |
On 06.12.21 18:02, Anthony PERARD wrote: > Fix the dependency on the library, $(SHLIB) variable doesn't exist > anymore. > > Rework dependency on the include file, we can let `swig` generate the > dependency for us with the use of "-M*" flags. > > The xenstat.h file has moved so we need to fix the include location. > > Rather than relaying 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. > > Fix python's specific *flags by using python-config, and add them to > generic flags variables: CFLAGS, 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 a prototype for > the "init" function, so we need "-Wno-missing-prototypes" in order to > build it. > > Add some targets to .PHONY. > > Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> Reviewed-by: Juergen Gross <jgross@suse.com> Juergen
On 06/12/2021 17:02, Anthony PERARD wrote: > Fix the dependency on the library, $(SHLIB) variable doesn't exist > anymore. > > Rework dependency on the include file, we can let `swig` generate the > dependency for us with the use of "-M*" flags. Hmm. At no point is swig mentioned in README/etc, and it's not in any of the CI logic. I wasn't even aware that we had python bindings here. Unless someone tries and confirms them not to be broken, I'd be tempted to drop it all. I bet this has been dead since we dropped Xend. ~Andrew
On Thu, Dec 16, 2021 at 06:47:17PM +0000, Andrew Cooper wrote: > On 06/12/2021 17:02, Anthony PERARD wrote: > > Fix the dependency on the library, $(SHLIB) variable doesn't exist > > anymore. > > > > Rework dependency on the include file, we can let `swig` generate the > > dependency for us with the use of "-M*" flags. > > Hmm. At no point is swig mentioned in README/etc, and it's not in any > of the CI logic. I wasn't even aware that we had python bindings here. > > Unless someone tries and confirms them not to be broken, I'd be tempted > to drop it all. I bet this has been dead since we dropped Xend. How about the perl binding? Nothing to do with xend for them. The only way to build the binding is to set a variable. It's not possible to enable the binding via ./configure at the moment. So, yes, maybe no one uses them. Cheers,
diff --git a/tools/libs/stat/Makefile b/tools/libs/stat/Makefile index e39fe29bd1..d5d9cb3659 100644 --- a/tools/libs/stat/Makefile +++ b/tools/libs/stat/Makefile @@ -49,23 +49,34 @@ install-bindings: install-perl-bindings install-python-bindings .PHONY: uninstall-bindings uninstall-bindings: uninstall-perl-bindings uninstall-python-bindings -$(BINDINGS): $(SHLIB) $(SHLIB_LINKS) include/xenstat.h +$(BINDINGS): libxenstat.so -SWIG_FLAGS=-module xenstat -Iinclude -I. +SWIG_FLAGS = -module xenstat -I$(XEN_INCLUDE) +SWIG_FLAGS += -MMD -MP -MF .$(if $(filter-out .,$(@D)),$(subst /,@,$(@D))@)$(@F).d # Python bindings -PYTHON_VERSION=$(PYTHON:python%=%) -PYTHON_FLAGS=-I/usr/include/python$(PYTHON_VERSION) -lpython$(PYTHON_VERSION) $(PYMOD): $(PYSRC) $(PYSRC): bindings/swig/xenstat.i - swig -python $(SWIG_FLAGS) -outdir $(@D) -o $(PYSRC) $< - + mkdir -p $(@D) + swig -python $(SWIG_FLAGS) -outdir $(@D) -o $@ $< + +$(PYLIB): CFLAGS += $(shell $(PYTHON)-config --includes) +$(PYLIB): CFLAGS += -fPIC +$(PYLIB): CFLAGS += -Wno-missing-prototypes +$(PYLIB): LDFLAGS += $(SHLIB_LDFLAGS) +$(PYLIB): LDLIBS := $(shell $(PYTHON)-config --libs) +$(PYLIB): LDLIBS += $(LDLIBS_libxenstat) $(PYLIB): $(PYSRC) - $(CC) $(CFLAGS) $(LDFLAGS) $(PYTHON_FLAGS) $(SHLIB_LDFLAGS) -lxenstat -o $@ $< $(APPEND_LDFLAGS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS) $(APPEND_LDFLAGS) +.PHONY: python-bindings python-bindings: $(PYLIB) $(PYMOD) -pythonlibdir=$(prefix)/lib/python$(PYTHON_VERSION)/site-packages +pythonlibdir = $(shell $(PYTHON) -c \ + 'import distutils.sysconfig as cfg; \ + print(cfg.get_python_lib(False, False, prefix="$(prefix)"))') + +.PHONY: install-python-bindings install-python-bindings: $(PYLIB) $(PYMOD) $(INSTALL_PROG) $(PYLIB) $(DESTDIR)$(pythonlibdir)/_xenstat.so $(INSTALL_PROG) $(PYMOD) $(DESTDIR)$(pythonlibdir)/xenstat.py diff --git a/tools/libs/stat/bindings/swig/python/.empty b/tools/libs/stat/bindings/swig/python/.empty deleted file mode 100644 index 2a8dd4274d..0000000000 --- a/tools/libs/stat/bindings/swig/python/.empty +++ /dev/null @@ -1 +0,0 @@ -This directory is empty; this file is included to prevent version control systems from removing the directory.
Fix the dependency on the library, $(SHLIB) variable doesn't exist anymore. Rework dependency on the include file, we can let `swig` generate the dependency for us with the use of "-M*" flags. The xenstat.h file has moved so we need to fix the include location. Rather than relaying 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. Fix python's specific *flags by using python-config, and add them to generic flags variables: CFLAGS, 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 a prototype for the "init" function, so we need "-Wno-missing-prototypes" in order to build it. Add some targets to .PHONY. Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> --- tools/libs/stat/Makefile | 27 +++++++++++++++------ tools/libs/stat/bindings/swig/python/.empty | 1 - 2 files changed, 19 insertions(+), 9 deletions(-) delete mode 100644 tools/libs/stat/bindings/swig/python/.empty