2
1

0001-m4-ac_python_devel-fixing-for-crosscompiling-environ.patch 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. From 235ce271f3fee53b918317ebb73a47b3c6a7ae03 Mon Sep 17 00:00:00 2001
  2. From: Angelo Compagnucci <angelo@amarulasolutions.com>
  3. Date: Tue, 24 Mar 2020 22:53:37 +0100
  4. Subject: [PATCH] m4: ac_python_devel: fixing for crosscompiling environments
  5. In a crosscompiling environment it's common to have a python executable
  6. running for the host system with a python-config reporting the host
  7. configuration and a second python-config reporting the target configuration.
  8. In such cases, relying on the default oython-config is wrong and breaks
  9. the cross compilation.
  10. This patch adds a PYTHON_CONFIG variable that can be pointed to the second
  11. python-config and fixes the rest of the m4 accordingly.
  12. Signed-off-by: Angelo Compagnucci <angelo@amarulasolutions.com>
  13. ---
  14. libraries/libapparmor/m4/ac_python_devel.m4 | 25 ++++++++++++++++-----
  15. 1 file changed, 19 insertions(+), 6 deletions(-)
  16. diff --git a/libraries/libapparmor/m4/ac_python_devel.m4 b/libraries/libapparmor/m4/ac_python_devel.m4
  17. index 2ea7dc77..6454e2d8 100644
  18. --- a/libraries/libapparmor/m4/ac_python_devel.m4
  19. +++ b/libraries/libapparmor/m4/ac_python_devel.m4
  20. @@ -13,6 +13,11 @@ AC_DEFUN([AC_PYTHON_DEVEL],[
  21. PYTHON_VERSION=""
  22. fi
  23. + AC_PATH_PROG([PYTHON_CONFIG],[`basename [$PYTHON]-config`])
  24. + if test -z "$PYTHON_CONFIG"; then
  25. + AC_MSG_ERROR([Cannot find python$PYTHON_VERSION-config in your system path])
  26. + fi
  27. +
  28. #
  29. # Check for a version of Python >= 2.1.0
  30. #
  31. @@ -79,8 +84,8 @@ $ac_distutils_result])
  32. # Check for Python include path
  33. #
  34. AC_MSG_CHECKING([for Python include path])
  35. - if type $PYTHON-config; then
  36. - PYTHON_CPPFLAGS=`$PYTHON-config --includes`
  37. + if type $PYTHON_CONFIG; then
  38. + PYTHON_CPPFLAGS=`$PYTHON_CONFIG --includes`
  39. fi
  40. if test -z "$PYTHON_CPPFLAGS"; then
  41. python_path=`$PYTHON -c "import sys; import distutils.sysconfig;\
  42. @@ -97,8 +102,8 @@ sys.stdout.write('%s\n' % distutils.sysconfig.get_python_inc());"`
  43. # Check for Python library path
  44. #
  45. AC_MSG_CHECKING([for Python library path])
  46. - if type $PYTHON-config; then
  47. - PYTHON_LDFLAGS=`$PYTHON-config --ldflags`
  48. + if type $PYTHON_CONFIG; then
  49. + PYTHON_LDFLAGS=`$PYTHON_CONFIG --ldflags`
  50. fi
  51. if test -z "$PYTHON_LDFLAGS"; then
  52. # (makes two attempts to ensure we've got a version number
  53. @@ -136,10 +141,14 @@ sys.stdout.write('%s\n' % distutils.sysconfig.get_python_lib(0,0));"`
  54. # libraries which must be linked in when embedding
  55. #
  56. AC_MSG_CHECKING(python extra libraries)
  57. + if type $PYTHON_CONFIG; then
  58. + PYTHON_EXTRA_LIBS=`$PYTHON_CONFIG --libs --embed` || \
  59. + PYTHON_EXTRA_LIBS=''
  60. + fi
  61. if test -z "$PYTHON_EXTRA_LIBS"; then
  62. PYTHON_EXTRA_LIBS=`$PYTHON -c "import sys; import distutils.sysconfig; \
  63. conf = distutils.sysconfig.get_config_var; \
  64. -sys.stdout.write('%s %s\n' % (conf('LOCALMODLIBS'), conf('LIBS')))"`
  65. +sys.stdout.write('%s %s %s\n' % (conf('BLDLIBRARY'), conf('LOCALMODLIBS'), conf('LIBS')))"`
  66. fi
  67. AC_MSG_RESULT([$PYTHON_EXTRA_LIBS])
  68. AC_SUBST(PYTHON_EXTRA_LIBS)
  69. @@ -148,6 +157,10 @@ sys.stdout.write('%s %s\n' % (conf('LOCALMODLIBS'), conf('LIBS')))"`
  70. # linking flags needed when embedding
  71. #
  72. AC_MSG_CHECKING(python extra linking flags)
  73. + if type $PYTHON_CONFIG; then
  74. + PYTHON_EXTRA_LDFLAGS=`$PYTHON_CONFIG --ldflags --embed` || \
  75. + PYTHON_EXTRA_LDFLAGS=''
  76. + fi
  77. if test -z "$PYTHON_EXTRA_LDFLAGS"; then
  78. PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "import sys; import distutils.sysconfig; \
  79. conf = distutils.sysconfig.get_config_var; \
  80. @@ -164,7 +177,7 @@ sys.stdout.write('%s\n' % conf('LINKFORSHARED'))"`
  81. # save current global flags
  82. ac_save_LIBS="$LIBS"
  83. ac_save_CPPFLAGS="$CPPFLAGS"
  84. - LIBS="$ac_save_LIBS $PYTHON_LDFLAGS"
  85. + LIBS="$ac_save_LIBS $PYTHON_EXTRA_LIBS $PYTHON_LDFLAGS"
  86. CPPFLAGS="$ac_save_CPPFLAGS $PYTHON_CPPFLAGS"
  87. AC_TRY_LINK([
  88. #include <Python.h>
  89. --
  90. 2.17.1