python-config.sh.in 2.69 KB
Newer Older
1 2
#!/bin/sh

3 4
# Keep this script in sync with python-config.in

5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
exit_with_usage ()
{
    echo "Usage: $0 --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--abiflags|--configdir"
    exit $1
}

if [ "$1" = "" ] ; then
    exit_with_usage 1
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
20 21 22
        if readlink -f "$RESULT" >/dev/null 2>&1; then
          RESULT=$(readlink -f "$RESULT")
        fi
23 24 25 26 27 28
    fi
    echo $RESULT
}

prefix_real=$(installed_prefix "$0")

29
# Use sed to fix paths from their built-to locations to their installed-to
30 31 32 33 34 35 36 37 38
# locations. Keep prefix & exec_prefix using their original values in case
# they are referenced in other configure variables, to prevent double
# substitution, issue #22140.
prefix="@prefix@"
exec_prefix="@exec_prefix@"
exec_prefix_real=${prefix_real}
includedir=$(echo "@includedir@" | sed "s#$prefix#$prefix_real#")
libdir=$(echo "@libdir@" | sed "s#$prefix#$prefix_real#")
CFLAGS=$(echo "@CFLAGS@" | sed "s#$prefix#$prefix_real#")
39 40 41 42 43
VERSION="@VERSION@"
LIBM="@LIBM@"
LIBC="@LIBC@"
SYSLIBS="$LIBM $LIBC"
ABIFLAGS="@ABIFLAGS@"
44
LIBS="@LIBPYTHON@ @LIBS@ $SYSLIBS"
45 46 47 48 49
BASECFLAGS="@BASECFLAGS@"
LDLIBRARY="@LDLIBRARY@"
OPT="@OPT@"
PY_ENABLE_SHARED="@PY_ENABLE_SHARED@"
LDVERSION="@LDVERSION@"
50 51
LIBDEST=${prefix_real}/lib/python${VERSION}
LIBPL=$(echo "@LIBPL@" | sed "s#$prefix#$prefix_real#")
52
SO="@EXT_SUFFIX@"
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
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 0
        ;;
        --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--abiflags|--configdir)
        ;;
        *)
            exit_with_usage 1
        ;;
    esac
done

for ARG in "$@"
do
    case "$ARG" in
        --prefix)
76
            echo "$prefix_real"
77 78
        ;;
        --exec-prefix)
79
            echo "$exec_prefix_real"
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
        ;;
        --includes)
            echo "$INCDIR $PLATINCDIR"
        ;;
        --cflags)
            echo "$INCDIR $PLATINCDIR $BASECFLAGS $CFLAGS $OPT"
        ;;
        --libs)
            echo "$LIBS"
        ;;
        --ldflags)
            LIBPLUSED=
            if [ "$PY_ENABLE_SHARED" = "0" ] ; then
                LIBPLUSED="-L$LIBPL"
            fi
95
            echo "$LIBPLUSED -L$libdir $LIBS"
96 97 98 99 100 101 102 103 104 105 106 107
        ;;
        --extension-suffix)
            echo "$SO"
        ;;
        --abiflags)
            echo "$ABIFLAGS"
        ;;
        --configdir)
            echo "$LIBPL"
        ;;
esac
done