11#! /bin/sh
22
3- # Keep this script in sync with python-config.in
4-
53exit_with_usage ()
64{
75 echo " Usage: $0 --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--abiflags|--configdir|--embed"
8- exit $ 1
6+ exit 1
97}
108
9+ # Really, python-config.py (and thus .sh) should be called directly, but
10+ # sometimes software (e.g. GDB) calls python-config.sh as if it were the
11+ # Python executable, passing python-config.py as the first argument.
12+ # Work around that oddness by ignoring any .py passed as first arg.
13+ case " $1 " in
14+ * .py)
15+ shift
16+ ;;
17+ esac
18+
1119if [ " $1 " = " " ] ; then
12- exit_with_usage 1
20+ exit_with_usage
1321fi
1422
1523# Returns the actual prefix where this script was installed to.
1624installed_prefix ()
1725{
18- RESULT=$( dirname $( cd $( dirname " $1 " ) && pwd -P) )
19- if which readlink > /dev/null 2>&1 ; then
20- if readlink -f " $RESULT " > /dev/null 2>&1 ; then
21- RESULT=$( readlink -f " $RESULT " )
22- fi
26+ local RESULT=$( dirname $( cd $( dirname " $1 " ) && pwd -P) )
27+ if [ $( which readlink) ] ; then
28+ RESULT=$( readlink -f " $RESULT " )
29+ fi
30+ # Since we don't know where the output from this script will end up
31+ # we keep all paths in Windows-land since MSYS2 can handle that
32+ # while native tools can't handle paths in MSYS2-land.
33+ if [ " $OSTYPE " = " msys" ]; then
34+ RESULT=$( cd " $RESULT " && pwd -W)
2335 fi
2436 echo $RESULT
2537}
2638
2739prefix_real=$( installed_prefix " $0 " )
2840
29- # Use sed to fix paths from their built-to locations to their installed- to
41+ # Use sed to fix paths from their built-to locations to their installed to
3042# locations. Keep prefix & exec_prefix using their original values in case
3143# they are referenced in other configure variables, to prevent double
3244# substitution, issue #22140.
@@ -41,13 +53,17 @@ LIBM="@LIBM@"
4153LIBC=" @LIBC@"
4254SYSLIBS=" $LIBM $LIBC "
4355ABIFLAGS=" @ABIFLAGS@"
56+ # Protect against lack of substitution.
57+ if [ " $ABIFLAGS " = " @" " ABIFLAGS" " @" ] ; then
58+ ABIFLAGS=
59+ fi
4460LIBS=" @LIBPYTHON@ @LIBS@ $SYSLIBS "
4561LIBS_EMBED=" -lpython${VERSION}${ABIFLAGS} @LIBS@ $SYSLIBS "
4662BASECFLAGS=" @BASECFLAGS@"
47- LDLIBRARY=" @LDLIBRARY@"
4863OPT=" @OPT@"
4964PY_ENABLE_SHARED=" @PY_ENABLE_SHARED@"
5065LDVERSION=" @LDVERSION@"
66+ LDLIBRARY=" @LDLIBRARY@"
5167LIBDEST=${prefix_real} /lib/python${VERSION}
5268LIBPL=$( echo " @LIBPL@" | sed " s#$prefix #$prefix_real #" )
5369SO=" @EXT_SUFFIX@"
@@ -61,15 +77,15 @@ for ARG in $*
6177do
6278 case $ARG in
6379 --help)
64- exit_with_usage 0
80+ exit_with_usage
6581 ;;
6682 --embed)
6783 PY_EMBED=1
6884 ;;
6985 --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--abiflags|--configdir)
7086 ;;
7187 * )
72- exit_with_usage 1
88+ exit_with_usage
7389 ;;
7490 esac
7591done
8096
8197for ARG in " $@ "
8298do
83- case " $ARG " in
99+ case $ARG in
84100 --prefix)
85- echo " $prefix_real "
101+ echo -ne " $prefix_real "
86102 ;;
87103 --exec-prefix)
88- echo " $exec_prefix_real "
104+ echo -ne " $exec_prefix_real "
89105 ;;
90106 --includes)
91- echo " $INCDIR $PLATINCDIR "
107+ echo -ne " $INCDIR $PLATINCDIR "
92108 ;;
93109 --cflags)
94- echo " $INCDIR $PLATINCDIR $BASECFLAGS $CFLAGS $OPT "
110+ echo -ne " $INCDIR $PLATINCDIR $BASECFLAGS $CFLAGS $OPT "
95111 ;;
96112 --libs)
97- echo " $LIBS "
113+ echo -ne " $LIBS "
98114 ;;
99115 --ldflags)
100116 LIBPLUSED=
101117 if [ " $PY_ENABLE_SHARED " = " 0" ] ; then
102118 LIBPLUSED=" -L$LIBPL "
103119 fi
104- echo " $LIBPLUSED -L$libdir $LIBS "
120+ echo -ne " $LIBPLUSED -L$libdir $LIBS "
105121 ;;
106122 --extension-suffix)
107- echo " $SO "
123+ echo -ne " $SO "
108124 ;;
109125 --abiflags)
110- echo " $ABIFLAGS "
126+ echo -ne " $ABIFLAGS "
111127 ;;
112128 --configdir)
113- echo " $LIBPL "
129+ echo -ne " $LIBPL "
114130 ;;
115131esac
116132done
0 commit comments