From patchwork Mon Dec 6 17:02:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 12659001 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8C68AC433F5 for ; Mon, 6 Dec 2021 17:07:45 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.239474.415182 (Exim 4.92) (envelope-from ) id 1muHSi-0000nc-Pp; Mon, 06 Dec 2021 17:07:36 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 239474.415182; Mon, 06 Dec 2021 17:07:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1muHSi-0000nJ-Ki; Mon, 06 Dec 2021 17:07:36 +0000 Received: by outflank-mailman (input) for mailman id 239474; Mon, 06 Dec 2021 17:07:35 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1muHPj-0005ti-Pj for xen-devel@lists.xenproject.org; Mon, 06 Dec 2021 17:04:31 +0000 Received: from esa6.hc3370-68.iphmx.com (esa6.hc3370-68.iphmx.com [216.71.155.175]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 93194e60-56b6-11ec-8a4d-196798b21f7b; Mon, 06 Dec 2021 18:04:30 +0100 (CET) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 93194e60-56b6-11ec-8a4d-196798b21f7b DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1638810270; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=p5aAroINdY0XxstjIhOll7B4+KbnIHxusYrnLiZlbAY=; b=Pqr2cvAxtlIySiaJWHrtWXJOLgJFVDinliXRFLIJczfsqZLSMQKJ7jn+ F5Ocly2PXPSP2GrJs/D0c7olTh/NAcxf5hLlMUFFAlsbXmLb9v6GB3h0r gsSveEpt6fjzwhFNllFgO0XayXI5+ZHwaY98Pb84AMuRCfRg0/Gy+GROs w=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: HBQFEQ+Y1u8kQ2/rCy/yYli3LDSL6ypUwUk7RO+01grHlWf6UQ/ZmXkXODPK73GhJsz/hPT65x lszt5Za7VFGBZ9rQR6qQYRCE2QQ6pKwZslXlC3CzIG3PGTqE8itXD1jyuUNTbxNjnJT6OdHDXT AwepTnXXDdrBelbcIKrytpl2sDp7GqQ1jiXL+WyWNMPH5QBL7mb4j+UjhfA67AtgVelfHLzfkp ZJu2UsIqVMstvwjSo46qF92JYoGVUr8f8g9ioEE6rgGij8jXxmhV2ByvFsSVqluDfid5P1NAKz 7srUcgCrRnB+lvJuNloc51IC X-SBRS: 5.1 X-MesageID: 59324146 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:ZiC+katT2BP3OfOz8s5ve02bpefnVKdZMUV32f8akzHdYApBsoF/q tZmKW/SMviDYDP1LYwjO4+woUpUup6HmN9jQAM6+S8zEy4S+JbJXdiXEBz9bniYRiHhoOOLz Cm8hv3odp1coqr0/0/1WlTZQP0VOZigHtIQMsadUsxKbVIiGHhJZS5LwbZj29cy2YbhWWthh PupyyHhEA79s9JLGjp8B5Kr8HuDa9yr5Vv0Fn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fotIYEzp/YUzc37xg/Y7LtsiMxLGwjfGh Q+aDQ1B/bvGopMv8cmPjqeB9t/7H+x7F0tcPm/a8bfpanWKojv9mddNCb/acyrcWWX4/LSZS d9Ul/ysYucamFtqspZnF+o5x6wJ+Nay9aRRyR5pHSuXYg3zWK9gOHSPweJGqrZJmu1CoQKzV 0+CpotaNLGONJ+3GVIdPlN4POGK1PVSkTjO9/UlZk794XYvrraAVExTOTiKiTBcc+QpYN90n 795tZ5E8RG7hzorLs2C33Jd+Gm7J3AdV7kq68MBC4jxhwt3klxPbPQw0MMtDE1jvzmUDnQXH w== IronPort-HdrOrdr: A9a23:kNp2CaxHh+WItbtFnv2GKrPwAr1zdoMgy1knxilNoERuA6ilfr OV7ZMmPH7P+U0ssR4b+exoVJPsfZqYz+8R3WBzB8bZYOCFghrKEGgK1+KLqFfd8m/Fh4xgPM xbHJSWfeeQMbEMt6jHCWeDf+rJHLG8gd2VbKzlvhFQpElRGthdBilCe36mLnE= X-IronPort-AV: E=Sophos;i="5.87,292,1631592000"; d="scan'208";a="59324146" From: Anthony PERARD To: CC: Anthony PERARD , Anthony PERARD , Ian Jackson , Wei Liu , Juergen Gross Subject: [XEN PATCH 47/57] libs/stat: Fix and rework python-bindings build Date: Mon, 6 Dec 2021 17:02:30 +0000 Message-ID: <20211206170241.13165-48-anthony.perard@citrix.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211206170241.13165-1-anthony.perard@citrix.com> References: <20211206170241.13165-1-anthony.perard@citrix.com> MIME-Version: 1.0 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 Reviewed-by: Juergen Gross --- 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 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.