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