Rev 44548 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
### clibs.m4 -- extra macros for configuring R -*- Autoconf -*-###### Copyright (C) 2004 R Core Team###### This file is part of R.###### R 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 of the License, or (at your### option) any later version.###### R 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.###### You should have received a copy of the GNU General Public License### along with R; if not, you can obtain it via the World Wide Web at### along with R; if not, a copy is available at### https://www.r-project.org/Licenses/## modified version of AC_F77_LIBRARY_LDFLAGS for C libraries# _R_PROG_C_V_OUTPUT([FLAG = $r_cv_prog_c_v])# -------------------------------------------------# Link a trivial Fortran program, compiling with a verbose output FLAG# (whose default value, $r_cv_prog_c_v, is computed by# _R_PROG_C_V), and return the output in $r_c_v_output. This# output is processed in the way expected by _AC_FC_LIBRARY_LDFLAGS,# so that any link flags that are echoed by the compiler appear as# space-separated items.AC_DEFUN([_R_PROG_C_V_OUTPUT],[AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])# Compile and link our simple test program by passing a flag (argument# 1 to this macro) to the Fortran compiler in order to get# "verbose" output that we can then parse for the Fortran linker# flags.r_save_CFLAGS=$CFLAGSCFLAGS="$CFLAGS m4_default([$1], [$r_cv_prog_c_v])"(eval echo $as_me:__oline__: \"$ac_link\") >&AS_MESSAGE_LOG_FDr_c_v_output=`eval $ac_link AS_MESSAGE_LOG_FD>&1 2>&1 | grep -v 'Driving:'`echo "$r_c_v_output" >&AS_MESSAGE_LOG_FDCFLAGS=$r_save_CFLAGSrm -rf conftest*# On HP/UX there is a line like: "LPATH is: /foo:/bar:/baz" where# /foo, /bar, and /baz are search directories for the Fortran linker.# Here, we change these into -L/foo -L/bar -L/baz (and put it first):r_c_v_output="`echo $r_c_v_output |grep 'LPATH is:' |sed 's,.*LPATH is\(: *[[^ ]]*\).*,\1,;s,: */, -L/,g'` $r_c_v_output"case $r_c_v_output in# If we are using xlc then replace all the commas with spaces.*xlcentry*)r_c_v_output=`echo $r_c_v_output | sed 's/,/ /g'` ;;# With Intel ifc, ignore the quoted -mGLOB_options_string stuff (quoted# $LIBS confuse us, and the libraries appear later in the output anyway).*mGLOB_options_string*)r_c_v_output=`echo $r_c_v_output | sed 's/\"-mGLOB[[^\"]]*\"/ /g'` ;;esac])# _R_PROG_C_V_OUTPUT# _R_PROG_C_V# --------------## Determine the flag that causes the Fortran compiler to print# information of library and object files (normally -v)# Needed for _AC_FC_LIBRARY_FLAGS# Some compilers don't accept -v (Lahey: -verbose, xlf: -V, Fujitsu: -###)AC_DEFUN([_R_PROG_C_V],[AC_CACHE_CHECK([how to get verbose linking output from ${CC}],[r_cv_prog_c_v],[AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],[r_cv_prog_c_v=# Try some options frequently used verbose outputfor r_verb in -v -verbose --verbose -V -\#\#\#; do_R_PROG_C_V_OUTPUT($r_verb)# look for -l* and *.a constructs in the outputfor r_arg in $r_c_v_output; docase $r_arg in[[\\/]]*.a | ?:[[\\/]]*.a | -[[lLRu]]*)r_cv_prog_c_v=$r_verbbreak 2 ;;esacdonedoneif test -z "$r_cv_prog_c_v"; thenAC_MSG_WARN([cannot determine how to obtain linking information from ${CC}])fi],[AC_MSG_WARN([compilation failed])])])])# _R_PROG_C_V# _R_C_LIBRARY_LDFLAGS# ----------------------## Determine the linker flags (e.g. "-L" and "-l") for the C# intrinsic and run-time libraries that are required to successfully# link a C program or shared library. The output variable# CLIBS is set to these flags.## This macro is intended to be used in those situations when it is# necessary to mix, e.g. C++ and Fortran, source code into a single# program or shared library.## For example, if object files from a C++ and Fortran compiler must# be linked together, then the C++ compiler/linker must be used for# linking (since special C++-ish things need to happen at link time# like calling global constructors, instantiating templates, enabling# exception support, etc.).## This macro was packaged in its current form by Matthew D. Langston.# However, nearly all of this macro came from the "OCTAVE_FLIBS" macro# in "octave-2.0.13/aclocal.m4", and full credit should go to John# W. Eaton for writing this extremely useful macro. Thank you John.AC_DEFUN([_R_C_LIBRARY_LDFLAGS],[_R_PROG_C_VAC_CACHE_CHECK([for C libraries of ${CC}], r_cv_c_libs,[if test "x$CLIBS" != "x"; thenr_cv_c_libs="$CLIBS" # Let the user override the test.else_R_PROG_C_V_OUTPUTr_cv_c_libs=# Save positional arguments (if any)r_save_positional="$[@]"set X $r_c_v_outputwhile test $[@%:@] != 1; doshiftr_arg=$[1]case $r_arg in[[\\/]]*.a | ?:[[\\/]]*.a)_AC_LIST_MEMBER_IF($r_arg, $r_cv_c_libs, ,r_cv_c_libs="$r_cv_c_libs $r_arg");;-bI:*)_AC_LIST_MEMBER_IF($r_arg, $r_cv_c_libs, ,[_AC_LINKER_OPTION([$r_arg], r_cv_c_libs)]);;# Ignore these flags.-lang* | -lcrt[[01]].o | -lcrtbegin.o | -lc | -lgcc | -libmil | -LANG:=*);;-lkernel32)test x"$CYGWIN" != xyes && r_cv_c_libs="$r_cv_c_libs $r_arg";;-[[LRuY]])# These flags, when seen by themselves, take an argument.# We remove the space between option and argument and re-iterate# unless we find an empty arg or a new option (starting with -)case $[2] in"" | -*);;*)r_arg="$r_arg$[2]"shift; shiftset X $r_arg "$[@]";;esac;;-YP,*)for r_j in `echo $r_arg | sed -e 's/-YP,/-L/;s/:/ -L/g'`; do_AC_LIST_MEMBER_IF($r_j, $r_cv_c_libs, ,[r_arg="$r_arg $r_j"r_cv_c_libs="$r_cv_c_libs $r_j"])done;;-[[lLR]]*)_AC_LIST_MEMBER_IF($r_arg, $r_cv_c_libs, ,r_cv_c_libs="$r_cv_c_libs $r_arg");;# Ignore everything else.esacdone# restore positional argumentsset X $r_save_positional; shift# We only consider "LD_RUN_PATH" on Solaris systems. If this is seen,# then we insist that the "run path" must be an absolute path (i.e. it# must begin with a "/").case `(uname -sr) 2>/dev/null` in"SunOS 5"*)r_ld_run_path=`echo $r_c_v_output |sed -n 's,^.*LD_RUN_PATH *= *\(/[[^ ]]*\).*$,-R\1,p'`test "x$r_ld_run_path" != x &&_AC_LINKER_OPTION([$r_ld_run_path], r_cv_c_libs);;esacfi # test "x$CLIBS" = "x"])CLIBS=for arg in $r_cv_c_libs; docase "${arg}" in-L*)CLIBS="${CLIBS} $arg";;esacdone])# _R_C_LIBRARY_LDFLAGS# R_C_LIBRARY_LDFLAGS# -------------------AC_DEFUN([R_C_LIBRARY_LDFLAGS],[AC_REQUIRE([AC_PROG_CC])dnlAC_LANG_PUSH(C)dnl_R_C_LIBRARY_LDFLAGSAC_LANG_POP(C)dnl])# R_C_LIBRARY_LDFLAGS