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|--embed" 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="@LIBPYTHON@ @LIBS@ $SYSLIBS" 45LIBS_EMBED="-lpython${VERSION}${ABIFLAGS} @LIBS@ $SYSLIBS" 46BASECFLAGS="@BASECFLAGS@" 47LDLIBRARY="@LDLIBRARY@" 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}" 57PY_EMBED=0 58 59# Scan for --help or unknown argument. 60for ARG in $* 61do 62 case $ARG in 63 --help) 64 exit_with_usage 0 65 ;; 66 --embed) 67 PY_EMBED=1 68 ;; 69 --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--abiflags|--configdir) 70 ;; 71 *) 72 exit_with_usage 1 73 ;; 74 esac 75done 76 77if [ $PY_EMBED = 1 ] ; then 78 LIBS="$LIBS_EMBED" 79fi 80 81for ARG in "$@" 82do 83 case "$ARG" in 84 --prefix) 85 echo "$prefix_real" 86 ;; 87 --exec-prefix) 88 echo "$exec_prefix_real" 89 ;; 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) 100 LIBPLUSED= 101 if [ "$PY_ENABLE_SHARED" = "0" ] ; then 102 LIBPLUSED="-L$LIBPL" 103 fi 104 echo "$LIBPLUSED -L$libdir $LIBS" 105 ;; 106 --extension-suffix) 107 echo "$SO" 108 ;; 109 --abiflags) 110 echo "$ABIFLAGS" 111 ;; 112 --configdir) 113 echo "$LIBPL" 114 ;; 115esac 116done 117