| 19165 |
hornik |
1 |
## config -- Simple shell script to get the values of basic R configure
|
|
|
2 |
## variables, or the header and library flags necessary for linking
|
|
|
3 |
## against R.
|
|
|
4 |
##
|
|
|
5 |
## Usage:
|
|
|
6 |
## R CMD config [options] [VAR]
|
|
|
7 |
|
| 62501 |
ripley |
8 |
## Copyright (C) 2002-13 The R Core Team
|
| 19165 |
hornik |
9 |
##
|
|
|
10 |
## This document is free software; you can redistribute it and/or modify
|
|
|
11 |
## it under the terms of the GNU General Public License as published by
|
|
|
12 |
## the Free Software Foundation; either version 2, or (at your option)
|
|
|
13 |
## any later version.
|
|
|
14 |
##
|
|
|
15 |
## This program is distributed in the hope that it will be useful, but
|
|
|
16 |
## WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
17 |
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
18 |
## General Public License for more details.
|
|
|
19 |
##
|
| 42314 |
ripley |
20 |
## A copy of the GNU General Public License is available at
|
|
|
21 |
## http://www.r-project.org/Licenses/
|
| 19165 |
hornik |
22 |
|
| 37351 |
ripley |
23 |
revision='$Revision: 63217 $'
|
| 19165 |
hornik |
24 |
version=`set - ${revision}; echo ${2}`
|
| 47522 |
ripley |
25 |
version="R configuration information retrieval script: ${R_VERSION} (r${version})
|
| 19165 |
hornik |
26 |
|
| 62501 |
ripley |
27 |
Copyright (C) 2002-13 The R Core Team.
|
| 42192 |
ripley |
28 |
This is free software; see the GNU General Public License version 2
|
| 19165 |
hornik |
29 |
or later for copying conditions. There is NO warranty."
|
|
|
30 |
|
|
|
31 |
usage="Usage: R CMD config [options] [VAR]
|
|
|
32 |
|
|
|
33 |
Get the value of a basic R configure variable VAR which must be among
|
|
|
34 |
those listed in the 'Variables' section below, or the header and
|
|
|
35 |
library flags necessary for linking against R.
|
|
|
36 |
|
|
|
37 |
Options:
|
|
|
38 |
-h, --help print short help message and exit
|
| 47442 |
hornik |
39 |
-v, --version print version info and exit
|
| 19165 |
hornik |
40 |
--cppflags print pre-processor flags required to compile
|
| 63217 |
ripley |
41 |
a C/C++ file using R as a library
|
|
|
42 |
--ldflags print linker flags needed for linking a front-end
|
|
|
43 |
against the R library
|
| 62515 |
ripley |
44 |
--no-user-files ignore customization files under ~/.R
|
|
|
45 |
--no-site-files ignore site customization files under R_HOME/etc
|
| 19165 |
hornik |
46 |
|
|
|
47 |
Variables:
|
| 46994 |
ripley |
48 |
BLAS_LIBS flags needed for linking against external BLAS libraries
|
| 29123 |
ripley |
49 |
CC C compiler command
|
|
|
50 |
CFLAGS C compiler flags
|
|
|
51 |
CPICFLAGS special flags for compiling C code to be turned into a
|
| 46994 |
ripley |
52 |
shared library
|
| 29123 |
ripley |
53 |
CPP C preprocessor
|
|
|
54 |
CPPFLAGS C/C++ preprocessor flags, e.g. -I<dir> if you have
|
| 46994 |
ripley |
55 |
headers in a nonstandard directory <dir>
|
| 29123 |
ripley |
56 |
CXX C++ compiler command
|
|
|
57 |
CXXCPP C++ preprocessor
|
|
|
58 |
CXXFLAGS C++ compiler flags
|
|
|
59 |
CXXPICFLAGS special flags for compiling C++ code to be turned into a
|
| 46994 |
ripley |
60 |
shared library
|
| 47780 |
ripley |
61 |
DYLIB_EXT file extension (including '.') for dynamic libraries
|
| 29123 |
ripley |
62 |
DYLIB_LD command for linking dynamic libraries which contain
|
| 46994 |
ripley |
63 |
object files from a C or Fortran compiler only
|
| 29123 |
ripley |
64 |
DYLIB_LDFLAGS
|
| 46994 |
ripley |
65 |
special flags used by DYLIB_LD
|
| 29123 |
ripley |
66 |
F77 Fortran 77 compiler command
|
|
|
67 |
FFLAGS Fortran 77 compiler flags
|
|
|
68 |
FLIBS linker flags needed to link Fortran code
|
|
|
69 |
FPICFLAGS special flags for compiling Fortran code to be turned
|
| 46994 |
ripley |
70 |
into a shared library
|
| 45258 |
ripley |
71 |
FC Fortran 9x compiler command
|
|
|
72 |
FCFLAGS Fortran 9x compiler flags
|
| 45267 |
ripley |
73 |
FCPICFLAGS special flags for compiling Fortran 9x code to be turned
|
| 46994 |
ripley |
74 |
into a shared library
|
| 39786 |
urbaneks |
75 |
JAR Java archive tool command
|
|
|
76 |
JAVA Java interpreter command
|
|
|
77 |
JAVAC Java compiler command
|
|
|
78 |
JAVAH Java header and stub generator command
|
| 41169 |
urbaneks |
79 |
JAVA_HOME path to the home of Java distribution
|
| 39786 |
urbaneks |
80 |
JAVA_LIBS flags needed for linking against Java libraries
|
| 41169 |
urbaneks |
81 |
JAVA_CPPFLAGS C preprocessor flags needed for compiling JNI programs
|
| 29123 |
ripley |
82 |
LAPACK_LIBS flags needed for linking against external LAPACK libraries
|
| 40913 |
ripley |
83 |
LIBnn location for libraries, e.g. 'lib' or 'lib64' on this platform
|
| 29123 |
ripley |
84 |
LDFLAGS linker flags, e.g. -L<dir> if you have libraries in a
|
| 46994 |
ripley |
85 |
nonstandard directory <dir>
|
| 39786 |
urbaneks |
86 |
OBJC Objective C compiler command
|
|
|
87 |
OBJCFLAGS Objective C compiler flags
|
| 29123 |
ripley |
88 |
MAKE Make command
|
| 36862 |
ripley |
89 |
SAFE_FFLAGS Safe (as conformant as possible) Fortran 77 compiler flags
|
| 47780 |
ripley |
90 |
SHLIB_CFLAGS additional CFLAGS used when building shared objects
|
|
|
91 |
SHLIB_CXXLD command for linking shared objects which contain
|
| 46994 |
ripley |
92 |
object files from a C++ compiler
|
| 29123 |
ripley |
93 |
SHLIB_CXXLDFLAGS
|
| 46994 |
ripley |
94 |
special flags used by SHLIB_CXXLD
|
| 47836 |
ripley |
95 |
SHLIB_EXT file extension (including '.') for shared objects
|
| 47780 |
ripley |
96 |
SHLIB_FFLAGS additional FFLAGS used when building shared objects
|
|
|
97 |
SHLIB_LD command for linking shared objects which contain
|
| 46994 |
ripley |
98 |
object files from a C or Fortran compiler only
|
| 29123 |
ripley |
99 |
SHLIB_LDFLAGS
|
| 46994 |
ripley |
100 |
special flags used by SHLIB_LD
|
| 45267 |
ripley |
101 |
SHLIB_FCLD, SHLIB_FCLDFLAGS
|
| 46994 |
ripley |
102 |
ditto when using Fortran 9x
|
| 29123 |
ripley |
103 |
TCLTK_CPPFLAGS
|
| 46994 |
ripley |
104 |
flags needed for finding the tcl.h and tk.h headers
|
| 29123 |
ripley |
105 |
TCLTK_LIBS flags needed for linking against the Tcl and Tk libraries
|
| 19165 |
hornik |
106 |
|
| 58676 |
ripley |
107 |
Report bugs at bugs.r-project.org ."
|
| 19165 |
hornik |
108 |
|
|
|
109 |
## <NOTE>
|
|
|
110 |
## The variables are basically the precious configure variables (with
|
|
|
111 |
## the R_* and MAIN_* ones removed), plus FLIBS and BLAS_LIBS.
|
|
|
112 |
## One could use
|
|
|
113 |
## precious_configure_vars=`~/src/R/configure --help \
|
|
|
114 |
## | sed -n '/^Some influential/,/^[^ ]/p' \
|
|
|
115 |
## | sed '/^[^ ]/d' \
|
|
|
116 |
## | sed 's/^ //' \
|
|
|
117 |
## | cut -f1 -d ' ' \
|
| 29123 |
ripley |
118 |
## | grep -v '^MAIN_' \
|
|
|
119 |
## | grep -v '^R_' \
|
| 19165 |
hornik |
120 |
## | sort \
|
|
|
121 |
## | uniq`
|
|
|
122 |
## to obtain the configure vars and hence create most of the above usage
|
| 29123 |
ripley |
123 |
## info as well as the list of accepted variables below automatically.
|
|
|
124 |
## </NOTE>
|
| 19165 |
hornik |
125 |
|
| 29123 |
ripley |
126 |
if test $# = 0; then
|
|
|
127 |
echo "${usage}"
|
|
|
128 |
exit 1
|
|
|
129 |
fi
|
|
|
130 |
|
| 45260 |
ripley |
131 |
if test "${R_OSTYPE}" = "windows"; then
|
|
|
132 |
MAKE=make
|
|
|
133 |
R_DOC_DIR=${R_HOME}/doc
|
|
|
134 |
R_INCLUDE_DIR=${R_HOME}/include
|
|
|
135 |
R_SHARE_DIR=${R_HOME}/share
|
|
|
136 |
fi
|
|
|
137 |
|
| 37310 |
ripley |
138 |
makefiles="-f ${R_HOME}/etc${R_ARCH}/Makeconf -f ${R_SHARE_DIR}/make/config.mk"
|
| 46881 |
ripley |
139 |
## avoid passing down -jN
|
| 47769 |
ripley |
140 |
MAKEFLAGS=
|
|
|
141 |
export MAKEFLAGS
|
| 23685 |
hornik |
142 |
query="${MAKE} -s ${makefiles} print R_HOME=${R_HOME}"
|
| 19165 |
hornik |
143 |
|
|
|
144 |
LIBR=`eval $query VAR=LIBR`
|
| 43352 |
ripley |
145 |
STATIC_LIBR=`eval $query VAR=STATIC_LIBR`
|
| 63217 |
ripley |
146 |
MAIN_LDFLAGS=`eval $query VAR=MAIN_LDFLAGS`
|
|
|
147 |
LIBS=`eval $query VAR=LIBS`
|
| 19165 |
hornik |
148 |
|
| 63217 |
ripley |
149 |
|
| 45260 |
ripley |
150 |
if test -n "${R_ARCH}"; then
|
|
|
151 |
includes="-I${R_INCLUDE_DIR} -I${R_INCLUDE_DIR}${R_ARCH}"
|
|
|
152 |
else
|
|
|
153 |
includes="-I${R_INCLUDE_DIR}"
|
|
|
154 |
fi
|
|
|
155 |
|
| 19165 |
hornik |
156 |
var=
|
| 62501 |
ripley |
157 |
personal="yes"
|
| 62515 |
ripley |
158 |
site="yes"
|
| 19165 |
hornik |
159 |
while test -n "${1}"; do
|
|
|
160 |
case "${1}" in
|
|
|
161 |
-h|--help)
|
|
|
162 |
echo "${usage}"; exit 0 ;;
|
|
|
163 |
-v|--version)
|
|
|
164 |
echo "${version}"; exit 0 ;;
|
|
|
165 |
--cppflags)
|
|
|
166 |
if test -z "${LIBR}"; then
|
| 46994 |
ripley |
167 |
if test -z "${STATIC_LIBR}"; then
|
|
|
168 |
echo "R was not built as a library" >&2
|
| 43352 |
ripley |
169 |
else
|
| 46994 |
ripley |
170 |
echo "${includes}"
|
|
|
171 |
fi
|
| 19165 |
hornik |
172 |
else
|
| 46994 |
ripley |
173 |
echo "${includes}"
|
| 19165 |
hornik |
174 |
fi
|
|
|
175 |
exit 0
|
|
|
176 |
;;
|
|
|
177 |
--ldflags)
|
| 63217 |
ripley |
178 |
## changed in R 3.1.0 to be those needed to link a front-end
|
| 19165 |
hornik |
179 |
if test -z "${LIBR}"; then
|
| 46994 |
ripley |
180 |
if test -z "${STATIC_LIBR}"; then
|
|
|
181 |
echo "R was not built as a library" >&2
|
| 43352 |
ripley |
182 |
else
|
| 63217 |
ripley |
183 |
echo "${MAIN_LDFLAGS} ${LDFLAGS} ${STATIC_LIBR}"
|
| 46994 |
ripley |
184 |
fi
|
| 19165 |
hornik |
185 |
else
|
| 63217 |
ripley |
186 |
echo "${MAIN_LDFLAGS} ${LDFLAGS} ${LIBR} ${LIBS}"
|
| 19165 |
hornik |
187 |
fi
|
|
|
188 |
exit 0
|
|
|
189 |
;;
|
| 62515 |
ripley |
190 |
--no-user-files)
|
| 62501 |
ripley |
191 |
personal="no"
|
|
|
192 |
;;
|
| 62515 |
ripley |
193 |
--no-site-files)
|
|
|
194 |
site="no"
|
|
|
195 |
;;
|
| 19165 |
hornik |
196 |
*)
|
|
|
197 |
if test -z "${var}"; then
|
| 46994 |
ripley |
198 |
var="${1}"
|
| 19165 |
hornik |
199 |
else
|
| 46994 |
ripley |
200 |
echo "ERROR: cannot query more than one variable" >&2
|
|
|
201 |
exit 1
|
| 19165 |
hornik |
202 |
fi
|
|
|
203 |
;;
|
|
|
204 |
esac
|
|
|
205 |
shift
|
|
|
206 |
done
|
|
|
207 |
|
| 62515 |
ripley |
208 |
if test "${site}" = "yes"; then
|
| 62605 |
ripley |
209 |
: ${R_MAKEVARS_SITE="${R_HOME}/etc${R_ARCH}/Makevars.site"}
|
|
|
210 |
if test -f "${R_MAKEVARS_SITE}"; then
|
|
|
211 |
makefiles="${makefiles} -f ${R_MAKEVARS_SITE}"
|
| 62515 |
ripley |
212 |
fi
|
|
|
213 |
fi
|
| 62501 |
ripley |
214 |
if test "${personal}" = "yes"; then
|
|
|
215 |
if test "${R_OSTYPE}" = "windows"; then
|
| 62605 |
ripley |
216 |
if test -n "${R_MAKEVARS_USER}"; then
|
|
|
217 |
makefiles="${makefiles} -f ${R_MAKEVARS_USER}"
|
|
|
218 |
elif test ${R_ARCH} = "/x64" -a -f "${HOME}/.R/Makevars.win64"; then
|
| 62501 |
ripley |
219 |
makefiles="${makefiles} -f ${HOME}/.R/Makevars.win64"
|
|
|
220 |
elif test -f "${HOME}/.R/Makevars.win"; then
|
|
|
221 |
makefiles="${makefiles} -f ${HOME}/.R/Makevars.win"
|
|
|
222 |
elif test -f "${HOME}/.R/Makevars"; then
|
|
|
223 |
makefiles="${makefiles} -f ${HOME}/.R/Makevars"
|
|
|
224 |
fi
|
|
|
225 |
else
|
| 62758 |
ripley |
226 |
. ${R_HOME}/etc${R_ARCH}/Renviron
|
| 62605 |
ripley |
227 |
if test -n "${R_MAKEVARS_USER}"; then
|
|
|
228 |
makefiles="${makefiles} -f ${R_MAKEVARS_USER}"
|
|
|
229 |
elif test -f "${HOME}/.R/Makevars-${R_PLATFORM}"; then
|
| 62501 |
ripley |
230 |
makefiles="${makefiles} -f ${HOME}/.R/Makevars-${R_PLATFORM}"
|
|
|
231 |
elif test -f "${HOME}/.R/Makevars"; then
|
|
|
232 |
makefiles="${makefiles} -f ${HOME}/.R/Makevars"
|
|
|
233 |
fi
|
|
|
234 |
fi
|
|
|
235 |
fi
|
| 62515 |
ripley |
236 |
query="${MAKE} -s ${makefiles} print R_HOME=${R_HOME}"
|
| 62501 |
ripley |
237 |
|
| 19165 |
hornik |
238 |
ok_c_vars="CC CFLAGS CPICFLAGS CPP CPPFLAGS"
|
|
|
239 |
ok_cxx_vars="CXX CXXCPP CXXFLAGS CXXPICFLAGS"
|
| 47780 |
ripley |
240 |
ok_dylib_vars="DYLIB_EXT DYLIB_LD DYLIB_LDFLAGS"
|
| 39786 |
urbaneks |
241 |
ok_objc_vars="OBJC OBJCFLAGS"
|
| 41169 |
urbaneks |
242 |
ok_java_vars="JAVA JAVAC JAVAH JAR JAVA_HOME JAVA_LIBS JAVA_CPPFLAGS"
|
| 45267 |
ripley |
243 |
ok_f77_vars="F77 FFLAGS FPICFLAGS FLIBS SAFE_FFLAGS FC FCFLAGS FCPICFLAGS"
|
| 19165 |
hornik |
244 |
ok_ld_vars="LDFLAGS"
|
| 47780 |
ripley |
245 |
ok_shlib_vars="SHLIB_CFLAGS SHLIB_CXXLD SHLIB_CXXLDFLAGS SHLIB_EXT SHLIB_FFLAGS SHLIB_LD SHLIB_LDFLAGS SHLIB_FCLD SHLIB_FCLDFLAGS"
|
| 19165 |
hornik |
246 |
ok_tcltk_vars="TCLTK_CPPFLAGS TCLTK_LIBS"
|
| 62841 |
ripley |
247 |
ok_other_vars="BLAS_LIBS LAPACK_LIBS MAKE LIBnn LOCAL_SOFT"
|
| 19165 |
hornik |
248 |
|
|
|
249 |
## Can we do this elegantly using case?
|
|
|
250 |
|
|
|
251 |
var_ok=no
|
| 29123 |
ripley |
252 |
for v in ${ok_c_vars} ${ok_cxx_vars} ${ok_dylib_vars} ${ok_f77_vars} \
|
| 46994 |
ripley |
253 |
${ok_objc_vars} ${ok_java_vars} \
|
|
|
254 |
${ok_ld_vars} ${ok_shlib_vars} ${ok_tcltk_vars} \
|
| 29123 |
ripley |
255 |
${ok_other_vars}; do
|
| 19165 |
hornik |
256 |
if test "${var}" = "${v}"; then
|
|
|
257 |
var_ok=yes
|
|
|
258 |
break
|
|
|
259 |
fi
|
|
|
260 |
done
|
|
|
261 |
|
|
|
262 |
if test "${var_ok}" = yes; then
|
|
|
263 |
eval "${query} VAR=${var}"
|
|
|
264 |
else
|
|
|
265 |
echo "ERROR: no information for variable '${var}'"
|
|
|
266 |
exit 1
|
|
|
267 |
fi
|
|
|
268 |
|
|
|
269 |
### Local Variables: ***
|
|
|
270 |
### mode: sh ***
|
|
|
271 |
### sh-indentation: 2 ***
|
|
|
272 |
### End: ***
|