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 | { |
Batuhan Taşkaya | d3cc189 | 2019-08-27 00:45:37 +0300 | [diff] [blame] | 7 | echo "Usage: $0 --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--abiflags|--configdir|--embed" |
doko@python.org | 8742119 | 2013-01-26 11:39:31 +0100 | [diff] [blame] | 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" |
Victor Stinner | 0a8e572 | 2019-05-23 03:30:23 +0200 | [diff] [blame] | 45 | LIBS_EMBED="-lpython${VERSION}${ABIFLAGS} @LIBS@ $SYSLIBS" |
doko@python.org | 8742119 | 2013-01-26 11:39:31 +0100 | [diff] [blame] | 46 | BASECFLAGS="@BASECFLAGS@" |
| 47 | LDLIBRARY="@LDLIBRARY@" |
doko@python.org | 8742119 | 2013-01-26 11:39:31 +0100 | [diff] [blame] | 48 | OPT="@OPT@" |
| 49 | PY_ENABLE_SHARED="@PY_ENABLE_SHARED@" |
| 50 | LDVERSION="@LDVERSION@" |
Michał Górny | 14086cf | 2017-09-27 07:45:06 +0200 | [diff] [blame] | 51 | LIBDEST=${prefix_real}/lib/python${VERSION} |
| 52 | LIBPL=$(echo "@LIBPL@" | sed "s#$prefix#$prefix_real#") |
doko@ubuntu.com | 2bf91bf | 2015-10-19 14:07:57 +0200 | [diff] [blame] | 53 | SO="@EXT_SUFFIX@" |
doko@python.org | 8742119 | 2013-01-26 11:39:31 +0100 | [diff] [blame] | 54 | PYTHONFRAMEWORK="@PYTHONFRAMEWORK@" |
| 55 | INCDIR="-I$includedir/python${VERSION}${ABIFLAGS}" |
| 56 | PLATINCDIR="-I$includedir/python${VERSION}${ABIFLAGS}" |
Victor Stinner | 0a8e572 | 2019-05-23 03:30:23 +0200 | [diff] [blame] | 57 | PY_EMBED=0 |
doko@python.org | 8742119 | 2013-01-26 11:39:31 +0100 | [diff] [blame] | 58 | |
| 59 | # Scan for --help or unknown argument. |
| 60 | for ARG in $* |
| 61 | do |
| 62 | case $ARG in |
| 63 | --help) |
| 64 | exit_with_usage 0 |
| 65 | ;; |
Victor Stinner | 0a8e572 | 2019-05-23 03:30:23 +0200 | [diff] [blame] | 66 | --embed) |
| 67 | PY_EMBED=1 |
| 68 | ;; |
doko@python.org | 8742119 | 2013-01-26 11:39:31 +0100 | [diff] [blame] | 69 | --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--abiflags|--configdir) |
| 70 | ;; |
| 71 | *) |
| 72 | exit_with_usage 1 |
| 73 | ;; |
| 74 | esac |
| 75 | done |
| 76 | |
Victor Stinner | 0a8e572 | 2019-05-23 03:30:23 +0200 | [diff] [blame] | 77 | if [ $PY_EMBED = 1 ] ; then |
| 78 | LIBS="$LIBS_EMBED" |
| 79 | fi |
| 80 | |
doko@python.org | 8742119 | 2013-01-26 11:39:31 +0100 | [diff] [blame] | 81 | for ARG in "$@" |
| 82 | do |
| 83 | case "$ARG" in |
| 84 | --prefix) |
Michał Górny | 14086cf | 2017-09-27 07:45:06 +0200 | [diff] [blame] | 85 | echo "$prefix_real" |
doko@python.org | 8742119 | 2013-01-26 11:39:31 +0100 | [diff] [blame] | 86 | ;; |
| 87 | --exec-prefix) |
Michał Górny | 14086cf | 2017-09-27 07:45:06 +0200 | [diff] [blame] | 88 | echo "$exec_prefix_real" |
doko@python.org | 8742119 | 2013-01-26 11:39:31 +0100 | [diff] [blame] | 89 | ;; |
| 90 | --includes) |
| 91 | echo "$INCDIR $PLATINCDIR" |
| 92 | ;; |
| 93 | --cflags) |
| 94 | echo "$INCDIR $PLATINCDIR $BASECFLAGS $CFLAGS $OPT" |
| 95 | ;; |
| 96 | --libs) |
| 97 | echo "$LIBS" |
| 98 | ;; |
| 99 | --ldflags) |
doko@python.org | 8742119 | 2013-01-26 11:39:31 +0100 | [diff] [blame] | 100 | LIBPLUSED= |
| 101 | if [ "$PY_ENABLE_SHARED" = "0" ] ; then |
| 102 | LIBPLUSED="-L$LIBPL" |
| 103 | fi |
Victor Stinner | e65f01f | 2019-04-09 18:12:44 +0200 | [diff] [blame] | 104 | echo "$LIBPLUSED -L$libdir $LIBS" |
doko@python.org | 8742119 | 2013-01-26 11:39:31 +0100 | [diff] [blame] | 105 | ;; |
| 106 | --extension-suffix) |
| 107 | echo "$SO" |
| 108 | ;; |
| 109 | --abiflags) |
| 110 | echo "$ABIFLAGS" |
| 111 | ;; |
| 112 | --configdir) |
| 113 | echo "$LIBPL" |
| 114 | ;; |
| 115 | esac |
| 116 | done |