diff -urN a/configure.ac b/configure.ac --- a/configure.ac 2013-12-27 16:50:19.310591300 +0000 +++ b/configure.ac 2013-12-27 16:50:23.266817600 +0000 @@ -968,6 +968,7 @@ # Other platforms follow if test $enable_shared = "yes"; then + PY_ENABLE_SHARED=1 AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.]) case $ac_sys_system in CYGWIN*) @@ -1030,6 +1031,7 @@ ;; esac else # shared is disabled + PY_ENABLE_SHARED=0 case $ac_sys_system in CYGWIN*) BLDLIBRARY='$(LIBRARY)' @@ -1041,6 +1043,9 @@ LDLIBRARY='libpython$(LDVERSION).a';; esac fi +AC_SUBST(PY_ENABLE_SHARED) +LIBPL="${prefix}"/lib/python"${VERSION}"/config-"${LDVERSION}" +AC_SUBST(LIBPL) if test "$cross_compiling" = yes; then RUNSHARED= @@ -4924,7 +4929,7 @@ fi # generate output files -AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc) +AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc Misc/python-config.sh) AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix]) AC_OUTPUT diff -urN a/Makefile.pre.in b/Makefile.pre.in --- a/Makefile.pre.in 2013-12-27 16:50:20.271646300 +0000 +++ b/Makefile.pre.in 2013-12-27 16:50:23.268817700 +0000 @@ -1176,6 +1176,8 @@ # Substitution happens here, as the completely-expanded BINDIR # is not available in configure sed -e "s,@EXENAME@,$(BINDIR)/python$(LDVERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config + # Replace makefile compat. variable references with shell script compat. ones; $(VAR) -> ${VAR} + sed -e "s,\$$(\([A-Za-z0-9_]*\)),\$$\{\1\},g" < Misc/python-config.sh >python-config.sh # Install the include files INCLDIRSTOMAKE=$(INCLUDEDIR) $(CONFINCLUDEDIR) $(INCLUDEPY) $(CONFINCLUDEPY) @@ -1234,6 +1236,7 @@ $(INSTALL_SCRIPT) $(srcdir)/Modules/makesetup $(DESTDIR)$(LIBPL)/makesetup $(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(LIBPL)/install-sh $(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(LDVERSION)-config + $(INSTALL_SCRIPT) python-config.sh $(DESTDIR)$(BINDIR)/python$(LDVERSION)-config.sh rm python-config @if [ -s Modules/python.exp -a \ "`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \ diff -urN a/Misc/python-config.sh.in b/Misc/python-config.sh.in --- a/Misc/python-config.sh.in 1970-01-01 01:00:00.000000000 +0100 +++ b/Misc/python-config.sh.in 2013-12-27 16:58:41.425310600 +0000 @@ -0,0 +1,126 @@ +#!/bin/sh + +exit_with_usage () +{ + echo "Usage: $0 --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--abiflags|--configdir" + exit 1 +} + +# Really, python-config.py (and thus .sh) should be called directly, but +# sometimes software (e.g. GDB) calls python-config.sh as if it were the +# Python executable, passing python-config.py as the first argument. +# Work around that oddness by ignoring any .py passed as first arg. +case "$1" in + *.py) + shift + ;; +esac + +if [ "$1" = "" ] ; then + exit_with_usage +fi + +# Returns the actual prefix where this script was installed to. +installed_prefix () +{ + local RESULT=$(dirname $(cd $(dirname "$1") && pwd -P)) + if [ $(which readlink) ] ; then + RESULT=$(readlink -f "$RESULT") + fi + # Since we don't know where the output from this script will end up + # we keep all paths in Windows-land since MSYS2 can handle that + # whilst native tools can't handle paths in MSYS2-land. + if [ "$OSTYPE" = "msys" ]; then + RESULT=$(cd "$RESULT" && pwd -W) + fi + echo $RESULT +} + +prefix_build="@prefix@" +prefix_real=$(installed_prefix "$0") + +# Use sed to fix paths from their built to locations to their installed to locations. +prefix=$(echo "$prefix_build" | sed "s#$prefix_build#$prefix_real#") +exec_prefix_build="@exec_prefix@" +exec_prefix=$(echo "$exec_prefix_build" | sed "s#$exec_prefix_build#$prefix_real#") +includedir=$(echo "@includedir@" | sed "s#$prefix_build#$prefix_real#") +libdir=$(echo "@libdir@" | sed "s#$prefix_build#$prefix_real#") +CFLAGS=$(echo "@CFLAGS@" | sed "s#$prefix_build#$prefix_real#") +VERSION="@VERSION@" +LIBM="@LIBM@" +LIBC="@LIBC@" +SYSLIBS="$LIBM $LIBC" +ABIFLAGS="@ABIFLAGS@" +# Protect against lack of substitution. +if [ "$ABIFLAGS" = "@""ABIFLAGS""@" ] ; then + ABIFLAGS= +fi +LIBS="@LIBS@ $SYSLIBS -lpython${VERSION}${ABIFLAGS}" +BASECFLAGS="@BASECFLAGS@" +LDLIBRARY="@LDLIBRARY@" +LINKFORSHARED="@LINKFORSHARED@" +OPT="@OPT@" +PY_ENABLE_SHARED="@PY_ENABLE_SHARED@" +LDVERSION="@LDVERSION@" +LIBDEST=${prefix}/lib/python${VERSION} +LIBPL=$(echo "@LIBPL@" | sed "s#$prefix_build#$prefix_real#") +SO="@SO@" +PYTHONFRAMEWORK="@PYTHONFRAMEWORK@" +INCDIR="-I$includedir/python${VERSION}${ABIFLAGS}" +PLATINCDIR="-I$includedir/python${VERSION}${ABIFLAGS}" + +# Scan for --help or unknown argument. +for ARG in $* +do + case $ARG in + --help) + exit_with_usage + ;; + --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--abiflags|--configdir) + ;; + *) + exit_with_usage + ;; + esac +done + +for ARG in $* +do + case $ARG in + --prefix) + echo -ne "$prefix" + ;; + --exec-prefix) + echo -ne "$exec_prefix " + ;; + --includes) + echo -ne "$INCDIR " + ;; + --cflags) + echo -ne "$INCDIR $BASECFLAGS $CFLAGS $OPT " + ;; + --libs) + echo -ne "$LIBS " + ;; + --ldflags) + LINKFORSHAREDUSED= + if [ -z "$PYTHONFRAMEWORK" ] ; then + LINKFORSHAREDUSED=$LINKFORSHARED + fi + LIBPLUSED= + if [ "$PY_ENABLE_SHARED" = "0" ] ; then + LIBPLUSED="-L$LIBPL" + fi + echo -ne "$LIBPLUSED -L$libdir $LIBS $LINKFORSHAREDUSED " + ;; + --extension-suffix) + echo -ne "$SO " + ;; + --abiflags) + echo -ne "$ABIFLAGS " + ;; + --configdir) + echo -ne "$LIBPL " + ;; +esac +done