forked from rstudio/tensorflow
-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure.ac
117 lines (97 loc) · 3.03 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
116
117
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
echo "Using python binary from PATH"
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
# find python
PYTHON_BIN=`which ${USE_PYTHON}`
if test -z "${PYTHON_BIN}"; then
echo "Could not locate ${PYTHON_BIN}"
exit 1
fi
# Check for Anaconda and error out in this case
# (see https://github.com/ContinuumIO/anaconda-issues/issues/498)
PYTHON_VERSION=`${PYTHON_BIN} -c 'import sys; sys.stdout.write(sys.version);'`
case "${PYTHON_VERSION}" in
*Anaconda*) CONDA_PYTHON=1 ;;
*Continuum*) CONDA_PYTHON=1 ;;
*) CONDA_PYTHON=0 ;;
esac
if test "${CONDA_PYTHON}" -eq "1"
then
echo ""
echo " The tensorflow R package is not compatible with "
echo " Conda/Anaconda distributions of Python. Please "
echo " use another version of Python (you can select a "
echo " version to compile against by defining the "
echo " TENSORFLOW_PYTHON environment variable)."
echo ""
exit 1
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 the numpy includes
NUMPY_INCLUDE_DIR=`$PYTHON_BIN -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_BIN -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