blob: 2602fe24c0402e14e438f3a139c198020dd1280f [file] [log] [blame]
doko@python.org87421192013-01-26 11:39:31 +01001#!/bin/sh
2
doko@ubuntu.com0df35b02013-08-01 15:32:49 +02003# Keep this script in sync with python-config.in
4
doko@python.org87421192013-01-26 11:39:31 +01005exit_with_usage ()
6{
Batuhan Taşkayad3cc1892019-08-27 00:45:37 +03007 echo "Usage: $0 --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--abiflags|--configdir|--embed"
doko@python.org87421192013-01-26 11:39:31 +01008 exit $1
9}
10
11if [ "$1" = "" ] ; then
12 exit_with_usage 1
13fi
14
15# Returns the actual prefix where this script was installed to.
16installed_prefix ()
17{
18 RESULT=$(dirname $(cd $(dirname "$1") && pwd -P))
19 if which readlink >/dev/null 2>&1 ; then
doko@ubuntu.com0df35b02013-08-01 15:32:49 +020020 if readlink -f "$RESULT" >/dev/null 2>&1; then
21 RESULT=$(readlink -f "$RESULT")
22 fi
doko@python.org87421192013-01-26 11:39:31 +010023 fi
24 echo $RESULT
25}
26
doko@python.org87421192013-01-26 11:39:31 +010027prefix_real=$(installed_prefix "$0")
28
doko@ubuntu.com0df35b02013-08-01 15:32:49 +020029# Use sed to fix paths from their built-to locations to their installed-to
Michał Górny14086cf2017-09-27 07:45:06 +020030# 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.
33prefix="@prefix@"
34exec_prefix="@exec_prefix@"
35exec_prefix_real=${prefix_real}
36includedir=$(echo "@includedir@" | sed "s#$prefix#$prefix_real#")
37libdir=$(echo "@libdir@" | sed "s#$prefix#$prefix_real#")
38CFLAGS=$(echo "@CFLAGS@" | sed "s#$prefix#$prefix_real#")
doko@python.org87421192013-01-26 11:39:31 +010039VERSION="@VERSION@"
40LIBM="@LIBM@"
41LIBC="@LIBC@"
42SYSLIBS="$LIBM $LIBC"
43ABIFLAGS="@ABIFLAGS@"
xdegaye254b3092019-04-29 09:27:40 +020044LIBS="@LIBPYTHON@ @LIBS@ $SYSLIBS"
Victor Stinner0a8e5722019-05-23 03:30:23 +020045LIBS_EMBED="-lpython${VERSION}${ABIFLAGS} @LIBS@ $SYSLIBS"
doko@python.org87421192013-01-26 11:39:31 +010046BASECFLAGS="@BASECFLAGS@"
47LDLIBRARY="@LDLIBRARY@"
doko@python.org87421192013-01-26 11:39:31 +010048OPT="@OPT@"
49PY_ENABLE_SHARED="@PY_ENABLE_SHARED@"
50LDVERSION="@LDVERSION@"
Michał Górny14086cf2017-09-27 07:45:06 +020051LIBDEST=${prefix_real}/lib/python${VERSION}
52LIBPL=$(echo "@LIBPL@" | sed "s#$prefix#$prefix_real#")
doko@ubuntu.com2bf91bf2015-10-19 14:07:57 +020053SO="@EXT_SUFFIX@"
doko@python.org87421192013-01-26 11:39:31 +010054PYTHONFRAMEWORK="@PYTHONFRAMEWORK@"
55INCDIR="-I$includedir/python${VERSION}${ABIFLAGS}"
56PLATINCDIR="-I$includedir/python${VERSION}${ABIFLAGS}"
Victor Stinner0a8e5722019-05-23 03:30:23 +020057PY_EMBED=0
doko@python.org87421192013-01-26 11:39:31 +010058
59# Scan for --help or unknown argument.
60for ARG in $*
61do
62 case $ARG in
63 --help)
64 exit_with_usage 0
65 ;;
Victor Stinner0a8e5722019-05-23 03:30:23 +020066 --embed)
67 PY_EMBED=1
68 ;;
doko@python.org87421192013-01-26 11:39:31 +010069 --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--abiflags|--configdir)
70 ;;
71 *)
72 exit_with_usage 1
73 ;;
74 esac
75done
76
Victor Stinner0a8e5722019-05-23 03:30:23 +020077if [ $PY_EMBED = 1 ] ; then
78 LIBS="$LIBS_EMBED"
79fi
80
doko@python.org87421192013-01-26 11:39:31 +010081for ARG in "$@"
82do
83 case "$ARG" in
84 --prefix)
Michał Górny14086cf2017-09-27 07:45:06 +020085 echo "$prefix_real"
doko@python.org87421192013-01-26 11:39:31 +010086 ;;
87 --exec-prefix)
Michał Górny14086cf2017-09-27 07:45:06 +020088 echo "$exec_prefix_real"
doko@python.org87421192013-01-26 11:39:31 +010089 ;;
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.org87421192013-01-26 11:39:31 +0100100 LIBPLUSED=
101 if [ "$PY_ENABLE_SHARED" = "0" ] ; then
102 LIBPLUSED="-L$LIBPL"
103 fi
Victor Stinnere65f01f2019-04-09 18:12:44 +0200104 echo "$LIBPLUSED -L$libdir $LIBS"
doko@python.org87421192013-01-26 11:39:31 +0100105 ;;
106 --extension-suffix)
107 echo "$SO"
108 ;;
109 --abiflags)
110 echo "$ABIFLAGS"
111 ;;
112 --configdir)
113 echo "$LIBPL"
114 ;;
115esac
116done