diff -urN a/Misc/python-config.sh.in b/Misc/python-config.sh.in --- a/Misc/python-config.sh.in 2014-10-11 14:21:11.611829800 +0100 +++ b/Misc/python-config.sh.in 2014-10-11 14:21:13.685948500 +0100 @@ -1,25 +1,37 @@ #!/bin/sh -# Keep this script in sync with python-config.in - exit_with_usage () { echo "Usage: $0 --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--abiflags|--configdir" - exit $1 + 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 1 + exit_with_usage fi # Returns the actual prefix where this script was installed to. installed_prefix () { - RESULT=$(dirname $(cd $(dirname "$1") && pwd -P)) - if which readlink >/dev/null 2>&1 ; then - if readlink -f "$RESULT" >/dev/null 2>&1; then - RESULT=$(readlink -f "$RESULT") - fi + 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 + # while native tools can't handle paths in MSYS2-land. + if [ "$OSTYPE" = "msys" ]; then + RESULT=$(cd "$RESULT" && pwd -W) fi echo $RESULT } @@ -27,8 +39,7 @@ prefix_build="@prefix@" prefix_real=$(installed_prefix "$0") -# Use sed to fix paths from their built-to locations to their installed-to -# locations. +# 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#") @@ -40,13 +51,17 @@ LIBC="@LIBC@" SYSLIBS="$LIBM $LIBC" ABIFLAGS="@ABIFLAGS@" +# Protect against lack of substitution. +if [ "$ABIFLAGS" = "@""ABIFLAGS""@" ] ; then + ABIFLAGS= +fi LIBS="-lpython${VERSION}${ABIFLAGS} @LIBS@ $SYSLIBS" BASECFLAGS="@BASECFLAGS@" -LDLIBRARY="@LDLIBRARY@" -LINKFORSHARED="@LINKFORSHARED@" OPT="@OPT@" PY_ENABLE_SHARED="@PY_ENABLE_SHARED@" LDVERSION="@LDVERSION@" +LDLIBRARY="@LDLIBRARY@" +LINKFORSHARED="@LINKFORSHARED@" LIBDEST=${prefix}/lib/python${VERSION} LIBPL=$(echo "@LIBPL@" | sed "s#$prefix_build#$prefix_real#") SO="@SO@" @@ -59,33 +74,33 @@ do case $ARG in --help) - exit_with_usage 0 + exit_with_usage ;; --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--abiflags|--configdir) ;; *) - exit_with_usage 1 + exit_with_usage ;; esac done -for ARG in "$@" +for ARG in $* do - case "$ARG" in + case $ARG in --prefix) - echo "$prefix" + echo -ne "$prefix" ;; --exec-prefix) - echo "$exec_prefix" + echo -ne "$exec_prefix " ;; --includes) - echo "$INCDIR $PLATINCDIR" + echo -ne "$INCDIR " ;; --cflags) - echo "$INCDIR $PLATINCDIR $BASECFLAGS $CFLAGS $OPT" + echo -ne "$INCDIR $BASECFLAGS $CFLAGS $OPT " ;; --libs) - echo "$LIBS" + echo -ne "$LIBS " ;; --ldflags) LINKFORSHAREDUSED= @@ -96,16 +111,16 @@ if [ "$PY_ENABLE_SHARED" = "0" ] ; then LIBPLUSED="-L$LIBPL" fi - echo "$LIBPLUSED -L$libdir $LIBS $LINKFORSHAREDUSED" + echo -ne "$LIBPLUSED -L$libdir $LIBS $LINKFORSHAREDUSED " ;; --extension-suffix) - echo "$SO" + echo -ne "$SO " ;; --abiflags) - echo "$ABIFLAGS" + echo -ne "$ABIFLAGS " ;; --configdir) - echo "$LIBPL" + echo -ne "$LIBPL " ;; esac done