forked from rstudio/tensorflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
115 lines (94 loc) · 3.06 KB
/
configure.ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
AC_INIT(tensorflow, 0.2, [email protected])
AC_CONFIG_SRCDIR([src])
# find R home and set CC/CFLAGS
: ${R_HOME=`R RHOME`}
if test -z "${R_HOME}"; then
echo "Could not determine R_HOME"
exit 1
fi
RBIN="${R_HOME}/bin/R"
CC=`"${RBIN}" CMD config CC`;
CFLAGS=`"${RBIN}" CMD config CFLAGS`
RLD=`"${RBIN}" CMD config --ldflags 2>/dev/null`
has_R_shlib=no
if test -n "$RLD"; then
has_R_shlib=yes
fi
# find tensorflow target python binary
if test -z "${TENSORFLOW_PYTHON}"
then
USE_PYTHON=python
else
TENSORFLOW_PYTHON="${TENSORFLOW_PYTHON/#\~/$HOME}"
echo "Using python binary at ${TENSORFLOW_PYTHON}"
USE_PYTHON=${TENSORFLOW_PYTHON}
fi
# find tensorflow target python version
if test -z "${TENSORFLOW_PYTHON_VERSION}"; then
# use 3 if the default python binary aliases python3
PYTHON_VERSION=`${USE_PYTHON} -c 'import sys; import platform; major, minor, patch = platform.python_version_tuple(); sys.stdout.write(major);'`
if [[ $PYTHON_VERSION == "3" ]]; then
USE_PYTHON="${USE_PYTHON}3"
fi
else
echo "Using python version ${TENSORFLOW_PYTHON_VERSION}"
USE_PYTHON=${USE_PYTHON}${TENSORFLOW_PYTHON_VERSION}
fi
# determine path to python-config
USE_PYTHON_CONFIG=${USE_PYTHON}-config
# Extract the linker and include flags for python
: ${PYTHONCONFIG=`which ${USE_PYTHON_CONFIG}`}
if test -z "${PYTHONCONFIG}"; then
echo "Could not locate ${USE_PYTHON_CONFIG}"
exit 1
fi
PKG_LIBS=`$PYTHONCONFIG --ldflags`
PKG_CPPFLAGS=`$PYTHONCONFIG --includes`
# find python
: ${PYTHON=`which ${USE_PYTHON}`}
PYTHON_BIN=`which ${USE_PYTHON}`
if test -z "${PYTHON}"; then
echo "Could not locate ${PYTHON}"
exit 1
fi
# anaconda doesn't provide a -L in ldflags so let's look for one if we need to
# (see https://github.com/JuliaPy/PyCall.jl/issues/37)
if [[ "$PKG_LIBS" != *"-L"* ]]; then
PYTHON_BIN_DIR=`dirname ${PYTHON_BIN}`
PYTHON_ROOT_DIR=`dirname ${PYTHON_BIN_DIR}`
PYTHON_LIB_DIR=${PYTHON_ROOT_DIR}/lib
PKG_LIBS="${PKG_LIBS} -L${PYTHON_LIB_DIR}"
fi
# anaconda adds a -stacksize argument for python3, this isn't allowed
# for building shared libraries
if [[ "$PKG_LIBS" == *"-stack_size,"* ]]; then
PKG_LIBS=`echo "${PKG_LIBS}"|sed 's/-stack_size,[0-9]*//g'`
fi
# For rpath related reasons anaconda actually can't be linked to in this
# fashion, see discussion here:
# https://github.com/ContinuumIO/anaconda-issues/issues/498
# find the numpy includes
NUMPY_INCLUDE_DIR=`$PYTHON -c "import numpy; print(numpy.get_include())"`
if test -z "${NUMPY_INCLUDE_DIR}"; then
echo "Could not locate numpy include directory"
exit 1
fi
PKG_CPPFLAGS="$PKG_CPPFLAGS -I$NUMPY_INCLUDE_DIR"
# Find the .so library for python
PYTHONLIBFILE=libpython`$PYTHON -c "import sys; print(sys.version[[:3]])"`.so
PKG_CPPFLAGS="$PKG_CPPFLAGS -D PYTHONLIBFILE=$PYTHONLIBFILE"
AC_SUBST(PYTHON_BIN)
AC_SUBST(PKG_LIBS)
AC_SUBST(PKG_CPPFLAGS)
AC_SUBST(NUMPY_INCLUDE_DIR)
AC_PREREQ
# Checks for programs.
AC_PROG_CC
# Checks for libraries.
# (None)
# Checks for header files.
# (None)
# Checks for typedefs, structures, and compiler characteristics.
# (None)
AC_CONFIG_FILES([src/Makevars R/config.R])
AC_OUTPUT