fontconfig: needs host-gperf
[buildroot-gz.git] / package / python / 010-fix-python-config.patch
blobb40339b42da21c4e49523059d8d1ce91ec76c1ed
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.
7 Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
9 Index: b/configure.ac
10 ===================================================================
11 --- a/configure.ac
12 +++ b/configure.ac
13 @@ -885,6 +885,7 @@
15 # Other platforms follow
16 if test $enable_shared = "yes"; then
17 + PY_ENABLE_SHARED=1
18 AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
19 case $ac_sys_system in
20 BeOS*)
21 @@ -945,6 +946,7 @@
23 esac
24 else # shared is disabled
25 + PY_ENABLE_SHARED=0
26 case $ac_sys_system in
27 CYGWIN*)
28 BLDLIBRARY='$(LIBRARY)'
29 @@ -1921,6 +1923,9 @@
30 AC_SUBST(BLDSHARED)
31 AC_SUBST(CCSHARED)
32 AC_SUBST(LINKFORSHARED)
33 +AC_SUBST(PY_ENABLE_SHARED)
34 +LIBPL="${prefix}/lib/python${VERSION}/config"
35 +AC_SUBST(LIBPL)
36 # SO is the extension of shared libraries `(including the dot!)
37 # -- usually .so, .sl on HP-UX, .dll on Cygwin
38 AC_MSG_CHECKING(SO)
39 @@ -4588,7 +4593,7 @@
40 AC_SUBST(ENSUREPIP)
42 # generate output files
43 -AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
44 +AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc Misc/python-config.sh)
45 AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix])
46 AC_OUTPUT
48 Index: b/Makefile.pre.in
49 ===================================================================
50 --- a/Makefile.pre.in
51 +++ b/Makefile.pre.in
52 @@ -166,7 +166,7 @@
53 SUBDIRSTOO= Include Lib Misc Demo
55 # Files and directories to be distributed
56 -CONFIGFILES= configure configure.ac acconfig.h pyconfig.h.in Makefile.pre.in
57 +CONFIGFILES= configure configure.ac acconfig.h pyconfig.h.in Makefile.pre.in Misc/python-config.sh
58 DISTFILES= README ChangeLog $(CONFIGFILES)
59 DISTDIRS= $(SUBDIRS) $(SUBDIRSTOO) Ext-dummy
60 DIST= $(DISTFILES) $(DISTDIRS)
61 @@ -410,7 +410,7 @@
63 # Default target
64 all: @DEF_MAKE_ALL_RULE@
65 -build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks
66 +build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks python-config
68 # Compile a binary with gcc profile guided optimization.
69 profile-opt:
70 @@ -1101,10 +1101,12 @@
71 fi; \
72 cd $(srcdir)/Lib/$(PLATDIR); $(RUNSHARED) ./regen
74 -python-config: $(srcdir)/Misc/python-config.in
75 +python-config: $(srcdir)/Misc/python-config.in Misc/python-config.sh
76 # Substitution happens here, as the completely-expanded BINDIR
77 # is not available in configure
78 - sed -e "s,@EXENAME@,$(BINDIR)/python$(VERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config
79 + sed -e "s,@EXENAME@,$(BINDIR)/python$(VERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config.py
80 + # Replace makefile compat. variable references with shell script compat. ones; $(VAR) -> ${VAR}
81 + sed -e 's,\$$(\([A-Za-z0-9_]*\)),\$$\{\1\},g' Misc/python-config.sh >python-config
83 # Install the include files
84 INCLDIRSTOMAKE=$(INCLUDEDIR) $(CONFINCLUDEDIR) $(INCLUDEPY) $(CONFINCLUDEPY)
85 @@ -1163,7 +1165,7 @@
86 $(INSTALL_SCRIPT) $(srcdir)/Modules/makesetup $(DESTDIR)$(LIBPL)/makesetup
87 $(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(LIBPL)/install-sh
88 $(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(VERSION)-config
89 - rm python-config
90 + $(INSTALL_SCRIPT) python-config.py $(DESTDIR)$(LIBPL)/python-config.py
91 @if [ -s Modules/python.exp -a \
92 "`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \
93 echo; echo "Installing support files for building shared extension modules on AIX:"; \
94 @@ -1345,6 +1347,7 @@
95 config.cache config.log pyconfig.h Modules/config.c
96 -rm -rf build platform
97 -rm -rf $(PYTHONFRAMEWORKDIR)
98 + -rm -f python-config.py python-config
100 # Make things extra clean, before making a distribution:
101 # remove all generated files, even Makefile[.pre]
102 Index: b/Misc/python-config.sh.in
103 ===================================================================
104 --- /dev/null
105 +++ b/Misc/python-config.sh.in
106 @@ -0,0 +1,102 @@
107 +#!/bin/sh
109 +exit_with_usage ()
111 + echo "Usage: $0 --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--configdir"
112 + exit $1
115 +if [ "$1" = "" ] ; then
116 + exit_with_usage 1
119 +# Returns the actual prefix where this script was installed to.
120 +installed_prefix ()
122 + RESULT=$(dirname $(cd $(dirname "$1") && pwd -P))
123 + if which readlink >/dev/null 2>&1 ; then
124 + RESULT=$(readlink -f "$RESULT")
125 + fi
126 + echo $RESULT
129 +prefix_build="@prefix@"
130 +prefix_real=$(installed_prefix "$0")
132 +# Use sed to fix paths from their built to locations to their installed to locations.
133 +prefix=$(echo "$prefix_build" | sed "s#$prefix_build#$prefix_real#")
134 +exec_prefix_build="@exec_prefix@"
135 +exec_prefix=$(echo "$exec_prefix_build" | sed "s#$exec_prefix_build#$prefix_real#")
136 +includedir=$(echo "@includedir@")
137 +libdir=$(echo "@libdir@" | sed "s#$prefix_build#$prefix_real#")
138 +CFLAGS=$(echo "@CFLAGS@" | sed "s#$prefix_build#$prefix_real#")
139 +VERSION="@VERSION@"
140 +LIBM="@LIBM@"
141 +LIBC="@LIBC@"
142 +SYSLIBS="$LIBM $LIBC"
143 +LIBS="@LIBS@ $SYSLIBS -lpython${VERSION}"
144 +BASECFLAGS="@BASECFLAGS@"
145 +LDLIBRARY="@LDLIBRARY@"
146 +LINKFORSHARED="@LINKFORSHARED@"
147 +OPT="@OPT@"
148 +PY_ENABLE_SHARED="@PY_ENABLE_SHARED@"
149 +LDVERSION="@LDVERSION@"
150 +LIBDEST=${prefix}/lib/python${VERSION}
151 +LIBPL=$(echo "@LIBPL@" | sed "s#$prefix_build#$prefix_real#")
152 +SO="@SO@"
153 +PYTHONFRAMEWORK="@PYTHONFRAMEWORK@"
154 +INCDIR="-I$includedir/python${VERSION}"
155 +PLATINCDIR="-I$includedir/python${VERSION}"
157 +# Scan for --help or unknown argument.
158 +for ARG in $*
160 + case $ARG in
161 + --help)
162 + exit_with_usage 0
163 + ;;
164 + --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--abiflags|--configdir)
165 + ;;
166 + *)
167 + exit_with_usage 1
168 + ;;
169 +esac
170 +done
172 +for ARG in "$@"
174 + case "$ARG" in
175 + --prefix)
176 + echo "$prefix"
177 + ;;
178 + --exec-prefix)
179 + echo "$exec_prefix"
180 + ;;
181 + --includes)
182 + echo "$INCDIR $PLATINCDIR"
183 + ;;
184 + --cflags)
185 + echo "$INCDIR $PLATINCDIR $BASECFLAGS $CFLAGS $OPT"
186 + ;;
187 + --libs)
188 + echo "$LIBS"
189 + ;;
190 + --ldflags)
191 + LINKFORSHAREDUSED=
192 + if [ -z "$PYTHONFRAMEWORK" ] ; then
193 + LINKFORSHAREDUSED=$LINKFORSHARED
194 + fi
195 + LIBPLUSED=
196 + if [ "$PY_ENABLE_SHARED" = "0" ] ; then
197 + LIBPLUSED="-L$LIBPL"
198 + fi
199 + echo "$LIBPLUSED -L$libdir $LIBS $LINKFORSHAREDUSED"
200 + ;;
201 + --extension-suffix)
202 + echo "$SO"
203 + ;;
204 + --configdir)
205 + echo "$LIBPL"
206 + ;;
207 +esac
208 +done