doko@python.org | 8742119 | 2013-01-26 11:39:31 +0100 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
doko@ubuntu.com | 0df35b0 | 2013-08-01 15:32:49 +0200 | [diff] [blame] | 3 | # Keep this script in sync with python-config.in |
| 4 | |
doko@python.org | 8742119 | 2013-01-26 11:39:31 +0100 | [diff] [blame] | 5 | exit_with_usage () |
| 6 | { |
| 7 | echo "Usage: $0 --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--abiflags|--configdir" |
| 8 | exit $1 |
| 9 | } |
| 10 | |
| 11 | if [ "$1" = "" ] ; then |
| 12 | exit_with_usage 1 |
| 13 | fi |
| 14 | |
| 15 | # Returns the actual prefix where this script was installed to. |
| 16 | installed_prefix () |
| 17 | { |
| 18 | RESULT=$(dirname $(cd $(dirname "$1") && pwd -P)) |
| 19 | if which readlink >/dev/null 2>&1 ; then |
doko@ubuntu.com | 0df35b0 | 2013-08-01 15:32:49 +0200 | [diff] [blame] | 20 | if readlink -f "$RESULT" >/dev/null 2>&1; then |
| 21 | RESULT=$(readlink -f "$RESULT") |
| 22 | fi |
doko@python.org | 8742119 | 2013-01-26 11:39:31 +0100 | [diff] [blame] | 23 | fi |
| 24 | echo $RESULT |
| 25 | } |
| 26 | |
| 27 | prefix_build="@prefix@" |
| 28 | prefix_real=$(installed_prefix "$0") |
| 29 | |
doko@ubuntu.com | 0df35b0 | 2013-08-01 15:32:49 +0200 | [diff] [blame] | 30 | # Use sed to fix paths from their built-to locations to their installed-to |
| 31 | # locations. |
doko@python.org | 8742119 | 2013-01-26 11:39:31 +0100 | [diff] [blame] | 32 | prefix=$(echo "$prefix_build" | sed "s#$prefix_build#$prefix_real#") |
| 33 | exec_prefix_build="@exec_prefix@" |
| 34 | exec_prefix=$(echo "$exec_prefix_build" | sed "s#$exec_prefix_build#$prefix_real#") |
| 35 | includedir=$(echo "@includedir@" | sed "s#$prefix_build#$prefix_real#") |
| 36 | libdir=$(echo "@libdir@" | sed "s#$prefix_build#$prefix_real#") |
| 37 | CFLAGS=$(echo "@CFLAGS@" | sed "s#$prefix_build#$prefix_real#") |
| 38 | VERSION="@VERSION@" |
| 39 | LIBM="@LIBM@" |
| 40 | LIBC="@LIBC@" |
| 41 | SYSLIBS="$LIBM $LIBC" |
| 42 | ABIFLAGS="@ABIFLAGS@" |
| 43 | LIBS="@LIBS@ $SYSLIBS -lpython${VERSION}${ABIFLAGS}" |
| 44 | BASECFLAGS="@BASECFLAGS@" |
| 45 | LDLIBRARY="@LDLIBRARY@" |
| 46 | LINKFORSHARED="@LINKFORSHARED@" |
| 47 | OPT="@OPT@" |
| 48 | PY_ENABLE_SHARED="@PY_ENABLE_SHARED@" |
| 49 | LDVERSION="@LDVERSION@" |
| 50 | LIBDEST=${prefix}/lib/python${VERSION} |
| 51 | LIBPL=$(echo "@LIBPL@" | sed "s#$prefix_build#$prefix_real#") |
| 52 | SO="@SO@" |
| 53 | PYTHONFRAMEWORK="@PYTHONFRAMEWORK@" |
| 54 | INCDIR="-I$includedir/python${VERSION}${ABIFLAGS}" |
| 55 | PLATINCDIR="-I$includedir/python${VERSION}${ABIFLAGS}" |
| 56 | |
| 57 | # Scan for --help or unknown argument. |
| 58 | for ARG in $* |
| 59 | do |
| 60 | case $ARG in |
| 61 | --help) |
| 62 | exit_with_usage 0 |
| 63 | ;; |
| 64 | --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--abiflags|--configdir) |
| 65 | ;; |
| 66 | *) |
| 67 | exit_with_usage 1 |
| 68 | ;; |
| 69 | esac |
| 70 | done |
| 71 | |
| 72 | for ARG in "$@" |
| 73 | do |
| 74 | case "$ARG" in |
| 75 | --prefix) |
| 76 | echo "$prefix" |
| 77 | ;; |
| 78 | --exec-prefix) |
| 79 | echo "$exec_prefix" |
| 80 | ;; |
| 81 | --includes) |
| 82 | echo "$INCDIR $PLATINCDIR" |
| 83 | ;; |
| 84 | --cflags) |
| 85 | echo "$INCDIR $PLATINCDIR $BASECFLAGS $CFLAGS $OPT" |
| 86 | ;; |
| 87 | --libs) |
| 88 | echo "$LIBS" |
| 89 | ;; |
| 90 | --ldflags) |
| 91 | LINKFORSHAREDUSED= |
| 92 | if [ -z "$PYTHONFRAMEWORK" ] ; then |
| 93 | LINKFORSHAREDUSED=$LINKFORSHARED |
| 94 | fi |
| 95 | LIBPLUSED= |
| 96 | if [ "$PY_ENABLE_SHARED" = "0" ] ; then |
| 97 | LIBPLUSED="-L$LIBPL" |
| 98 | fi |
| 99 | echo "$LIBPLUSED -L$libdir $LIBS $LINKFORSHAREDUSED" |
| 100 | ;; |
| 101 | --extension-suffix) |
| 102 | echo "$SO" |
| 103 | ;; |
| 104 | --abiflags) |
| 105 | echo "$ABIFLAGS" |
| 106 | ;; |
| 107 | --configdir) |
| 108 | echo "$LIBPL" |
| 109 | ;; |
| 110 | esac |
| 111 | done |