1
1
#! /bin/sh
2
2
3
- # Keep this script in sync with python-config.in
4
-
5
3
exit_with_usage ()
6
4
{
7
5
echo " Usage: $0 --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--abiflags|--configdir|--embed"
8
- exit $ 1
6
+ exit 1
9
7
}
10
8
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
+
11
19
if [ " $1 " = " " ] ; then
12
- exit_with_usage 1
20
+ exit_with_usage
13
21
fi
14
22
15
23
# Returns the actual prefix where this script was installed to.
16
24
installed_prefix ()
17
25
{
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)
23
35
fi
24
36
echo $RESULT
25
37
}
26
38
27
39
prefix_real=$( installed_prefix " $0 " )
28
40
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
30
42
# locations. Keep prefix & exec_prefix using their original values in case
31
43
# they are referenced in other configure variables, to prevent double
32
44
# substitution, issue #22140.
@@ -41,13 +53,17 @@ LIBM="@LIBM@"
41
53
LIBC=" @LIBC@"
42
54
SYSLIBS=" $LIBM $LIBC "
43
55
ABIFLAGS=" @ABIFLAGS@"
56
+ # Protect against lack of substitution.
57
+ if [ " $ABIFLAGS " = " @" " ABIFLAGS" " @" ] ; then
58
+ ABIFLAGS=
59
+ fi
44
60
LIBS=" @LIBPYTHON@ @LIBS@ $SYSLIBS "
45
61
LIBS_EMBED=" -lpython${VERSION}${ABIFLAGS} @LIBS@ $SYSLIBS "
46
62
BASECFLAGS=" @BASECFLAGS@"
47
- LDLIBRARY=" @LDLIBRARY@"
48
63
OPT=" @OPT@"
49
64
PY_ENABLE_SHARED=" @PY_ENABLE_SHARED@"
50
65
LDVERSION=" @LDVERSION@"
66
+ LDLIBRARY=" @LDLIBRARY@"
51
67
LIBDEST=${prefix_real} /lib/python${VERSION}
52
68
LIBPL=$( echo " @LIBPL@" | sed " s#$prefix #$prefix_real #" )
53
69
SO=" @EXT_SUFFIX@"
@@ -61,15 +77,15 @@ for ARG in $*
61
77
do
62
78
case $ARG in
63
79
--help)
64
- exit_with_usage 0
80
+ exit_with_usage
65
81
;;
66
82
--embed)
67
83
PY_EMBED=1
68
84
;;
69
85
--prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--abiflags|--configdir)
70
86
;;
71
87
* )
72
- exit_with_usage 1
88
+ exit_with_usage
73
89
;;
74
90
esac
75
91
done
80
96
81
97
for ARG in " $@ "
82
98
do
83
- case " $ARG " in
99
+ case $ARG in
84
100
--prefix)
85
- echo " $prefix_real "
101
+ echo -ne " $prefix_real "
86
102
;;
87
103
--exec-prefix)
88
- echo " $exec_prefix_real "
104
+ echo -ne " $exec_prefix_real "
89
105
;;
90
106
--includes)
91
- echo " $INCDIR $PLATINCDIR "
107
+ echo -ne " $INCDIR $PLATINCDIR "
92
108
;;
93
109
--cflags)
94
- echo " $INCDIR $PLATINCDIR $BASECFLAGS $CFLAGS $OPT "
110
+ echo -ne " $INCDIR $PLATINCDIR $BASECFLAGS $CFLAGS $OPT "
95
111
;;
96
112
--libs)
97
- echo " $LIBS "
113
+ echo -ne " $LIBS "
98
114
;;
99
115
--ldflags)
100
116
LIBPLUSED=
101
117
if [ " $PY_ENABLE_SHARED " = " 0" ] ; then
102
118
LIBPLUSED=" -L$LIBPL "
103
119
fi
104
- echo " $LIBPLUSED -L$libdir $LIBS "
120
+ echo -ne " $LIBPLUSED -L$libdir $LIBS "
105
121
;;
106
122
--extension-suffix)
107
- echo " $SO "
123
+ echo -ne " $SO "
108
124
;;
109
125
--abiflags)
110
- echo " $ABIFLAGS "
126
+ echo -ne " $ABIFLAGS "
111
127
;;
112
128
--configdir)
113
- echo " $LIBPL "
129
+ echo -ne " $LIBPL "
114
130
;;
115
131
esac
116
132
done
0 commit comments