Home | History | Annotate | Download | only in bin
      1 #!/usr/bin/env sh
      2 
      3 exit_with_usage ()
      4 {
      5     echo "Usage: $0 [ignored.py] --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--abiflags|--configdir"
      6     exit 1
      7 }
      8 
      9 case "$1" in
     10     *.py)
     11         shift
     12     ;;
     13 esac
     14 
     15 if [ "$1" = "" ] ; then
     16     exit_with_usage
     17 fi
     18 
     19 # Returns the actual prefix where this script was installed to.
     20 installed_prefix ()
     21 {
     22     local RESULT=$(dirname $(cd $(dirname "$1") && pwd -P))
     23     local READLINK=readlink
     24     if [ "$(uname -s)" = "Darwin" ] ; then
     25         # readlink in darwin can't handle -f.  Use greadlink from MacPorts instead.
     26         READLINK=greadlink
     27     fi
     28     if [ $(which $READLINK) ] ; then
     29         RESULT=$($READLINK -f "$RESULT")
     30     fi
     31     echo $RESULT
     32 }
     33 
     34 prefix_build="/usr/local/google/buildbot/src/android/master-ndk/out/build/buildhost/linux-x86_64/install/host-tools"
     35 prefix_real=$(installed_prefix "$0")
     36 
     37 exec_prefix_build="${prefix}"
     38 exec_prefix_real="$prefix_real"
     39 
     40 # Use sed to fix paths from their built to locations to their installed to locations.
     41 
     42 # The ${prefix}/include and ${exec_prefix}/lib macros can be '$prefix/include' and the like, so we
     43 # need to avoid replacing the prefix multiple times.
     44 prefix="$prefix_build"
     45 exec_prefix="$exec_prefix_build"
     46 
     47 includedir=$(echo "${prefix}/include" | sed "s#^$prefix_build#$prefix_real#")
     48 libdir=$(echo "${exec_prefix}/lib" | sed "s#^$prefix_build#$prefix_real#")
     49 
     50 prefix="$prefix_real"
     51 exec_prefix="$exec_prefix_real"
     52 
     53 CFLAGS="-O2 -Os -fomit-frame-pointer -s"
     54 VERSION="2.7"
     55 LIBM="-lm"
     56 LIBC=""
     57 SYSLIBS="$LIBM $LIBC"
     58 ABIFLAGS="@ABIFLAGS@"
     59 # Protect against lack of substitution.
     60 if [ "$ABIFLAGS" = "@ABIFLAGS@" ] ; then
     61     ABIFLAGS=
     62 fi
     63 LIBS="-lpython${VERSION}${ABIFLAGS} -lpthread -ldl  -lutil $SYSLIBS"
     64 BASECFLAGS=" -fno-strict-aliasing"
     65 LDLIBRARY="libpython${VERSION}.a"
     66 LINKFORSHARED="-Xlinker -export-dynamic"
     67 OPT="-DNDEBUG -fwrapv -O3 -Wall -Wstrict-prototypes"
     68 PY_ENABLE_SHARED="0"
     69 DLLLIBRARY=""
     70 LIBDEST=${prefix}/lib/python${VERSION}
     71 LIBPL=${LIBDEST}/config
     72 SO=".so"
     73 PYTHONFRAMEWORK=""
     74 INCDIR="-I$includedir/python${VERSION}${ABIFLAGS}"
     75 PLATINCDIR="-I$includedir/python${VERSION}${ABIFLAGS}"
     76 
     77 # Scan for --help or unknown argument.
     78 for ARG in $*
     79 do
     80     case $ARG in
     81         --help)
     82             exit_with_usage
     83         ;;
     84         --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags)
     85         ;;
     86         *)
     87             exit_with_usage
     88         ;;
     89     esac
     90 done
     91 
     92 for ARG in $*
     93 do
     94     case $ARG in
     95         --prefix)
     96             echo "$prefix"
     97         ;;
     98         --exec-prefix)
     99             echo "$exec_prefix"
    100         ;;
    101         --includes)
    102             echo "$INCDIR"
    103         ;;
    104         --cflags)
    105             echo "$INCDIR $BASECFLAGS $CFLAGS $OPT"
    106         ;;
    107         --libs)
    108             echo "$LIBS"
    109         ;;
    110         --ldflags)
    111             LINKFORSHAREDUSED=
    112             if [ -z "$PYTHONFRAMEWORK" ] ; then
    113                 LINKFORSHAREDUSED=$LINKFORSHARED
    114             fi
    115             LIBPLUSED=
    116             if [ "$PY_ENABLE_SHARED" = "0" -o -n "${DLLLIBRARY}" ] ; then
    117                 LIBPLUSED="-L$LIBPL"
    118             fi
    119             echo "$LIBPLUSED -L$libdir $LIBS $LINKFORSHAREDUSED"
    120         ;;
    121 esac
    122 done
    123