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>
10 ===================================================================
15 # Other platforms follow
16 if test $enable_shared = "yes"; then
18 AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
19 case $ac_sys_system in
24 else # shared is disabled
26 case $ac_sys_system in
28 BLDLIBRARY='$(LIBRARY)'
32 AC_SUBST(LINKFORSHARED)
33 +AC_SUBST(PY_ENABLE_SHARED)
34 +LIBPL="${prefix}/lib/python${VERSION}/config"
36 # SO is the extension of shared libraries `(including the dot!)
37 # -- usually .so, .sl on HP-UX, .dll on Cygwin
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])
48 Index: b/Makefile.pre.in
49 ===================================================================
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)
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.
70 @@ -1101,10 +1101,12 @@
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)
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
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:"; \
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 ===================================================================
105 +++ b/Misc/python-config.sh.in
111 + echo "Usage: $0 --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--configdir"
115 +if [ "$1" = "" ] ; then
119 +# Returns the actual prefix where this script was installed to.
122 + RESULT=$(dirname $(cd $(dirname "$1") && pwd -P))
123 + if which readlink >/dev/null 2>&1 ; then
124 + RESULT=$(readlink -f "$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#")
142 +SYSLIBS="$LIBM $LIBC"
143 +LIBS="@LIBS@ $SYSLIBS -lpython${VERSION}"
144 +BASECFLAGS="@BASECFLAGS@"
145 +LDLIBRARY="@LDLIBRARY@"
146 +LINKFORSHARED="@LINKFORSHARED@"
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#")
153 +PYTHONFRAMEWORK="@PYTHONFRAMEWORK@"
154 +INCDIR="-I$includedir/python${VERSION}"
155 +PLATINCDIR="-I$includedir/python${VERSION}"
157 +# Scan for --help or unknown argument.
164 + --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--abiflags|--configdir)
179 + echo "$exec_prefix"
182 + echo "$INCDIR $PLATINCDIR"
185 + echo "$INCDIR $PLATINCDIR $BASECFLAGS $CFLAGS $OPT"
192 + if [ -z "$PYTHONFRAMEWORK" ] ; then
193 + LINKFORSHAREDUSED=$LINKFORSHARED
196 + if [ "$PY_ENABLE_SHARED" = "0" ] ; then
197 + LIBPLUSED="-L$LIBPL"
199 + echo "$LIBPLUSED -L$libdir $LIBS $LINKFORSHAREDUSED"
201 + --extension-suffix)