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 | |
doko@python.org | 8742119 | 2013-01-26 11:39:31 +0100 | [diff] [blame] | 27 | prefix_real=$(installed_prefix "$0") |
| 28 | |
doko@ubuntu.com | 0df35b0 | 2013-08-01 15:32:49 +0200 | [diff] [blame] | 29 | # Use sed to fix paths from their built-to locations to their installed-to |
Michał Górny | 14086cf | 2017-09-27 07:45:06 +0200 | [diff] [blame] | 30 | # locations. Keep prefix & exec_prefix using their original values in case |
| 31 | # they are referenced in other configure variables, to prevent double |
| 32 | # substitution, issue #22140. |
| 33 | prefix="@prefix@" |
| 34 | exec_prefix="@exec_prefix@" |
| 35 | exec_prefix_real=${prefix_real} |
| 36 | includedir=$(echo "@includedir@" | sed "s#$prefix#$prefix_real#") |
| 37 | libdir=$(echo "@libdir@" | sed "s#$prefix#$prefix_real#") |
| 38 | CFLAGS=$(echo "@CFLAGS@" | sed "s#$prefix#$prefix_real#") |
doko@python.org | 8742119 | 2013-01-26 11:39:31 +0100 | [diff] [blame] | 39 | VERSION="@VERSION@" |
| 40 | LIBM="@LIBM@" |
| 41 | LIBC="@LIBC@" |
| 42 | SYSLIBS="$LIBM $LIBC" |
| 43 | ABIFLAGS="@ABIFLAGS@" |
xdegaye | 254b309 | 2019-04-29 09:27:40 +0200 | [diff] [blame] | 44 | LIBS="@LIBPYTHON@ @LIBS@ $SYSLIBS" |
doko@python.org | 8742119 | 2013-01-26 11:39:31 +0100 | [diff] [blame] | 45 | BASECFLAGS="@BASECFLAGS@" |
| 46 | LDLIBRARY="@LDLIBRARY@" |
doko@python.org | 8742119 | 2013-01-26 11:39:31 +0100 | [diff] [blame] | 47 | OPT="@OPT@" |
| 48 | PY_ENABLE_SHARED="@PY_ENABLE_SHARED@" |
| 49 | LDVERSION="@LDVERSION@" |
Michał Górny | 14086cf | 2017-09-27 07:45:06 +0200 | [diff] [blame] | 50 | LIBDEST=${prefix_real}/lib/python${VERSION} |
| 51 | LIBPL=$(echo "@LIBPL@" | sed "s#$prefix#$prefix_real#") |
doko@ubuntu.com | 2bf91bf | 2015-10-19 14:07:57 +0200 | [diff] [blame] | 52 | SO="@EXT_SUFFIX@" |
doko@python.org | 8742119 | 2013-01-26 11:39:31 +0100 | [diff] [blame] | 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) |
Michał Górny | 14086cf | 2017-09-27 07:45:06 +0200 | [diff] [blame] | 76 | echo "$prefix_real" |
doko@python.org | 8742119 | 2013-01-26 11:39:31 +0100 | [diff] [blame] | 77 | ;; |
| 78 | --exec-prefix) |
Michał Górny | 14086cf | 2017-09-27 07:45:06 +0200 | [diff] [blame] | 79 | echo "$exec_prefix_real" |
doko@python.org | 8742119 | 2013-01-26 11:39:31 +0100 | [diff] [blame] | 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) |
doko@python.org | 8742119 | 2013-01-26 11:39:31 +0100 | [diff] [blame] | 91 | LIBPLUSED= |
| 92 | if [ "$PY_ENABLE_SHARED" = "0" ] ; then |
| 93 | LIBPLUSED="-L$LIBPL" |
| 94 | fi |
Victor Stinner | e65f01f | 2019-04-09 18:12:44 +0200 | [diff] [blame] | 95 | echo "$LIBPLUSED -L$libdir $LIBS" |
doko@python.org | 8742119 | 2013-01-26 11:39:31 +0100 | [diff] [blame] | 96 | ;; |
| 97 | --extension-suffix) |
| 98 | echo "$SO" |
| 99 | ;; |
| 100 | --abiflags) |
| 101 | echo "$ABIFLAGS" |
| 102 | ;; |
| 103 | --configdir) |
| 104 | echo "$LIBPL" |
| 105 | ;; |
| 106 | esac |
| 107 | done |