• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2
3# Keep this script in sync with python-config.in
4
5exit_with_usage ()
6{
7    echo "Usage: $0 --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--abiflags|--configdir"
8    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
20        if readlink -f "$RESULT" >/dev/null 2>&1; then
21          RESULT=$(readlink -f "$RESULT")
22        fi
23    fi
24    echo $RESULT
25}
26
27prefix_build="@prefix@"
28prefix_real=$(installed_prefix "$0")
29
30# Use sed to fix paths from their built-to locations to their installed-to
31# locations.
32prefix=$(echo "$prefix_build" | sed "s#$prefix_build#$prefix_real#")
33exec_prefix_build="@exec_prefix@"
34exec_prefix=$(echo "$exec_prefix_build" | sed "s#$exec_prefix_build#$prefix_real#")
35includedir=$(echo "@includedir@" | sed "s#$prefix_build#$prefix_real#")
36libdir=$(echo "@libdir@" | sed "s#$prefix_build#$prefix_real#")
37CFLAGS=$(echo "@CFLAGS@" | sed "s#$prefix_build#$prefix_real#")
38VERSION="@VERSION@"
39LIBM="@LIBM@"
40LIBC="@LIBC@"
41SYSLIBS="$LIBM $LIBC"
42ABIFLAGS="@ABIFLAGS@"
43LIBS="-lpython${VERSION}${ABIFLAGS} @LIBS@ $SYSLIBS"
44BASECFLAGS="@BASECFLAGS@"
45LDLIBRARY="@LDLIBRARY@"
46LINKFORSHARED="@LINKFORSHARED@"
47OPT="@OPT@"
48PY_ENABLE_SHARED="@PY_ENABLE_SHARED@"
49LDVERSION="@LDVERSION@"
50LIBDEST=${prefix}/lib/python${VERSION}
51LIBPL=$(echo "@LIBPL@" | sed "s#$prefix_build#$prefix_real#")
52SO="@EXT_SUFFIX@"
53PYTHONFRAMEWORK="@PYTHONFRAMEWORK@"
54INCDIR="-I$includedir/python${VERSION}${ABIFLAGS}"
55PLATINCDIR="-I$includedir/python${VERSION}${ABIFLAGS}"
56
57# Scan for --help or unknown argument.
58for ARG in $*
59do
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
70done
71
72for ARG in "$@"
73do
74    case "$ARG" in
75        --prefix)
76            echo "$prefix"
77        ;;
78        --exec-prefix)
79            echo "$exec_prefix"
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)
91            LINKFORSHAREDUSED=
92            if [ -z "$PYTHONFRAMEWORK" ] ; then
93                LINKFORSHAREDUSED=$LINKFORSHARED
94            fi
95            LIBPLUSED=
96            if [ "$PY_ENABLE_SHARED" = "0" ] ; then
97                LIBPLUSED="-L$LIBPL"
98            fi
99            echo "$LIBPLUSED -L$libdir $LIBS $LINKFORSHAREDUSED"
100        ;;
101        --extension-suffix)
102            echo "$SO"
103        ;;
104        --abiflags)
105            echo "$ABIFLAGS"
106        ;;
107        --configdir)
108            echo "$LIBPL"
109        ;;
110esac
111done
112