From a3f1f1a72e1a84be2f33ab847114f7acd97e61ea Mon Sep 17 00:00:00 2001 From: Saikrishna Arcot Date: Fri, 30 Jun 2023 10:32:46 -0700 Subject: [PATCH] Reland 'Make changes to building and packaging sairedis (#1116)' (#1194) * Reland 'Make changes to building and packaging sairedis (#1116)' * Make changes to building and packaging sairedis This commit includes the following changes: 1. Use Debian build profiles instead of custom build targets to build different configurations of sairedis. Build profiles were designed for this purpose. This also makes the debian/rules file a bit cleaner. 2. Rely on the debug packages being automatically created, instead of us explicitly specifying it in debian/control. 3. Add actual support for excluding Python 2 binding during build. 4. Make sure the compile flags used for building Python 2 and Python 3 are actually correct. Signed-off-by: Saikrishna Arcot * Update pipeline file Signed-off-by: Saikrishna Arcot * Fix argument for profile Signed-off-by: Saikrishna Arcot * Exclude libsai package from the list of dependencies Signed-off-by: Saikrishna Arcot * Allow multiple syslog artifacts during tests Signed-off-by: Saikrishna Arcot * Fix debug poackage name in dockerfile Signed-off-by: Saikrishna Arcot * Fix armhf build due to python binary not existing Signed-off-by: Saikrishna Arcot --------- Signed-off-by: Saikrishna Arcot --- .azure-pipelines/build-template.yml | 4 +- .azure-pipelines/docker-sonic-vs/Dockerfile | 2 +- configure.ac | 28 +- debian/compat | 2 +- debian/control | 70 +---- debian/libsaimetadata-dev.install | 2 + debian/libsairedis-dev.install | 1 + debian/rules | 81 ++--- m4/ax_python3_devel.m4 | 327 ++++++++++++++++++++ meta/Makefile.am | 4 +- pyext/Makefile.am | 5 +- pyext/py2/Makefile.am | 4 +- pyext/py3/Makefile.am | 2 +- 13 files changed, 406 insertions(+), 126 deletions(-) create mode 100644 m4/ax_python3_devel.m4 diff --git a/.azure-pipelines/build-template.yml b/.azure-pipelines/build-template.yml index 4567435a6..84f839e83 100644 --- a/.azure-pipelines/build-template.yml +++ b/.azure-pipelines/build-template.yml @@ -159,7 +159,7 @@ jobs: if [ '${{ parameters.asan }}' == True ]; then extraflags='--enable-asan' fi - DEB_BUILD_OPTIONS=nocheck fakeroot debian/rules DEB_CONFIGURE_EXTRA_FLAGS=$extraflags DEB_BUILD_PROFILES=nopython2 CFLAGS="" CXXFLAGS="" binary-syncd-vs + DEB_BUILD_OPTIONS=nocheck DEB_CONFIGURE_EXTRA_FLAGS=$extraflags dpkg-buildpackage -us -uc -b -Psyncd,vs,nopython2 -j$(nproc) mv ../*.deb . displayName: "Compile sonic sairedis with coverage enabled" - script: | @@ -227,6 +227,6 @@ jobs: contents: 'syslog-all.tgz' targetFolder: $(Build.ArtifactStagingDirectory) - publish: $(Build.ArtifactStagingDirectory)/ - artifact: ${{ parameters.syslog_artifact_name }} + artifact: ${{ parameters.syslog_artifact_name }}@$(System.JobAttempt) displayName: "Publish syslog artifacts" condition: always() diff --git a/.azure-pipelines/docker-sonic-vs/Dockerfile b/.azure-pipelines/docker-sonic-vs/Dockerfile index deedf0265..9ca53f85a 100644 --- a/.azure-pipelines/docker-sonic-vs/Dockerfile +++ b/.azure-pipelines/docker-sonic-vs/Dockerfile @@ -14,4 +14,4 @@ RUN dpkg -i /debs/libswsscommon_1.0.0_amd64.deb \ /debs/syncd-vs_1.0.0_amd64.deb \ /debs/swss_1.0.0_amd64.deb -RUN if [ "$need_dbg" = "y" ] ; then dpkg -i /debs/syncd-vs-dbg_1.0.0_amd64.deb ; fi +RUN if [ "$need_dbg" = "y" ] ; then dpkg -i /debs/syncd-vs-dbgsym_1.0.0_amd64.deb ; fi diff --git a/configure.ac b/configure.ac index b95367ef5..1f664b490 100644 --- a/configure.ac +++ b/configure.ac @@ -10,8 +10,8 @@ AC_PROG_CC AC_PROG_CXX AC_PROG_LIBTOOL AC_HEADER_STDC -AM_PATH_PYTHON AM_PATH_PYTHON3 +AX_PYTHON3_DEVEL AX_CODE_COVERAGE AX_ADD_AM_MACRO_STATIC([]) @@ -101,6 +101,14 @@ AC_ARG_ENABLE(asan, *) AC_MSG_ERROR(bad value ${enableval} for --enable-asan) ;; esac],[asan_enabled=false]) +AC_ARG_ENABLE(python2, +[ --enable-python2 Generate Python 2 bindings], +[case "${enableval}" in + yes) python2=true ;; + no) python2=false ;; + *) AC_MSG_ERROR(bad value ${enableval} for --enable-python2) ;; +esac],[python2=true]) + if test "x$asan_enabled" = "xtrue"; then CFLAGS_ASAN+=" -fsanitize=address" CFLAGS_ASAN+=" -DASAN_ENABLED" @@ -111,13 +119,31 @@ if test "x$asan_enabled" = "xtrue"; then AC_SUBST(LDFLAGS_ASAN) fi +if test "x$python2" = "xtrue"; then + m4_define_default([_AM_PYTHON_INTERPRETER_LIST], + [python2 python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0]) + AM_PATH_PYTHON + AX_PYTHON_DEVEL([< '3']) + PYTHON2_CPPFLAGS=$PYTHON_CPPFLAGS + PYTHON2_LIBS=$PYTHON_LIBS + AC_SUBST(PYTHON2_CPPFLAGS) + AC_SUBST(PYTHON2_LIBS) +else + # The py-compile script either uses $PYTHON (which won't be set if we're not building python 2 bindings), + # or assumes a default of `python` (which may or may not exist as a symlink). Therefore, just assign + # PYTHON3 to PYTHON to make sure it always points to a valid binary. + PYTHON=$PYTHON3 +fi + AM_CONDITIONAL(ASAN_ENABLED, test x$asan_enabled = xtrue) +AM_CONDITIONAL(PYTHON2, test x$python2 = xtrue) AC_PATH_PROGS(SWIG, [swig3.0 swig]) CXXFLAGS_COMMON="" CXXFLAGS_COMMON+=" -ansi" CXXFLAGS_COMMON+=" -fPIC" +CXXFLAGS_COMMON+=" -pipe" CXXFLAGS_COMMON+=" -std=c++14" CXXFLAGS_COMMON+=" -Wall" CXXFLAGS_COMMON+=" -Wcast-align" diff --git a/debian/compat b/debian/compat index f599e28b8..48082f72f 100644 --- a/debian/compat +++ b/debian/compat @@ -1 +1 @@ -10 +12 diff --git a/debian/control b/debian/control index 5b5284e0b..a07ed6d80 100644 --- a/debian/control +++ b/debian/control @@ -2,17 +2,23 @@ Source: sonic Maintainer: Kamil Cudnik Section: net Priority: optional -Build-Depends: debhelper (>=9), autotools-dev, libzmq5-dev +Build-Depends: debhelper (>= 12), autotools-dev, libzmq5-dev Standards-Version: 1.0.0 Package: syncd Architecture: any +Build-Profiles: +Depends: ${misc:Pre-Depends} +Recommends: ${shlibs:Depends} Conflicts: syncd-rpc, syncd-vs Description: This package contains sync daemon for SONiC project. This sync daemon syncs the ASIC_DB in Redis database and the real ASIC via SAI. Package: syncd-rpc Architecture: any +Build-Profiles: +Depends: ${misc:Pre-Depends} +Recommends: ${shlibs:Depends} Conflicts: syncd, syncd-vs Description: This package contains sync daemon with rpc for SONiC project. This sync daemon syncs the ASIC_DB in Redis database and the real ASIC via SAI. @@ -20,6 +26,9 @@ Description: This package contains sync daemon with rpc for SONiC project. Package: syncd-vs Architecture: any +Build-Profiles: +Depends: ${misc:Pre-Depends} +Recommends: ${shlibs:Depends} Conflicts: syncd-rpc, syncd Description: This package contains sync daemon for SONiC project linked with virtual switch. This sync daemon syncs the ASIC_DB in Redis database and the real ASIC via SAI. @@ -38,6 +47,7 @@ Description: This package contains development files for SAI-Redis. Package: libsaivs Architecture: any +Depends: ${shlibs:Depends}, ${misc:Pre-Depends} Section: libs Description: This package contains SAI-VirtualSwitch implementation for SONiC project. @@ -49,6 +59,7 @@ Description: This package contains development files for SAI-VirtualSwitch. Package: libsaimetadata Architecture: any +Depends: ${shlibs:Depends}, ${misc:Pre-Depends} Section: libs Description: This package contains SAI-Metadata implementation for SONiC project. @@ -58,63 +69,6 @@ Depends: libsaimetadata (= ${binary:Version}) Section: libdevel Description: This package contains development files for SAI-Metadata. -Package: syncd-dbg -Architecture: any -Section: debug -Priority: extra -Conflicts: syncd-rpc-dbg, syncd-vs -Depends: - syncd (= ${binary:Version}), - ${misc:Depends} -Description: debugging symbols for syncd - -Package: syncd-rpc-dbg -Architecture: any -Section: debug -Priority: extra -Conflicts: syncd-dbg, syncd-vs -Depends: - syncd-rpc (= ${binary:Version}), - ${misc:Depends} -Description: debugging symbols for syncd-rpc - -Package: syncd-vs-dbg -Architecture: any -Section: debug -Priority: extra -Conflicts: syncd-dbg, syncd-rpc-dbg -Depends: - syncd-vs (= ${binary:Version}), - ${misc:Depends} -Description: debugging symbols for syncd-vs - -Package: libsairedis-dbg -Architecture: any -Section: debug -Priority: extra -Depends: - libsairedis (= ${binary:Version}), - ${misc:Depends} -Description: debugging symbols for libsairedis - -Package: libsaivs-dbg -Architecture: any -Section: debug -Priority: extra -Depends: - libsaivs (= ${binary:Version}), - ${misc:Depends} -Description: debugging symbols for libsaivs - -Package: libsaimetadata-dbg -Architecture: any -Section: debug -Priority: extra -Depends: - libsaimetadata (= ${binary:Version}), - ${misc:Depends} -Description: debugging symbols for libsaimetadata - Package: python-pysairedis Architecture: any Build-Profiles: diff --git a/debian/libsaimetadata-dev.install b/debian/libsaimetadata-dev.install index a79656b38..877842eeb 100644 --- a/debian/libsaimetadata-dev.install +++ b/debian/libsaimetadata-dev.install @@ -1,3 +1,5 @@ meta/sai*.h usr/include/sai meta/Sai*.h usr/include/sai SAI/meta/sai*.h usr/include/sai +usr/lib/*/libsaimetadata.so +usr/lib/*/libsaimeta.so diff --git a/debian/libsairedis-dev.install b/debian/libsairedis-dev.install index 21fa7340a..d5750f6dd 100644 --- a/debian/libsairedis-dev.install +++ b/debian/libsairedis-dev.install @@ -1 +1,2 @@ lib/sairedis.h usr/include/sai +usr/lib/*/libsairedis.so diff --git a/debian/rules b/debian/rules index 7568b68ca..c66761544 100755 --- a/debian/rules +++ b/debian/rules @@ -3,14 +3,6 @@ # output every command that modifies files on the build system. #export DH_VERBOSE = 1 -.ONESHELL: -SHELL = /bin/bash -.SHELLFLAGS += -ex - -# see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/* -DPKG_EXPORT_BUILDFLAGS = 1 -include /usr/share/dpkg/default.mk - ifneq (${SWSS_COMMON_INC},) SWSS_COMMON_CONFIG = "--with-swss-common-inc=${SWSS_COMMON_INC}" endif @@ -21,7 +13,7 @@ ifneq (${SWSS_COMMON_LIB},) endif # see FEATURE AREAS in dpkg-buildflags(1) -#export DEB_BUILD_MAINT_OPTIONS = hardening=+all +export DEB_BUILD_MAINT_OPTIONS = hardening=+all # see ENVIRONMENT in dpkg-buildflags(1) # package maintainers to append CFLAGS @@ -31,45 +23,32 @@ endif DOPACKAGES = $(shell dh_listpackages) +configure_opts = --disable-static +ifeq ($(ENABLE_ASAN), y) + configure_opts += --enable-asan +endif + # For Debian jessie, stretch, and buster, and Ubuntu bionic and focal, build # Python 2 bindings. This is controlled by the build profile being used. -ifneq (,$(filter python-pysairedis,$(DOPACKAGES))) +ifeq (,$(filter nopython2,$(DEB_BUILD_PROFILES))) configure_opts += --enable-python2 else configure_opts += --disable-python2 endif -clean: - dh $@ --with autotools-dev - -build: - echo build stage is skipped. Please use binary to generate debian packages - -binary: binary-syncd-rpc binary-syncd - -binary-sairedis: - echo '--enable-syncd=no' > /tmp/syncd-build - ENABLESYNCD=no dh clean --with autotools-dev - dh build -N syncd -N syncd-dbg -N syncd-rpc -N syncd-rpc-dbg -N syncd-vs -N syncd-vs-dbg --with autotools-dev - dh binary -N syncd -N syncd-dbg -N syncd-rpc -N syncd-rpc-dbg -N syncd-vs -N syncd-vs-dbg --with autotools-dev - -binary-syncd: - echo > /tmp/syncd-build - dh clean --with autotools-dev - dh build -N syncd-rpc -N syncd-rpc-dbg -N syncd-vs -N syncd-vs-dbg --with autotools-dev - dh binary -N syncd-rpc -N syncd-rpc-dbg -N syncd-vs -N syncd-vs-dbg --with autotools-dev - -binary-syncd-rpc: | binary-syncd - echo '--enable-rpcserver=yes' > /tmp/syncd-build - dh clean --with autotools-dev - dh build -N syncd -N syncd-dbg -N syncd-vs -N syncd-vs-dbg --with autotools-dev - dh binary -N syncd -N syncd-dbg -N syncd-vs -N syncd-vs-dbg --with autotools-dev +ifneq ($(filter syncd,$(DEB_BUILD_PROFILES)),) +ifneq ($(filter rpc,$(DEB_BUILD_PROFILES)),) +configure_opts += --enable-rpcserver +endif +ifneq ($(filter vs,$(DEB_BUILD_PROFILES)),) +configure_opts += --with-sai=vs +endif +else +configure_opts += --disable-syncd +endif -binary-syncd-vs: - echo '--with-sai=vs' > /tmp/syncd-build - dh clean --with autotools-dev - dh build -N syncd -N syncd-dbg -N syncd-rpc -N syncd-rpc-dbg --with autotools-dev - dh binary -N syncd -N syncd-dbg -N syncd-rpc -N syncd-rpc-dbg --with autotools-dev +%: + dh $@ # dh_make generated override targets # This is example for Cmake (See https://bugs.debian.org/641051 ) @@ -77,32 +56,20 @@ binary-syncd-vs: # dh_auto_configure -- \ # -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH) -configure_opts = -ifeq ($(ENABLE_ASAN), y) - configure_opts += --enable-asan -endif - override_dh_auto_configure: - ./autogen.sh - dh_auto_configure -- $(DEB_CONFIGURE_EXTRA_FLAGS) $(shell cat /tmp/syncd-build) ${SWSS_COMMON_CONFIG} $(configure_opts) + dh_auto_configure -- ${SWSS_COMMON_CONFIG} $(configure_opts) override_dh_install: dh_install # Note: escape $ with an extra $ symbol - if egrep -q '(^| )--enable-rpcserver=yes( |$$)' /tmp/syncd-build && [ -f debian/syncd-rpc/usr/bin/syncd_init_common.sh ] ; then +ifneq ($(filter rpc,$(DEB_BUILD_PROFILES)),) + if [ -f debian/syncd-rpc/usr/bin/syncd_init_common.sh ] ; then sed -i 's|ENABLE_SAITHRIFT=0|ENABLE_SAITHRIFT=1 # Add a comment to fix https://github.com/Azure/sonic-buildimage/issues/2694 |' debian/syncd-rpc/usr/bin/syncd_init_common.sh fi +endif override_dh_installinit: dh_installinit --init-script=syncd override_dh_shlibdeps: - $(LD_LIBRARY_PATH_CONFIG) dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info - -override_dh_strip: - dh_strip -psyncd-rpc --dbg-package=syncd-rpc-dbg - dh_strip -psyncd --dbg-package=syncd-dbg - dh_strip -psyncd-vs --dbg-package=syncd-vs-dbg - dh_strip -plibsairedis --dbg-package=libsairedis-dbg - dh_strip -plibsaivs --dbg-package=libsaivs-dbg - dh_strip -plibsaimetadata --dbg-package=libsaimetadata-dbg + $(LD_LIBRARY_PATH_CONFIG) dh_shlibdeps -- --ignore-missing-info -xlibsai diff --git a/m4/ax_python3_devel.m4 b/m4/ax_python3_devel.m4 new file mode 100644 index 000000000..d7df668c7 --- /dev/null +++ b/m4/ax_python3_devel.m4 @@ -0,0 +1,327 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_python_devel.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PYTHON3_DEVEL([version]) +# +# DESCRIPTION +# +# Note: Defines as a precious variable "PYTHON3_VERSION". Don't override it +# in your configure.ac. +# +# This macro checks for Python and tries to get the include path to +# 'Python.h'. It provides the $(PYTHON3_CPPFLAGS) and $(PYTHON3_LIBS) output +# variables. It also exports $(PYTHON3_EXTRA_LIBS) and +# $(PYTHON3_EXTRA_LDFLAGS) for embedding Python in your code. +# +# You can search for some particular version of Python by passing a +# parameter to this macro, for example ">= '2.3.1'", or "== '2.4'". Please +# note that you *have* to pass also an operator along with the version to +# match, and pay special attention to the single quotes surrounding the +# version number. Don't use "PYTHON3_VERSION" for this: that environment +# variable is declared as precious and thus reserved for the end-user. +# +# This macro should work for all versions of Python >= 2.1.0. As an end +# user, you can disable the check for the python version by setting the +# PYTHON3_NOVERSIONCHECK environment variable to something else than the +# empty string. +# +# If you need to use this macro for an older Python version, please +# contact the authors. We're always open for feedback. +# +# LICENSE +# +# Copyright (c) 2009 Sebastian Huber +# Copyright (c) 2009 Alan W. Irwin +# Copyright (c) 2009 Rafael Laboissiere +# Copyright (c) 2009 Andrew Collier +# Copyright (c) 2009 Matteo Settenvini +# Copyright (c) 2009 Horst Knorr +# Copyright (c) 2013 Daniel Mullner +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 21 + +AU_ALIAS([AC_PYTHON3_DEVEL], [AX_PYTHON3_DEVEL]) +AC_DEFUN([AX_PYTHON3_DEVEL],[ + # + # Allow the use of a (user set) custom python version + # + AC_ARG_VAR([PYTHON3_VERSION],[The installed Python + version to use, for example '2.3'. This string + will be appended to the Python interpreter + canonical name.]) + + AC_PATH_PROG([PYTHON3],[python[$PYTHON3_VERSION]]) + if test -z "$PYTHON3"; then + AC_MSG_ERROR([Cannot find python$PYTHON3_VERSION in your system path]) + PYTHON3_VERSION="" + fi + + # + # Check for a version of Python >= 3.0 + # + AC_MSG_CHECKING([for a version of Python >= '3.0']) + ac_supports_python_ver=`$PYTHON3 -c "import sys; \ + ver = sys.version.split ()[[0]]; \ + print (ver >= '3.0')"` + if test "$ac_supports_python_ver" != "True"; then + if test -z "$PYTHON3_NOVERSIONCHECK"; then + AC_MSG_RESULT([no]) + AC_MSG_FAILURE([ +This version of the AC@&t@_PYTHON3_DEVEL macro +is not for versions of Python before +3.0. You may need to re-run configure, setting the +variables PYTHON3_CPPFLAGS, PYTHON3_LIBS, PYTHON3_SITE_PKG, +PYTHON3_EXTRA_LIBS and PYTHON3_EXTRA_LDFLAGS by hand. +Moreover, to disable this check, set PYTHON3_NOVERSIONCHECK +to something else than an empty string. +]) + else + AC_MSG_RESULT([skip at user request]) + fi + else + AC_MSG_RESULT([yes]) + fi + + # + # if the macro parameter ``version'' is set, honour it + # + if test -n "$1"; then + AC_MSG_CHECKING([for a version of Python $1]) + ac_supports_python_ver=`$PYTHON3 -c "import sys; \ + ver = sys.version.split ()[[0]]; \ + print (ver $1)"` + if test "$ac_supports_python_ver" = "True"; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + AC_MSG_ERROR([this package requires Python $1. +If you have it installed, but it isn't the default Python +interpreter in your system path, please pass the PYTHON3_VERSION +variable to configure. See ``configure --help'' for reference. +]) + PYTHON3_VERSION="" + fi + fi + + # + # Check if you have distutils, else fail + # + AC_MSG_CHECKING([for the distutils Python package]) + ac_distutils_result=`$PYTHON3 -c "import distutils" 2>&1` + if test $? -eq 0; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + AC_MSG_ERROR([cannot import Python module "distutils". +Please check your Python installation. The error was: +$ac_distutils_result]) + PYTHON3_VERSION="" + fi + + # + # Check for Python include path + # + AC_MSG_CHECKING([for Python include path]) + if test -z "$PYTHON3_CPPFLAGS"; then + python_path=`$PYTHON3 -c "import distutils.sysconfig; \ + print (distutils.sysconfig.get_python_inc ());"` + plat_python_path=`$PYTHON3 -c "import distutils.sysconfig; \ + print (distutils.sysconfig.get_python_inc (plat_specific=1));"` + if test -n "${python_path}"; then + if test "${plat_python_path}" != "${python_path}"; then + python_path="-I$python_path -I$plat_python_path" + else + python_path="-I$python_path" + fi + fi + PYTHON3_CPPFLAGS=$python_path + fi + AC_MSG_RESULT([$PYTHON3_CPPFLAGS]) + AC_SUBST([PYTHON3_CPPFLAGS]) + + # + # Check for Python library path + # + AC_MSG_CHECKING([for Python library path]) + if test -z "$PYTHON3_LIBS"; then + # (makes two attempts to ensure we've got a version number + # from the interpreter) + ac_python_version=`cat<]], + [[Py_Initialize();]]) + ],[pythonexists=yes],[pythonexists=no]) + AC_LANG_POP([C]) + # turn back to default flags + CPPFLAGS="$ac_save_CPPFLAGS" + LIBS="$ac_save_LIBS" + LDFLAGS="$ac_save_LDFLAGS" + + AC_MSG_RESULT([$pythonexists]) + + if test ! "x$pythonexists" = "xyes"; then + AC_MSG_FAILURE([ + Could not link test program to Python. Maybe the main Python library has been + installed in some non-standard library path. If so, pass it to configure, + via the LIBS environment variable. + Example: ./configure LIBS="-L/usr/non-standard-path/python/lib" + ============================================================================ + ERROR! + You probably have to install the development version of the Python package + for your distribution. The exact name of this package varies among them. + ============================================================================ + ]) + PYTHON3_VERSION="" + fi + + # + # all done! + # +]) diff --git a/meta/Makefile.am b/meta/Makefile.am index 0667fb4ba..c2de85b3f 100644 --- a/meta/Makefile.am +++ b/meta/Makefile.am @@ -8,10 +8,10 @@ BUILT_SOURCES = $(top_srcdir)/SAI/meta/saimetadata.c $(top_srcdir)/SAI/meta/saim $(top_srcdir)/SAI/meta/saimetadata.c $(top_srcdir)/SAI/meta/saimetadata.h: saimeta-gen saimeta-gen: - make -C $(top_srcdir)/SAI/meta saimetadata.c + $(MAKE) -C $(top_srcdir)/SAI/meta saimetadata.c clean-local: - make -C $(top_srcdir)/SAI/meta clean + $(MAKE) -C $(top_srcdir)/SAI/meta clean libsaimetadata_la_SOURCES = \ $(top_srcdir)/SAI/meta/saimetadata.c \ diff --git a/pyext/Makefile.am b/pyext/Makefile.am index ceeeba214..f7c1915f7 100644 --- a/pyext/Makefile.am +++ b/pyext/Makefile.am @@ -1,3 +1,6 @@ -SUBDIRS = py2 py3 +SUBDIRS = py3 +if PYTHON2 +SUBDIRS += py2 +endif ACLOCAL_AMFLAGS = -I m4 diff --git a/pyext/py2/Makefile.am b/pyext/py2/Makefile.am index 981971d79..6c6ed8ef6 100644 --- a/pyext/py2/Makefile.am +++ b/pyext/py2/Makefile.am @@ -9,7 +9,7 @@ AM_CXXFLAGS = $(SAIINC) -I$(top_srcdir)/lib -I.. BUILT_SOURCES = pysairedis_wrap.cpp _pysairedis_la_SOURCES = pysairedis_wrap.cpp $(SOURCES) -_pysairedis_la_CXXFLAGS = -I/usr/include/python$(PYTHON_VERSION) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON) \ +_pysairedis_la_CXXFLAGS = $(PYTHON2_CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON) \ -Wno-cast-qual -Wno-shadow -Wno-redundant-decls -Wno-conversion $(NO_CAST_FUNCTION_TYPE) _pysairedis_la_LDFLAGS = -module \ @@ -18,7 +18,7 @@ _pysairedis_la_LDFLAGS = -module \ -L$(top_srcdir)/meta/.libs -lsaimetadata -lsaimeta \ -lzmq -_pysairedis_la_LIBADD = -lpython$(PYTHON_VERSION) +_pysairedis_la_LIBADD = $(PYTHON2_LIBS) SWIG_FLAG = -Wall -c++ -python -keyword if ARCH64 diff --git a/pyext/py3/Makefile.am b/pyext/py3/Makefile.am index 4d93a416d..e3b936499 100644 --- a/pyext/py3/Makefile.am +++ b/pyext/py3/Makefile.am @@ -9,7 +9,7 @@ AM_CXXFLAGS = $(SAIINC) -I$(top_srcdir)/lib -I.. BUILT_SOURCES = pysairedis_wrap.cpp _pysairedis_la_SOURCES = pysairedis_wrap.cpp $(SOURCES) -_pysairedis_la_CXXFLAGS = -I/usr/include/python$(PYTHON3_VERSION) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON) \ +_pysairedis_la_CXXFLAGS = $(PYTHON3_CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON) \ -Wno-cast-qual -Wno-shadow -Wno-redundant-decls -Wno-conversion $(NO_CAST_FUNCTION_TYPE) _pysairedis_la_LDFLAGS = -module \