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_real=$(installed_prefix "$0") 28 29# Use sed to fix paths from their built-to locations to their installed-to 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. 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#") 39VERSION="@VERSION@" 40LIBM="@LIBM@" 41LIBC="@LIBC@" 42SYSLIBS="$LIBM $LIBC" 43ABIFLAGS="@ABIFLAGS@" 44LIBS="-lpython${VERSION}${ABIFLAGS} @LIBS@ $SYSLIBS" 45BASECFLAGS="@BASECFLAGS@" 46LDLIBRARY="@LDLIBRARY@" 47LINKFORSHARED="@LINKFORSHARED@" 48OPT="@OPT@" 49PY_ENABLE_SHARED="@PY_ENABLE_SHARED@" 50LDVERSION="@LDVERSION@" 51LIBDEST=${prefix_real}/lib/python${VERSION} 52LIBPL=$(echo "@LIBPL@" | sed "s#$prefix#$prefix_real#") 53SO="@EXT_SUFFIX@" 54PYTHONFRAMEWORK="@PYTHONFRAMEWORK@" 55INCDIR="-I$includedir/python${VERSION}${ABIFLAGS}" 56PLATINCDIR="-I$includedir/python${VERSION}${ABIFLAGS}" 57 58# Scan for --help or unknown argument. 59for ARG in $* 60do 61 case $ARG in 62 --help) 63 exit_with_usage 0 64 ;; 65 --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--abiflags|--configdir) 66 ;; 67 *) 68 exit_with_usage 1 69 ;; 70 esac 71done 72 73for ARG in "$@" 74do 75 case "$ARG" in 76 --prefix) 77 echo "$prefix_real" 78 ;; 79 --exec-prefix) 80 echo "$exec_prefix_real" 81 ;; 82 --includes) 83 echo "$INCDIR $PLATINCDIR" 84 ;; 85 --cflags) 86 echo "$INCDIR $PLATINCDIR $BASECFLAGS $CFLAGS $OPT" 87 ;; 88 --libs) 89 echo "$LIBS" 90 ;; 91 --ldflags) 92 LINKFORSHAREDUSED= 93 if [ -z "$PYTHONFRAMEWORK" ] ; then 94 LINKFORSHAREDUSED=$LINKFORSHARED 95 fi 96 LIBPLUSED= 97 if [ "$PY_ENABLE_SHARED" = "0" ] ; then 98 LIBPLUSED="-L$LIBPL" 99 fi 100 echo "$LIBPLUSED -L$libdir $LIBS $LINKFORSHAREDUSED" 101 ;; 102 --extension-suffix) 103 echo "$SO" 104 ;; 105 --abiflags) 106 echo "$ABIFLAGS" 107 ;; 108 --configdir) 109 echo "$LIBPL" 110 ;; 111esac 112done 113