2
1

python-010-fix-python-config.patch 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. Add a backport of http://bugs.python.org/issue16235 so we can use
  2. python-config for cross builds.
  3. This basically replaces the python version of python-config with a pure-shell
  4. version that's already preprocessed when installed and doesn't depend
  5. on the sysconfig import that usually leads to bad data/results.
  6. Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
  7. diff -Nura Python-2.7.6.orig/configure.ac Python-2.7.6/configure.ac
  8. --- Python-2.7.6.orig/configure.ac 2014-02-25 12:48:16.726535439 -0300
  9. +++ Python-2.7.6/configure.ac 2014-02-25 12:49:00.992176462 -0300
  10. @@ -868,6 +868,7 @@
  11. # Other platforms follow
  12. if test $enable_shared = "yes"; then
  13. + PY_ENABLE_SHARED=1
  14. AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
  15. case $ac_sys_system in
  16. BeOS*)
  17. @@ -928,6 +929,7 @@
  18. esac
  19. else # shared is disabled
  20. + PY_ENABLE_SHARED=0
  21. case $ac_sys_system in
  22. CYGWIN*)
  23. BLDLIBRARY='$(LIBRARY)'
  24. @@ -1905,6 +1907,9 @@
  25. AC_SUBST(BLDSHARED)
  26. AC_SUBST(CCSHARED)
  27. AC_SUBST(LINKFORSHARED)
  28. +AC_SUBST(PY_ENABLE_SHARED)
  29. +LIBPL="${prefix}/lib/python${VERSION}/config"
  30. +AC_SUBST(LIBPL)
  31. # SO is the extension of shared libraries `(including the dot!)
  32. # -- usually .so, .sl on HP-UX, .dll on Cygwin
  33. AC_MSG_CHECKING(SO)
  34. @@ -4529,7 +4534,7 @@
  35. AC_MSG_RESULT(done)
  36. # generate output files
  37. -AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
  38. +AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc Misc/python-config.sh)
  39. AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix])
  40. AC_OUTPUT
  41. diff -Nura Python-2.7.6.orig/Makefile.pre.in Python-2.7.6/Makefile.pre.in
  42. --- Python-2.7.6.orig/Makefile.pre.in 2014-02-25 12:48:16.611533773 -0300
  43. +++ Python-2.7.6/Makefile.pre.in 2014-02-25 12:49:00.993176482 -0300
  44. @@ -161,7 +161,7 @@
  45. SUBDIRSTOO= Include Lib Misc Demo
  46. # Files and directories to be distributed
  47. -CONFIGFILES= configure configure.ac acconfig.h pyconfig.h.in Makefile.pre.in
  48. +CONFIGFILES= configure configure.ac acconfig.h pyconfig.h.in Makefile.pre.in Misc/python-config.sh
  49. DISTFILES= README ChangeLog $(CONFIGFILES)
  50. DISTDIRS= $(SUBDIRS) $(SUBDIRSTOO) Ext-dummy
  51. DIST= $(DISTFILES) $(DISTDIRS)
  52. @@ -405,7 +405,7 @@
  53. # Default target
  54. all: build_all
  55. -build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks
  56. +build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks python-config
  57. # Compile a binary with gcc profile guided optimization.
  58. profile-opt:
  59. @@ -1045,10 +1045,12 @@
  60. fi; \
  61. cd $(srcdir)/Lib/$(PLATDIR); $(RUNSHARED) ./regen
  62. -python-config: $(srcdir)/Misc/python-config.in
  63. +python-config: $(srcdir)/Misc/python-config.in Misc/python-config.sh
  64. # Substitution happens here, as the completely-expanded BINDIR
  65. # is not available in configure
  66. - sed -e "s,@EXENAME@,$(BINDIR)/python$(VERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config
  67. + sed -e "s,@EXENAME@,$(BINDIR)/python$(VERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config.py
  68. + # Replace makefile compat. variable references with shell script compat. ones; $(VAR) -> ${VAR}
  69. + sed -e 's,\$$(\([A-Za-z0-9_]*\)),\$$\{\1\},g' Misc/python-config.sh >python-config
  70. # Install the include files
  71. INCLDIRSTOMAKE=$(INCLUDEDIR) $(CONFINCLUDEDIR) $(INCLUDEPY) $(CONFINCLUDEPY)
  72. @@ -1107,7 +1109,7 @@
  73. $(INSTALL_SCRIPT) $(srcdir)/Modules/makesetup $(DESTDIR)$(LIBPL)/makesetup
  74. $(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(LIBPL)/install-sh
  75. $(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(VERSION)-config
  76. - rm python-config
  77. + $(INSTALL_SCRIPT) python-config.py $(DESTDIR)$(LIBPL)/python-config.py
  78. @if [ -s Modules/python.exp -a \
  79. "`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \
  80. echo; echo "Installing support files for building shared extension modules on AIX:"; \
  81. @@ -1287,6 +1289,7 @@
  82. config.cache config.log pyconfig.h Modules/config.c
  83. -rm -rf build platform
  84. -rm -rf $(PYTHONFRAMEWORKDIR)
  85. + -rm -f python-config.py python-config
  86. # Make things extra clean, before making a distribution:
  87. # remove all generated files, even Makefile[.pre]
  88. diff -Nura Python-2.7.6.orig/Misc/python-config.sh.in Python-2.7.6/Misc/python-config.sh.in
  89. --- Python-2.7.6.orig/Misc/python-config.sh.in 1969-12-31 21:00:00.000000000 -0300
  90. +++ Python-2.7.6/Misc/python-config.sh.in 2014-02-25 12:49:00.993176482 -0300
  91. @@ -0,0 +1,102 @@
  92. +#!/bin/sh
  93. +
  94. +exit_with_usage ()
  95. +{
  96. + echo "Usage: $0 --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--configdir"
  97. + exit $1
  98. +}
  99. +
  100. +if [ "$1" = "" ] ; then
  101. + exit_with_usage 1
  102. +fi
  103. +
  104. +# Returns the actual prefix where this script was installed to.
  105. +installed_prefix ()
  106. +{
  107. + RESULT=$(dirname $(cd $(dirname "$1") && pwd -P))
  108. + if which readlink >/dev/null 2>&1 ; then
  109. + RESULT=$(readlink -f "$RESULT")
  110. + fi
  111. + echo $RESULT
  112. +}
  113. +
  114. +prefix_build="@prefix@"
  115. +prefix_real=$(installed_prefix "$0")
  116. +
  117. +# Use sed to fix paths from their built to locations to their installed to locations.
  118. +prefix=$(echo "$prefix_build" | sed "s#$prefix_build#$prefix_real#")
  119. +exec_prefix_build="@exec_prefix@"
  120. +exec_prefix=$(echo "$exec_prefix_build" | sed "s#$exec_prefix_build#$prefix_real#")
  121. +includedir=$(echo "@includedir@")
  122. +libdir=$(echo "@libdir@" | sed "s#$prefix_build#$prefix_real#")
  123. +CFLAGS=$(echo "@CFLAGS@" | sed "s#$prefix_build#$prefix_real#")
  124. +VERSION="@VERSION@"
  125. +LIBM="@LIBM@"
  126. +LIBC="@LIBC@"
  127. +SYSLIBS="$LIBM $LIBC"
  128. +LIBS="@LIBS@ $SYSLIBS -lpython${VERSION}"
  129. +BASECFLAGS="@BASECFLAGS@"
  130. +LDLIBRARY="@LDLIBRARY@"
  131. +LINKFORSHARED="@LINKFORSHARED@"
  132. +OPT="@OPT@"
  133. +PY_ENABLE_SHARED="@PY_ENABLE_SHARED@"
  134. +LDVERSION="@LDVERSION@"
  135. +LIBDEST=${prefix}/lib/python${VERSION}
  136. +LIBPL=$(echo "@LIBPL@" | sed "s#$prefix_build#$prefix_real#")
  137. +SO="@SO@"
  138. +PYTHONFRAMEWORK="@PYTHONFRAMEWORK@"
  139. +INCDIR="-I$includedir/python${VERSION}"
  140. +PLATINCDIR="-I$includedir/python${VERSION}"
  141. +
  142. +# Scan for --help or unknown argument.
  143. +for ARG in $*
  144. +do
  145. + case $ARG in
  146. + --help)
  147. + exit_with_usage 0
  148. + ;;
  149. + --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--abiflags|--configdir)
  150. + ;;
  151. + *)
  152. + exit_with_usage 1
  153. + ;;
  154. +esac
  155. +done
  156. +
  157. +for ARG in "$@"
  158. +do
  159. + case "$ARG" in
  160. + --prefix)
  161. + echo "$prefix"
  162. + ;;
  163. + --exec-prefix)
  164. + echo "$exec_prefix"
  165. + ;;
  166. + --includes)
  167. + echo "$INCDIR $PLATINCDIR"
  168. + ;;
  169. + --cflags)
  170. + echo "$INCDIR $PLATINCDIR $BASECFLAGS $CFLAGS $OPT"
  171. + ;;
  172. + --libs)
  173. + echo "$LIBS"
  174. + ;;
  175. + --ldflags)
  176. + LINKFORSHAREDUSED=
  177. + if [ -z "$PYTHONFRAMEWORK" ] ; then
  178. + LINKFORSHAREDUSED=$LINKFORSHARED
  179. + fi
  180. + LIBPLUSED=
  181. + if [ "$PY_ENABLE_SHARED" = "0" ] ; then
  182. + LIBPLUSED="-L$LIBPL"
  183. + fi
  184. + echo "$LIBPLUSED -L$libdir $LIBS $LINKFORSHAREDUSED"
  185. + ;;
  186. + --extension-suffix)
  187. + echo "$SO"
  188. + ;;
  189. + --configdir)
  190. + echo "$LIBPL"
  191. + ;;
  192. +esac
  193. +done