Rev 81322 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
## config -- Simple shell script to get the values of basic R configure## variables, or the header and library flags necessary for linking## against R.#### Usage:## R CMD config [options] [VAR]## Copyright (C) 2002-2020 The R Core Team#### This document is free software; you can redistribute it and/or modify## it under the terms of the GNU General Public License as published by## the Free Software Foundation; either version 2, or (at your option)## any later version.#### This program is distributed in the hope that it will be useful, but## WITHOUT ANY WARRANTY; without even the implied warranty of## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU## General Public License for more details.#### A copy of the GNU General Public License is available at## https://www.R-project.org/Licenses/revision='$Revision: 81337 $'version=`set - ${revision}; echo ${2}`version="R configuration information retrieval script: ${R_VERSION} (r${version})Copyright (C) 2002-2020 The R Core Team.This is free software; see the GNU General Public License version 2or later for copying conditions. There is NO warranty."usage="Usage: R CMD config [options] [VAR]Get the value of a basic R configure variable VAR which must be amongthose listed in the 'Variables' section below, or the header andlibrary flags necessary for linking a front-end against R.Options:-h, --help print short help message and exit-v, --version print version info and exit--cppflags print pre-processor flags required to compile aC/C++ file as part of a front-end using R as a library--ldflags print linker flags needed for linking a front-endagainst the R library--no-user-files ignore customization files under ~/.R--no-site-files ignore site customization files under R_HOME/etc--all print names and values of all variables belowVariables:AR command to make static librariesBLAS_LIBS flags needed for linking against external BLAS librariesCC C compiler commandCFLAGS C compiler flagsCPICFLAGS special flags for compiling C code to be included in ashared libraryCPPFLAGS C/C++ preprocessor flags, e.g. -I<dir> if you haveheaders in a nonstandard directory <dir>CXX default compiler command for C++ codeCXXFLAGS compiler flags for CXXCXXPICFLAGS special flags for compiling C++ code to be included in ashared libraryCXX11 compiler command for C++11 codeCXX11STD flag used with CXX11 to enable C++11 supportCXX11FLAGS further compiler flags for CXX11CXX11PICFLAGSspecial flags for compiling C++11 code to be included ina shared libraryCXX14 compiler command for C++14 codeCXX14STD flag used with CXX14 to enable C++14 supportCXX14FLAGS further compiler flags for CXX14CXX14PICFLAGSspecial flags for compiling C++14 code to be included ina shared libraryCXX17 compiler command for C++17 codeCXX17STD flag used with CXX17 to enable C++17 supportCXX17FLAGS further compiler flags for CXX17CXX17PICFLAGSspecial flags for compiling C++17 code to be included ina shared libraryCXX20 compiler command for C++20 codeCXX20STD flag used with CXX20 to enable C++20 supportCXX20FLAGS further compiler flags for CXX20CXX20PICFLAGSspecial flags for compiling C++20 code to be included ina shared libraryDYLIB_EXT file extension (including '.') for dynamic librariesDYLIB_LD command for linking dynamic libraries which containobject files from a C or Fortran compiler onlyDYLIB_LDFLAGSspecial flags used by DYLIB_LDFC Fortran compiler commandFFLAGS fixed-form Fortran compiler flagsFCFLAGS free-form Fortran 9x compiler flagsFLIBS linker flags needed to link Fortran codeFPICFLAGS special flags for compiling Fortran code to be turnedinto a shared libraryJAR Java archive tool commandJAVA Java interpreter commandJAVAC Java compiler commandJAVAH Java header and stub generator commandJAVA_HOME path to the home of Java distributionJAVA_LIBS flags needed for linking against Java librariesJAVA_CPPFLAGS C preprocessor flags needed for compiling JNI programsLAPACK_LIBS flags needed for linking against external LAPACK librariesLIBnn location for libraries, e.g. 'lib' or 'lib64' on this platformLDFLAGS linker flags, e.g. -L<dir> if you have libraries in anonstandard directory <dir>LTO LTO_FC LTO_LD flags for Link-Time OptimizationMAKE Make commandNM comand to display symbol tablesOBJC Objective C compiler commandOBJCFLAGS Objective C compiler flagsRANLIB command to index static librariesSAFE_FFLAGS Safe (as conformant as possible) Fortran compiler flagsSHLIB_CFLAGS additional CFLAGS used when building shared objectsSHLIB_CXXFLAGSadditional CXXFLAGS used when building shared objectsSHLIB_CXXLD command for linking shared objects which containobject files from a C++ compiler (and CXX11 CXX14 CXX17 CXX20)SHLIB_CXXLDFLAGSspecial flags used by SHLIB_CXXLD (and CXX11 CXX14 CXX17 CXX20)SHLIB_EXT file extension (including '.') for shared objectsSHLIB_FFLAGS additional FFLAGS used when building shared objectsSHLIB_LD command for linking shared objects which containobject files from a C or Fortran compiler onlySHLIB_LDFLAGSspecial flags used by SHLIB_LDTCLTK_CPPFLAGSflags needed for finding the tcl.h and tk.h headersTCLTK_LIBS flags needed for linking against the Tcl and Tk libraries"if test "${R_OSTYPE}" = "windows"; thenusage="${usage}Windows only:COMPILED_BY name and version of compiler used to build RLOCAL_SOFT absolute path to '/usr/local' software collectionOBJDUMP command to dump objects"fiusage="${usage}Report bugs at <https://bugs.R-project.org>."## <NOTE>## The variables are basically the precious configure variables (with## the R_* and MAIN_* ones removed), plus FLIBS and BLAS_LIBS.## One could use## precious_configure_vars=`~/src/R/configure --help \## | sed -n '/^Some influential/,/^[^ ]/p' \## | sed '/^[^ ]/d' \## | sed 's/^ //' \## | cut -f1 -d ' ' \## | grep -v '^MAIN_' \## | grep -v '^R_' \## | sort \## | uniq`## to obtain the configure vars and hence create most of the above usage## info as well as the list of accepted variables below automatically.## </NOTE>if test $# = 0; thenecho "${usage}"exit 1fiif test "${R_OSTYPE}" = "windows"; thenMAKE=makeR_DOC_DIR=${R_HOME}/docR_INCLUDE_DIR=${R_HOME}/includeR_SHARE_DIR=${R_HOME}/sharefimakefiles="-f ${R_HOME}/etc${R_ARCH}/Makeconf -f ${R_SHARE_DIR}/make/config.mk"## avoid passing down -jNMAKEFLAGS=export MAKEFLAGSquery="${MAKE} -s ${makefiles} print R_HOME=${R_HOME}"LIBR=`eval $query VAR=LIBR`STATIC_LIBR=`eval $query VAR=STATIC_LIBR`MAIN_LDFLAGS=`eval $query VAR=MAIN_LDFLAGS`LIBS=`eval $query VAR=LIBS`LDFLAGS=`eval $query VAR=LDFLAGS`if test -n "${R_ARCH}"; thenincludes="-I${R_INCLUDE_DIR} -I${R_INCLUDE_DIR}${R_ARCH}"elseincludes="-I${R_INCLUDE_DIR}"fivar=personal="yes"site="yes"all="no"while test -n "${1}"; docase "${1}" in-h|--help)echo "${usage}"; exit 0 ;;-v|--version)echo "${version}"; exit 0 ;;--cppflags)if test -z "${LIBR}"; thenif test -z "${STATIC_LIBR}"; thenecho "R was not built as a library" >&2elseecho "${includes}"fielseecho "${includes}"fiexit 0;;--ldflags)## changed in R 3.1.0 to be those needed to link a front-endif test -z "${LIBR}"; thenif test -z "${STATIC_LIBR}"; thenecho "R was not built as a library" >&2elseecho "${MAIN_LDFLAGS} ${LDFLAGS} ${STATIC_LIBR}"fielseecho "${MAIN_LDFLAGS} ${LDFLAGS} ${LIBR} ${LIBS}"fiexit 0;;--no-user-files)personal="no";;--no-site-files)site="no";;--all)all="yes";;*)if test -z "${var}"; thenvar="${1}"elseecho "ERROR: cannot query more than one variable" >&2exit 1fi;;esacshiftdone## quotes added in R 3.3.2if test "${site}" = "yes"; then: ${R_MAKEVARS_SITE="${R_HOME}/etc${R_ARCH}/Makevars.site"}if test -f "${R_MAKEVARS_SITE}"; thenmakefiles="${makefiles} -f \"${R_MAKEVARS_SITE}\""fifiif test "${personal}" = "yes"; thenif test "${R_OSTYPE}" = "windows"; thenif test -f "${R_MAKEVARS_USER}"; thenmakefiles="${makefiles} -f \"${R_MAKEVARS_USER}\""elif test ${R_ARCH} = "/x64" && test -f "${HOME}/.R/Makevars.ucrt"; thenmakefiles="${makefiles} -f \"${HOME}\"/.R/Makevars.ucrt"elif test ${R_ARCH} = "/x64" && test -f "${HOME}/.R/Makevars.win64"; thenmakefiles="${makefiles} -f \"${HOME}\"/.R/Makevars.win64"elif test -f "${HOME}/.R/Makevars.win"; thenmakefiles="${makefiles} -f \"${HOME}\"/.R/Makevars.win"elif test -f "${HOME}/.R/Makevars"; thenmakefiles="${makefiles} -f \"${HOME}\"/.R/Makevars"fielse. ${R_HOME}/etc${R_ARCH}/Renvironif test -f "${R_MAKEVARS_USER}"; thenmakefiles="${makefiles} -f \"${R_MAKEVARS_USER}\""elif test -f "${HOME}/.R/Makevars-${R_PLATFORM}"; thenmakefiles="${makefiles} -f \"${HOME}\"/.R/Makevars-${R_PLATFORM}"elif test -f "${HOME}/.R/Makevars"; thenmakefiles="${makefiles} -f \"${HOME}\"/.R/Makevars"fififiquery="${MAKE} -s ${makefiles} print R_HOME=${R_HOME}"ok_c_vars="CC CFLAGS CPICFLAGS CPPFLAGS"ok_cxx_vars="CXX CXXFLAGS CXXPICFLAGS CXX11 CXX11STD CXX11FLAGS CXX11PICFLAGS CXX14 CXX14STD CXX14FLAGS CXX14PICFLAGS CXX17 CXX17STD CXX17FLAGS CXX17PICFLAGS CXX20 CXX20STD CXX20FLAGS CXX20PICFLAGS"ok_dylib_vars="DYLIB_EXT DYLIB_LD DYLIB_LDFLAGS"ok_objc_vars="OBJC OBJCFLAGS"ok_java_vars="JAVA JAVAC JAVAH JAR JAVA_HOME JAVA_LIBS JAVA_CPPFLAGS"ok_ftn_vars="FC FFLAGS FPICFLAGS FLIBS FCFLAGS SAFE_FFLAGS"ok_ld_vars="LDFLAGS"ok_shlib_vars="SHLIB_CFLAGS SHLIB_CXXFLAGS SHLIB_CXXLD SHLIB_CXXLDFLAGS SHLIB_CXX11LD SHLIB_CXX11LDFLAGS SHLIB_CXX14LD SHLIB_CXX14LDFLAGS SHLIB_CXX17LD SHLIB_CXX17LDFLAGS SHLIB_CXX20LD SHLIB_CXX20LDFLAGS SHLIB_EXT SHLIB_FFLAGS SHLIB_LD SHLIB_LDFLAGS"ok_tcltk_vars="TCLTK_CPPFLAGS TCLTK_LIBS"ok_other_vars="BLAS_LIBS LAPACK_LIBS MAKE LIBnn AR NM RANLIB LTO LTO_FC LTO_LD"defunct_vars="CPP CXXCPP"if test "${R_OSTYPE}" = "windows"; thenok_win_vars="LOCAL_SOFT COMPILED_BY OBJDUMP"fiif test "${all}" = "yes"; thenquery="${MAKE} -s ${makefiles} print-name-and-value R_HOME=${R_HOME}"for v in ${ok_c_vars} ${ok_cxx_vars} ${ok_dylib_vars} ${ok_ftn_vars} \${ok_objc_vars} ${ok_java_vars} \${ok_ld_vars} ${ok_shlib_vars} ${ok_tcltk_vars} \${ok_other_vars} ${ok_win_vars}; doeval "${query} VAR=${v}"doneechoecho "## The following variables are defunct"echo ${defunct_vars}exit 0fi## Can we do this elegantly using case?var_ok=nofor v in ${ok_c_vars} ${ok_cxx_vars} ${ok_dylib_vars} ${ok_ftn_vars} \${ok_objc_vars} ${ok_java_vars} \${ok_ld_vars} ${ok_shlib_vars} ${ok_tcltk_vars} \${ok_other_vars} ${ok_win_vars}; doif test "${var}" = "${v}"; thenvar_ok=yesbreakfidonefor v in ${defunct_vars}; doif test "${var}" = "${v}"; thenvar_ok=yes1>&2 echo "'config' variable '${v}' is defunct"exit 2fidoneif test "${var_ok}" = yes; theneval "${query} VAR=${var}"elseecho "ERROR: no information for variable '${var}'"exit 1fi### Local Variables: ***### mode: sh ***### sh-indentation: 2 ***### End: ***