1### R.m4 -- extra macros for configuring R -*- Autoconf -*- 2### 3### Copyright (C) 1998-2005 R Core Team 4### 5### This file is part of R. 6### 7### R is free software; you can redistribute it and/or modify it under 8### the terms of the GNU General Public License as published by the Free 9### Software Foundation; either version 2 of the License, or (at your 10### option) any later version. 11### 12### R is distributed in the hope that it will be useful, but WITHOUT ANY 13### WARRANTY; without even the implied warranty of MERCHANTABILITY or 14### FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 15### License for more details. 16### 17### You should have received a copy of the GNU General Public License 18### along with R; if not, you can obtain it via the World Wide Web at 19### `http://www.gnu.org/copyleft/gpl.html', or by writing to the Free 20### Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 21### 02110-1301, USA. 22 23### * General support macros 24 25## R_ARG_USE 26## --------- 27AC_DEFUN([R_ARG_USE], 28[if test "${withval}" = no; then 29 use_$1=no 30else 31 use_$1=yes 32fi 33])# R_ARG_USE 34 35## R_ARG_USE_SYSTEM 36## ---------------- 37AC_DEFUN([R_ARG_USE_SYSTEM], 38[if test "${withval}" = no; then 39 use_system_$1=no 40else 41 use_system_$1=yes 42fi 43])# R_ARG_USE_SYSTEM 44 45## R_SH_VAR_ADD(VARIABLE, VALUE, [SEPARATOR = " "]) 46## ------------------------------------------------ 47## Set sh variable VARIABLE to VALUE if empty (or undefined), or append 48## VALUE to the value of VARIABLE, separated by SEPARATOR. 49## Currently, safe only if all arguments are literals. 50## Useful mostly when we do not know whether VARIABLE is empty or not. 51## Should maybe also have a fourth argument to control whether adding 52## happens by appending (default) or prepending ... 53AC_DEFUN([R_SH_VAR_ADD], 54[separator="$3" 55test -z "${separator}" && separator=" " 56if test -z "${[$1]}"; then 57 $1="$2" 58else 59 $1="${[$1]}${separator}$2" 60fi])# R_SH_VAR_ADD 61 62## R_MISSING_PROG(NAME, PROGRAM) 63## ----------------------------- 64## Simplified variant of AM_MISSING_PROG. 65## Set NAME to PROGRAM if this is found and works (in the sense of 66## properly implementing --version, or to an appropriate invocation 67## if the missing script otherwise. 68AC_DEFUN([R_MISSING_PROG], 69[AC_MSG_CHECKING([for working $2]) 70if ($2 --version) < /dev/null > /dev/null 2>&1; then 71 $1=$2 72 AC_MSG_RESULT([found]) 73else 74 $1="\$(SHELL) \$(top_srcdir)/tools/missing $2" 75 AC_MSG_RESULT([missing]) 76fi 77AC_SUBST($1) 78])# R_MISSING_PROG 79 80 81### * Programs 82 83## R_PROG_AR 84## --------- 85AC_DEFUN([R_PROG_AR], 86[AC_CHECK_PROGS(AR, [${AR} ar]) 87: ${ARFLAGS="rc"} 88AC_SUBST(ARFLAGS) 89])# R_PROG_AR 90 91## R_PROG_INSTALL 92## -------------- 93## Find a good install program. 94## We like to provide INSTALL in the top-level Makeconf. 95## Hence, if AC_PROG_INSTALL ends up with the 'tools/install-sh' script, 96## we need to ensure a relative path (i.e., in case we build in srcdir) 97## gets prefixed by top_srcdir. (This would not be necessary if we had 98## '@INSTALL@' in each Makefile.in, but we prefer to share ...) 99AC_DEFUN([R_PROG_INSTALL], 100[AC_REQUIRE([AC_PROG_INSTALL]) 101case "${INSTALL}" in 102 [[\\/]]* | ?:[[\\/]]* ) # absolute 103 ;; 104 *) 105 INSTALL="\$\(top_srcdir\)/tools/install-sh -c" 106 ;; 107esac 108case "${host_os}" in 109 hpux*) 110 ## On some versions of HP-UX (seen on both 10.20 and 11.0) we end up 111 ## a broken install (seen in /opt/imake/bin) which has the default 112 ## permissions wrong (PR#2091). Let's just always use install-sh on 113 ## HP-UX. 114 INSTALL="\$\(top_srcdir\)/tools/install-sh -c" 115 ;; 116esac 117])# R_PROG_INSTALL 118 119## R_PROG_PAGER 120## ------------ 121AC_DEFUN([R_PROG_PAGER], 122[AC_PATH_PROGS(PAGER, [${PAGER} less more page pg], false) 123if test "${PAGER}" = false; then 124 warn_pager="I could not determine a pager" 125 AC_MSG_WARN([${warn_pager}]) 126fi 127])# R_PROG_PAGER 128 129## R_PROG_PERL 130## ----------- 131AC_DEFUN([R_PROG_PERL], 132[AC_PATH_PROGS(PERL, [${PERL} perl]) 133if test -n "${PERL}"; then 134 _R_PROG_PERL_VERSION 135else 136 ## <NOTE> 137 ## Need a full path for '@PERL@' substitutions when starting Perl 138 ## scripts with a line of the form '#! FOO'. 139 AC_PATH_PROGS(FALSE, false) 140 PERL="${FALSE}" 141 ## </NOTE> 142fi 143if test "${r_cv_prog_perl_v5}" = yes; then 144 NO_PERL5=false 145else 146 warn_perl5="you cannot build the object documentation system" 147 AC_MSG_WARN([${warn_perl5}]) 148 NO_PERL5=true 149fi 150AC_SUBST(NO_PERL5) 151])# R_PROG_PERL 152 153## _R_PROG_PERL_VERSION 154## -------------------- 155## Building the R documentation system (Rdconv and friends) requires 156## Perl version 5.004 or better. 157## Set shell variable r_cv_prog_perl_v5 to 'yes' if a recent enough 158## Perl is found, and to 'no' otherwise. 159AC_DEFUN([_R_PROG_PERL_VERSION], 160[AC_CACHE_CHECK([whether perl version is at least 5.004], 161 [r_cv_prog_perl_v5], 162[if ${PERL} -e 'require 5.004 or exit 1'; then 163 r_cv_prog_perl_v5=yes 164else 165 r_cv_prog_perl_v5=no 166fi]) 167])# _R_PROG_PERL_VERSION 168 169## R_PROG_TEXMF 170## ------------ 171AC_DEFUN([R_PROG_TEXMF], 172[AC_REQUIRE([R_PROG_PERL]) 173AC_PATH_PROGS(DVIPS, [${DVIPS} dvips], false) 174AC_PATH_PROGS(TEX, [${TEX} tex], false) 175AC_PATH_PROGS(LATEX, [${LATEX} latex], false) 176if test -z "${ac_cv_path_TEX}" ; then 177 warn_dvi="you cannot build DVI versions of the R manuals" 178elif test -z "${ac_cv_path_LATEX}"; then 179 warn_dvi="you cannot build DVI versions of all the help pages" 180fi 181if test -n "${warn_dvi}"; then 182 AC_MSG_WARN([${warn_dvi}]) 183fi 184AC_PATH_PROGS(MAKEINDEX, [${MAKEINDEX} makeindex], false) 185AC_PATH_PROGS(PDFTEX, [${PDFTEX} pdftex], false) 186AC_PATH_PROGS(PDFLATEX, [${PDFLATEX} pdflatex], false) 187if test -z "${ac_cv_path_PDFTEX}" ; then 188 warn_pdf="you cannot build PDF versions of the R manuals" 189elif test -z "${ac_cv_path_PDFLATEX}" ; then 190 warn_pdf="you cannot build PDF versions of all the help pages" 191fi 192if test -n "${warn_pdf}"; then 193 AC_MSG_WARN([${warn_pdf}]) 194fi 195AC_PATH_PROGS(MAKEINFO_CMD, [${MAKEINFO} makeinfo]) 196## This test admittedly looks a bit strange ... see R_PROG_PERL. 197if test "${PERL}" = "${FALSE}"; then 198 AC_PATH_PROGS(INSTALL_INFO, [${INSTALL_INFO} install-info], false) 199else 200 INSTALL_INFO="\$(PERL) \$(top_srcdir)/tools/install-info.pl" 201 AC_SUBST(INSTALL_INFO) 202fi 203: ${R_RD4DVI="ae"} 204AC_SUBST(R_RD4DVI) 205: ${R_RD4PDF="times,hyper"} 206AC_SUBST(R_RD4PDF) 207])# R_PROG_TEXMF 208 209## R_PROG_MAKEINFO 210## --------------- 211AC_DEFUN([R_PROG_MAKEINFO], 212## This used to be part of R_PROG_TEXMF, where it really belongs. 213## Unfortunately, AC_PROG_LIBTOOL unconditionally overwrites MAKEINFO 214## by makeinfo or missing. To allow users to pass a MAKEINFO setting to 215## configure, we thus have to run R_PROG_TEXMF before AC_PROG_LIBTOOL, 216## save the result to something not overwritten (hence MAKEINFO_CMD), 217## and finally set MAKEINFO according to our needs. 218[AC_REQUIRE([R_PROG_TEXMF]) 219AC_REQUIRE([AC_PROG_LIBTOOL]) 220if test -n "${MAKEINFO_CMD}"; then 221 _R_PROG_MAKEINFO_VERSION 222fi 223if test "${r_cv_prog_makeinfo_v4}" != yes; then 224 warn_info="you cannot build info or html versions of the R manuals" 225 AC_MSG_WARN([${warn_info}]) 226 MAKEINFO=false 227else 228 MAKEINFO="${MAKEINFO_CMD}" 229fi 230])# R_PROG_MAKEINFO 231 232## _R_PROG_MAKEINFO_VERSION 233## ------------------------ 234## Building the R Texinfo manuals requires Makeinfo v4.7 or better. 235## Set shell variable r_cv_prog_makeinfo_v4 to 'yes' if a recent 236## enough Makeinfo is found, and to 'no' otherwise. 237## If you change the minimum version here, also change it in 238## doc/manual/Makefile.in and doc/manual/R-admin.texi. 239AC_DEFUN([_R_PROG_MAKEINFO_VERSION], 240[AC_CACHE_CHECK([whether makeinfo version is at least 4.7], 241 [r_cv_prog_makeinfo_v4], 242[makeinfo_version=`${MAKEINFO_CMD} --version | \ 243 grep "^makeinfo" | sed 's/[[^)]]*) \(.*\)/\1/'` 244makeinfo_version_maj=`echo ${makeinfo_version} | cut -f1 -d.` 245makeinfo_version_min=`echo ${makeinfo_version} | cut -f2 -d.` 246if test -z "${makeinfo_version_maj}" \ 247 || test -z "${makeinfo_version_min}"; then 248 r_cv_prog_makeinfo_v4=no 249elif test ${makeinfo_version_maj} -lt 4 \ 250 || test ${makeinfo_version_min} -lt 7; then 251 r_cv_prog_makeinfo_v4=no 252else 253 r_cv_prog_makeinfo_v4=yes 254fi]) 255])# _R_PROG_MAKEINFO_VERSION 256 257## R_PROG_BROWSER 258## -------------- 259AC_DEFUN([R_PROG_BROWSER], 260[if test -z "${R_BROWSER}"; then 261 AC_PATH_PROGS(R_BROWSER, [firefox mozilla netscape galeon kfmclient opera gnome-moz-remote open]) 262fi 263if test -z "${R_BROWSER}"; then 264 warn_browser="I could not determine a browser" 265 AC_MSG_WARN([${warn_browser}]) 266else 267 AC_MSG_RESULT([using default browser ... ${R_BROWSER}]) 268fi 269AC_SUBST(R_BROWSER) 270])# R_BROWSER 271 272## R_PROG_PDFVIEWER 273## ---------------- 274## Try to determine a PDF viewer. 275## According to Jeff Gentry <jgentry@jimmy.harvard.edu>, 'acroread4' is 276## the FreeBSD acroread port. 277AC_DEFUN([R_PROG_PDFVIEWER], 278[AC_PATH_PROGS(R_PDFVIEWER, 279 [${R_PDFVIEWER} acroread acroread4 xpdf gv gnome-gv ggv kghostview open gpdf]) 280if test -z "${R_PDFVIEWER}"; then 281 warn_pdfviewer="I could not determine a PDF viewer" 282 AC_MSG_WARN([${warn_pdfviewer}]) 283fi 284AC_SUBST(R_PDFVIEWER) 285])# R_PDFVIEWER 286 287### * C compiler and its characteristics. 288 289## R_PROG_CPP_CPPFLAGS 290## ------------------- 291## In case of gcc, check whether the C preprocessor complains about 292## having '/usr/local/include' in its header search path (no matter how 293## it came there). GCC 3.1 and 3.2 (at least) give warnings about 294## 'changing search order for system directory "/usr/local/include" as 295## it has already been specified as a non-system directory' which are at 296## least quite annoying. 297## <NOTE> 298## We currently do not distinguish whether '/usr/local/include' was 299## added as the R default, or by an explicit CPPFLAGS arg to configure. 300## If we wanted to, we should change 301## : ${CPPFLAGS="-I/usr/local/include"} 302## in 'configure.ac' by something like 303## : ${CPPFLAGS=${r_default_CPPFLAGS="-I/usr/local/include"}} 304## and test whether r_default_CPPFLAGS is non-empty. 305## </NOTE> 306AC_DEFUN([R_PROG_CPP_CPPFLAGS], 307[AC_REQUIRE([AC_PROG_CC]) 308AC_REQUIRE([AC_PROG_CPP]) 309if test "${GCC}" = yes; then 310 AC_LANG_PUSH(C) 311 AC_LANG_CONFTEST([AC_LANG_PROGRAM()]) 312 if ${CPP} ${CPPFLAGS} conftest.${ac_ext} 2>&1 1>/dev/null | \ 313 grep 'warning:.*system directory.*/usr/local/include' >/dev/null; then 314 CPPFLAGS=`echo ${CPPFLAGS} | \ 315 sed 's|\(.*\)-I/usr/local/include *\(.*\)|\1\2|'` 316 fi 317 rm -f conftest.${ac_ext} 318 AC_LANG_POP(C) 319fi])# R_PROG_CPP_CPPFLAGS 320 321## R_PROG_CC_VERSION 322## ----------------- 323## Determine the version of the C compiler (currently only for gcc). 324AC_DEFUN([R_PROG_CC_VERSION], 325[AC_REQUIRE([AC_PROG_CC]) 326CC_VERSION= 327if test "${GCC}" = yes; then 328 CC_VERSION=`${CC} -v 2>&1 | grep "^.*g.. version" | \ 329 sed -e 's/^.*g.. version *//'` 330fi])# R_PROG_CC_VERSION 331 332## R_PROG_CC_M 333## ----------- 334## Check whether we can figure out C Make dependencies. 335AC_DEFUN([R_PROG_CC_M], 336[AC_REQUIRE([R_PROG_CC_VERSION]) 337AC_MSG_CHECKING([whether we can compute C Make dependencies]) 338AC_CACHE_VAL([r_cv_prog_cc_m], 339[echo "#include <math.h>" > conftest.c 340## No real point in using AC_LANG_* and ${ac_ext}, as we need to create 341## hard-wired suffix rules. 342## Another obvious candidate to try is '${MAKEDEPEND-makedepend} -f-'. 343## However, this does not work out of the box when srcdir and builddir 344## are different, as it creates dependencies of the form 345## ${srcdir}/foo.o: /path/to/bar.h 346## Could be made to work, of course ... 347## Note also that it does not create a 'conftest.o: conftest.c' line. 348## For gcc 3.2 or better, we want to use '-MM' in case this works. 349cc_minus_MM=false 350if test "${GCC}" = yes; then 351 case "${CC_VERSION}" in 352 1.*|2.*|3.[[01]]*) ;; 353 *) cc_minus_MM="${CC} -MM" ;; 354 esac 355fi 356for prog in "${cc_minus_MM}" "${CC} -M" "${CPP} -M" "cpp -M"; do 357 if ${prog} conftest.c 2>/dev/null | \ 358 grep 'conftest.o: conftest.c' >/dev/null; then 359 r_cv_prog_cc_m="${prog}" 360 break 361 fi 362done]) 363if test -z "${r_cv_prog_cc_m}"; then 364 AC_MSG_RESULT([no]) 365else 366 AC_MSG_RESULT([yes, using ${r_cv_prog_cc_m}]) 367fi 368])# R_PROG_CC_M 369 370## R_PROG_CC_C_O_LO 371## ---------------- 372## Check whether the C compiler supports '-c -o FILE.lo'. 373AC_DEFUN([R_PROG_CC_C_O_LO], 374[AC_CACHE_CHECK([whether ${CC} supports -c -o FILE.lo], 375 [r_cv_prog_cc_c_o_lo], 376[test -d TMP || mkdir TMP 377echo "int some_variable = 0;" > conftest.c 378## No real point in using AC_LANG_* and ${ac_ext}, as we need to create 379## hard-wired suffix rules. 380ac_try='${CC} ${CFLAGS} -c conftest.c -o TMP/conftest.lo 1>&AS_MESSAGE_LOG_FD' 381if AC_TRY_EVAL(ac_try) \ 382 && test -f TMP/conftest.lo \ 383 && AC_TRY_EVAL(ac_try); then 384 r_cv_prog_cc_c_o_lo=yes 385else 386 r_cv_prog_cc_c_o_lo=no 387fi 388rm -rf conftest* TMP]) 389])# R_PROG_CC_C_O_LO 390 391## R_PROG_CC_MAKEFRAG 392## ------------------ 393## Generate a Make fragment with suffix rules for the C compiler. 394## Used for both building R (Makeconf) and add-ons (etc/Makeconf). 395AC_DEFUN([R_PROG_CC_MAKEFRAG], 396[r_cc_rules_frag=Makefrag.cc 397AC_REQUIRE([R_PROG_CC_M]) 398cat << \EOF > ${r_cc_rules_frag} 399.c.o: 400 $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c $< -o $[@] 401EOF 402if test -n "${r_cv_prog_cc_m}"; then 403 cat << EOF >> ${r_cc_rules_frag} 404.c.d: 405 @echo "making \$[@] from \$<" 406 @${r_cv_prog_cc_m} \$(ALL_CPPFLAGS) $< > \$[@] 407EOF 408else 409 cat << \EOF >> ${r_cc_rules_frag} 410.c.d: 411 @echo > $[@] 412EOF 413fi 414AC_SUBST_FILE(r_cc_rules_frag) 415])# R_PROG_CC_MAKEFRAG 416 417## R_PROG_CC_LO_MAKEFRAG 418## --------------------- 419## Generate a Make fragment with suffix rules for the C compiler. 420## Used for both building R (Makeconf) and add-ons (etc/Makeconf). 421## Need to make .lo files in src/nmath/standalone only 422## NB test -d .libs || mkdir .libs can be run more than once 423## and hence race when a parallel make is used 424AC_DEFUN([R_PROG_CC_LO_MAKEFRAG], 425[r_cc_lo_rules_frag=Makefrag.cc_lo 426AC_REQUIRE([R_PROG_CC_C_O_LO]) 427if test "${r_cv_prog_cc_c_o_lo}" = yes; then 428 cat << \EOF > ${r_cc_lo_rules_frag} 429.c.lo: 430 $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS_LO) -c $< -o $[@] 431EOF 432else 433 cat << \EOF > ${r_cc_lo_rules_frag} 434.c.lo: 435 @-test -d .libs || mkdir .libs 436 $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS_LO) -c $< -o .libs/$[*].o 437 mv .libs/$[*].o $[*].lo 438EOF 439fi 440AC_SUBST_FILE(r_cc_lo_rules_frag) 441])# R_PROG_CC_LO_MAKEFRAG 442 443 444## R_PROG_CC_FLAG(FLAG, [ACTION-IF-TRUE]) 445## --------------------------------------- 446## Check whether the C compiler handles command line option FLAG, 447## and set shell variable r_cv_prog_cc_flag_SFLAG accordingly (where 448## SFLAG is a shell-safe transliteration of FLAG). 449## In addition, execute ACTION-IF-TRUE in case of success. 450AC_DEFUN([R_PROG_CC_FLAG], 451[ac_safe=AS_TR_SH($1) 452AC_MSG_CHECKING([whether ${CC} accepts $1]) 453AC_CACHE_VAL([r_cv_prog_cc_flag_${ac_safe}], 454[AC_LANG_PUSH(C) 455r_save_CFLAGS="${CFLAGS}" 456CFLAGS="${CFLAGS} $1" 457AC_LINK_IFELSE([AC_LANG_PROGRAM()], 458 [eval "r_cv_prog_cc_flag_${ac_safe}=yes"], 459 [eval "r_cv_prog_cc_flag_${ac_safe}=no"]) 460CFLAGS="${r_save_CFLAGS}" 461AC_LANG_POP(C) 462]) 463if eval "test \"`echo '$r_cv_prog_cc_flag_'$ac_safe`\" = yes"; then 464 AC_MSG_RESULT([yes]) 465 [$2] 466else 467 AC_MSG_RESULT([no]) 468fi 469])# R_PROG_CC_FLAG 470 471## R_PROG_CC_FLAG_D__NO_MATH_INLINES 472## --------------------------- 473## In glibc 2.1, inline version [x86] of exp was broken (exp(-Inf) = NaN). 474## We fix this by adding '-D__NO_MATH_INLINES' to R_XTRA_CFLAGS rather 475## than AC_DEFINE(__NO_MATH_INLINES) as the former also takes care of 476## compiling C code for add-on packages. 477AC_DEFUN([R_PROG_CC_FLAG_D__NO_MATH_INLINES], 478[AC_CACHE_CHECK([whether C runtime needs -D__NO_MATH_INLINES], 479 [r_cv_c_no_math_inlines], 480[AC_RUN_IFELSE([AC_LANG_SOURCE([[ 481#include <math.h> 482#if defined(__GLIBC__) 483int main () { 484 double x, y; 485 x = -0./1.; 486 y = exp(x); 487 exit (y != 0.); 488} 489#else 490int main () { 491 exit(0); 492} 493#endif 494]])], 495 [r_cv_c_no_math_inlines=yes], 496 [r_cv_c_no_math_inlines=no], 497 [r_cv_c_no_math_inlines=no])]) 498if test "${r_cv_c_no_math_inlines}" = yes; then 499 R_SH_VAR_ADD(R_XTRA_CFLAGS, [-D__NO_MATH_INLINES]) 500fi 501])# R_PROG_CC_FLAG_D__NO_MATH_INLINES 502 503## R_C_OPTIEEE 504## ----------- 505## Check whether the C compiler needs '-OPT:IEEE_NaN_inf=ON' to 506## correctly deal with IEEE NaN/Inf. 507## This flag is needed for the native SGI C compiler. 508## If needed, add the flag to R_XTRA_CFLAGS. 509AC_DEFUN([R_C_OPTIEEE], 510[AC_CACHE_CHECK([whether C compiler needs -OPT:IEEE_NaN_inf=ON], 511 [r_cv_c_optieee], 512[AC_RUN_IFELSE([AC_LANG_SOURCE([[ 513#include <math.h> 514#include <ieeefp.h> 515int main () { 516 double x = 0; 517 fpsetmask(0); x = x / x; exit (x != x); 518} 519]])], 520 [r_cv_c_optieee=yes], 521 [r_cv_c_optieee=no], 522 [r_cv_c_optieee=no])]) 523if test "${r_cv_c_optieee}" = yes; then 524 R_SH_VAR_ADD(R_XTRA_CFLAGS, [-OPT:IEEE_NaN_inf=ON]) 525fi 526])# R_C_OPTIEEE 527 528## R_C_INLINE 529## ---------- 530## modified version of AC_C_INLINE to use R_INLINE not inline 531AC_DEFUN([R_C_INLINE], 532[AC_REQUIRE([AC_PROG_CC_STDC]) dnl 533AC_CACHE_CHECK([for inline], r_cv_c_inline, 534[r_cv_c_inline="" 535for ac_kw in inline __inline__ __inline; do 536 AC_COMPILE_IFELSE([AC_LANG_SOURCE( 537[#ifndef __cplusplus 538static $ac_kw int static_foo () {return 0; } 539$ac_kw int foo () {return 0; } 540#endif 541])], 542 [r_cv_c_inline=$ac_kw; break]) 543done 544]) 545case $r_cv_c_inline in 546 no) AC_DEFINE(R_INLINE,, 547 [Define as `inline', or `__inline__' or `__inline' 548 if that's what the C compiler calls it, 549 or to nothing if it is not supported.]) ;; 550 *) AC_DEFINE_UNQUOTED(R_INLINE, $r_cv_c_inline) ;; 551esac 552])# R_C_INLINE 553 554### * C++ compiler and its characteristics. 555 556## R_PROG_CXX_M 557## ------------ 558## Check whether the C++ compiler accepts '-M' for generating 559## dependencies. 560AC_DEFUN([R_PROG_CXX_M], 561[AC_REQUIRE([R_PROG_CC_M]) 562AC_CACHE_CHECK([whether ${CXX} accepts -M for generating dependencies], 563 [r_cv_prog_cxx_m], 564[echo "#include <math.h>" > conftest.cc 565## No real point in using AC_LANG_* and ${ac_ext}, as we need to create 566## hard-wired suffix rules. We could be a bit more careful as we 567## actually only test suffix '.cc'. 568if test -n "`${CXX} -M conftest.cc 2>/dev/null | grep conftest`"; then 569 r_cv_prog_cxx_m=yes 570else 571 r_cv_prog_cxx_m=no 572fi]) 573])# R_PROG_CXX_M 574 575## R_PROG_CXX_MAKEFRAG 576## ------------------- 577## Generate a Make fragment with suffix rules for the C++ compiler. 578## Used for both building R (Makeconf) and add-ons (etc/Makeconf). 579AC_DEFUN([R_PROG_CXX_MAKEFRAG], 580[r_cxx_rules_frag=Makefrag.cxx 581AC_REQUIRE([R_PROG_CXX_M]) 582cat << \EOF > ${r_cxx_rules_frag} 583.cc.o: 584 $(CXX) $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) -c $< -o $[@] 585.cpp.o: 586 $(CXX) $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) -c $< -o $[@] 587.C.o: 588 $(CXX) $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) -c $< -o $[@] 589EOF 590if test "${r_cv_prog_cxx_m}" = yes; then 591 cat << \EOF >> ${r_cxx_rules_frag} 592.cc.d: 593 @echo "making $[@] from $<" 594 @$(CXX) -M $(ALL_CPPFLAGS) $< > $[@] 595.cpp.d: 596 @echo "making $[@] from $<" 597 @$(CXX) -M $(ALL_CPPFLAGS) $< > $[@] 598.C.d: 599 @echo "making $[@] from $<" 600 @$(CXX) -M $(ALL_CPPFLAGS) $< > $[@] 601EOF 602else 603 cat << \EOF >> ${r_cxx_rules_frag} 604.cc.d: 605 @echo > $[@] 606.cpp.d: 607 @echo > $[@] 608.C.d: 609 @echo > $[@] 610EOF 611fi 612AC_SUBST_FILE(r_cxx_rules_frag) 613])# R_PROG_CXX_MAKEFRAG 614 615## R_PROG_CXX_FLAG 616## --------------- 617## Check whether the C++ compiler handles command line option FLAG, 618## and set shell variable r_cv_prog_cc_flag_SFLAG accordingly (where 619## SFLAG is a shell-safe transliteration of FLAG). 620## In addition, execute ACTION-IF-TRUE in case of success. 621AC_DEFUN([R_PROG_CXX_FLAG], 622[ac_safe=AS_TR_SH($1) 623AC_MSG_CHECKING([whether ${CXX-c++} accepts $1]) 624AC_CACHE_VAL([r_cv_prog_cxx_flag_${ac_safe}], 625[AC_LANG_PUSH(C++) 626r_save_CXXFLAGS="${CXXFLAGS}" 627CXXFLAGS="${CXXFLAGS} $1" 628AC_LINK_IFELSE([AC_LANG_PROGRAM()], 629 [eval "r_cv_prog_cxx_flag_${ac_safe}=yes"], 630 [eval "r_cv_prog_cxx_flag_${ac_safe}=no"]) 631CXXFLAGS="${r_save_CXXFLAGS}" 632AC_LANG_POP(C++) 633]) 634if eval "test \"`echo '$r_cv_prog_cxx_flag_'$ac_safe`\" = yes"; then 635 AC_MSG_RESULT([yes]) 636 [$2] 637else 638 AC_MSG_RESULT([no]) 639fi 640])# R_PROG_CXX_FLAG 641 642### * Fortran 77 compiler/converter and its characteristics. 643 644## R_PROG_F77 645## ---------- 646## Find a Fortran 77 compiler 647## 648## If we have not been forced to use a particular Fortran compiler, try 649## to find one using one of the several common names. The list is based 650## on what the current autoconf CVS contains (2005-05-21). This says, 651## 652## <QUOTE> 653## Known compilers: 654## f77/f90/f95: generic compiler names 655## g77: GNU Fortran 77 compiler 656## gfortran: putative GNU Fortran 95+ compiler (in progress) 657## ftn: native Fortran 95 compiler on Cray X1 658## cf77: native F77 compiler under older Crays (prefer over fort77) 659## fort77: native F77 compiler under HP-UX (and some older Crays) 660## frt: Fujitsu F77 compiler 661## pgf77/pgf90/pghpf/pgf95: Portland Group F77/F90/F95 compilers 662## xlf/xlf90/xlf95: IBM (AIX) F77/F90/F95 compilers 663## lf95: Lahey-Fujitsu F95 compiler 664## fl32: Microsoft Fortran 77 "PowerStation" compiler 665## af77: Apogee F77 compiler for Intergraph hardware running CLIX 666## epcf90: "Edinburgh Portable Compiler" F90 667## fort: Compaq (now HP) Fortran 90/95 compiler for Tru64 and Linux/Alpha 668## ifort, previously ifc: Intel Fortran 95 compiler for Linux/x86 669## efc: Intel Fortran 95 compiler for IA64 670## </QUOTE> 671## 672## and uses the following lists: 673## F95: f95 fort xlf95 ifort ifc efc pgf95 lf95 gfortran ftn 674## F90: f90 xlf90 pgf90 pghpf epcf90 675## F77: g77 f77 xlf frt pgf77 cf77 fort77 fl32 af77 676## 677## We use basically the same, with the following exceptions: 678## * On HP-UX fort77 is the POSIX-compatible native compiler and 679## f77 is not: hence we need look for fort77 first! 680## <FIXME> 681## Is this still true? 682## </FIXME> 683## * It seems that g95 has been resurrected, see www.g95.org, hence we 684## add this to the list of F95 compilers. 685## * Older versions of the Autoconf code used to have 'fc' as a wrapper 686## around f2c (last in the list). It no longer has, but we still do. 687## <FIXME> 688## Is this still needed? 689## </FIXME> 690## * If the C compiler is gcc, we try looking for a matching GCC Fortran 691## compiler (gfortran for 4.x, g77 for 3.x) first. This should handle 692## problems if GCC 4.x and 3.x suites are installed and, depending on 693## the gcc default, the "wrong" GCC Fortran compiler is picked up (as 694## reported by Bill Northcott <w.northcott@unsw.edu.au> for OSX with 695## 4.0 as default and g77 around and the "old" search order F77 F95 696## F90 in use). 697AC_DEFUN([R_PROG_F77], 698[AC_BEFORE([$0], [AC_PROG_LIBTOOL]) 699AC_REQUIRE([R_PROG_CC_VERSION]) 700if test -n "${F77}"; then 701 AC_MSG_RESULT([defining F77 to be ${F77}]) 702else 703 F77= 704 F95_compilers="f95 fort xlf95 ifort ifc efc pgf95 lf95 gfortran ftn g95" 705 F90_compilers="f90 xlf90 pgf90 pghpf epcf90" 706 case "${host_os}" in 707 hpux*) 708 F77_compilers="g77 fort77 f77 xlf frt pgf77 cf77 fl32 af77" ;; 709 *) 710 F77_compilers="g77 f77 xlf frt pgf77 cf77 fort77 fl32 af77" ;; 711 esac 712 GCC_Fortran_compiler= 713 if test "${GCC}" = yes; then 714 case "${CC_VERSION}" in 715 3.*) GCC_Fortran_compiler=g77 ;; 716 4.*) GCC_Fortran_compiler=gfortran ;; 717 esac 718 fi 719 AC_CHECK_PROGS(F77, [ ${GCC_Fortran_compiler} ${F95_compilers} \ 720 ${F90_compilers} ${F77_compilers} fc ]) 721fi 722if test -n "${F77}"; then 723 ## If the above 'found' a Fortran 77 compiler, we run AC_PROG_F77 as 724 ## this does additional testing (GNU, '-g', ...). 725 AC_PROG_F77 726else 727 AC_MSG_ERROR([Neither an F77 compiler nor f2c found]) 728fi 729])# R_PROG_F77 730 731## R_PROG_F77_FLIBS 732## ---------------- 733## Run AC_F77_LIBRARY_LDFLAGS, and fix some known problems with FLIBS. 734## Only do this if the user has not already set FLIBS. 735AC_DEFUN([R_PROG_F77_FLIBS], 736[AC_BEFORE([$0], [AC_F77_LIBRARY_LDFLAGS]) 737if test -z "${FLIBS}"; then 738## 739## Currently (Autoconf 2.50 or better, it seems) FLIBS also contains all 740## elements of LIBS when AC_F77_LIBRARY_LDFLAGS is run. This is because 741## _AC_PROG_F77_V_OUTPUT() uses 'eval $ac_link' for obtaining verbose 742## linker output, and AC_LANG(Fortran 77) sets up ac_link to contain 743## LIBS. Most likely a bug, and a nuisance in any case ... 744## But we cannot simply eliminate the elements in FLIBS duplicated from 745## LIBS (e.g. '-lm' should be preserved). Hence, we try to call 746## AC_F77_LIBRARY_LDFLAGS() with LIBS temporarily set to empty. 747r_save_LIBS="${LIBS}" 748LIBS= 749AC_F77_LIBRARY_LDFLAGS 750if test -z "${MAIN_LD}" ; then 751 LIBS= 752 R_C_LIBRARY_LDFLAGS 753else 754 CLIBS= 755fi 756LIBS="${r_save_LIBS}" 757## Currently g77 on Darwin links against '-lcrt1.o' (and for GCC 3.1 or 758## better also against '-lcrtbegin.o'), which (unlike '-lcrt0.o') are 759## not stripped by AC_F77_LIBRARY_LDFLAGS. This in particular causes 760## R_PROG_F77_CC_COMPAT to fail. Hence, we make sure all -lcrt*.o are 761## removed. 762## 763## Native f90 on HPUX 11 comes up with '-l:libF90.a' causing trouble 764## when using gcc for linking. The '-l:' construction is similar to 765## plain '-l' except that search order (archive/shared) given by '-a' 766## is not important. We escape such flags via '-Wl,' in case of gcc. 767## Note that the current Autoconf CVS uses _AC_LINKER_OPTION for a 768## similar purpose when computing FLIBS: this uses '-Xlinker' escapes 769## for gcc and does nothing otherwise. Note also that we cannot simply 770## unconditionally escape with '${wl}' from libtool as on HPUX we need 771## SHLIB_LD=ld for native C compilers (problem with non-PIC 'crt0.o', 772## see 'Individual platform overrides' in section 'DLL stuff' in file 773## 'configure.ac'. 774## 775## Using the Intel Fortran compiler (ifc) one typically gets incorrect 776## flags, as the output from _AC_PROG_F77_V_OUTPUT() contains double 777## quoted options, e.g. "-mGLOB_options_string=......", see also e.g. 778## http://www.octave.org/octave-lists/archive/octave-maintainers.2002/msg00038.html. 779## One possible solution is to change AC_F77_LIBRARY_LDFLAGS() to remove 780## double quotes for ifc, as it already does for the Cray cft90. As we 781## prefer not to overload Autoconf code, we try to fix things here ... 782## 783## As of 2.1.0 we try to tidy this up a bit. 784## 1) -lfrtbegin and -lgfortranbegin are used by g77/gfortran only for a 785## Fortran main program, which we do not have. 786## 2) g77 also tends to duplicate paths via ../../.., so we canonicalize 787## paths and remove duplicates. 788## 3) We do not need -L/lib etc, nor those in LDFLAGS 789## 4) We exclude path with CC will include when linking. 790## 791## First try to fathom out what -Lfoo commands are unnecessary. 792case "${host_os}" in 793 linux*) 794 r_libpath_default="/usr/lib64 /lib64 /usr/lib /lib" 795 ;; 796 solaris*) 797 r_libpath_default="/usr/lib /lib" 798 ;; 799 *) 800 r_libpath_default= 801 ;; 802esac 803r_extra_libs= 804for arg in ${LDFLAGS} ${CLIBS}; do 805 case "${arg}" in 806 -L*) 807 lib=`echo ${arg} | sed "s/^-L//"` 808 test -d "${lib}" || continue 809 ## Canonicalize (/usr/lib/gcc-lib/i686-linux/3.4.3/../../..). 810 lib=`cd "${lib}" && ${GETWD}` 811 r_extra_libs="${r_extra_libs} $lib" 812 ;; 813 esac 814done 815 816flibs= 817if test "${GCC}" = yes; then 818 linker_option="-Wl," 819else 820 linker_option= 821fi 822r_save_flibs="" 823for arg in ${FLIBS}; do 824 case "${arg}" in 825 ## this is not for a Fortran main program 826 -lcrt*.o | -lfrtbegin | -lgfortranbegin) 827 ;; 828 -[[a-zA-Z]]/*\" | -[[a-zA-Z]]*\\) # ifc 829 ;; 830 -l:*) 831 flibs="${flibs} ${linker_option}${arg}" 832 ;; 833 -L*) 834 lib=`echo ${arg} | sed "s/^-L//"` 835 ## Do not add non-existent directories. 836 test -d "${lib}" || continue 837 ## Canonicalize (/usr/lib/gcc-lib/i686-linux/3.4.3/../../..). 838 lib=`cd "${lib}" && ${GETWD}` 839 r_want_lib=true 840 ## Do not add something twice nor default paths nor those in LDFLAGS 841 for dir in ${r_save_flibs} ${r_libpath_default} ${r_extra_libs}; do 842 if test "${dir}" = "${lib}"; then 843 r_want_lib=false 844 break 845 fi 846 done 847 if test x"${r_want_lib}" = xtrue; then 848 flibs="${flibs} -L${lib}" 849 r_save_flibs="${r_save_flibs} ${lib}" 850 fi 851 ;; 852 *) 853 flibs="${flibs} ${arg}" 854 ;; 855 esac 856done 857FLIBS="${flibs}" 858fi 859])# R_PROG_F77_FLIBS 860 861## R_PROG_F77_APPEND_UNDERSCORE 862## ---------------------------- 863## See if the Fortran 77 compiler appends underscores. 864## What we really should do is determine how to properly mangle the 865## names of C/C++ identifiers (potentially containing underscores) so 866## that they match the name-mangling scheme used by the Fortran 77 867## compiler. Autoconf 2.50 or better has macros F77_FUNC(name, NAME) 868## and F77_FUNC_(name, NAME) for this. However, the F77_* macros in 869## the R API have one argument only and therefore cannot deal with 870## Fortran 77 compilers which convert to upper case or add an extra 871## underscore for identifiers containing underscores. We give an error 872## in the former case; as ISO Fortran 77 does not allow underscores in 873## function names, we do nothing about the latter. 874AC_DEFUN([R_PROG_F77_APPEND_UNDERSCORE], 875[AC_REQUIRE([AC_F77_WRAPPERS]) 876## DANGER! We really needs the results of _AC_F77_NAME_MANGLING as 877## stored in the cache var ac_cv_f77_mangling which is not documented 878## and hence may change ... 879case "${ac_cv_f77_mangling}" in 880 "upper "*) 881 AC_MSG_WARN([Fortran compiler uses uppercase external names]) 882 AC_MSG_ERROR([cannot use Fortran]) 883 ;; 884esac 885AC_MSG_CHECKING([whether ${F77} appends underscores to external names]) 886AC_CACHE_VAL([r_cv_prog_f77_append_underscore], 887[case "${ac_cv_f77_mangling}" in 888 *", underscore, "*) 889 r_cv_prog_f77_append_underscore=yes 890 ;; 891 *", no underscore, "*) 892 r_cv_prog_f77_append_underscore=no 893 ;; 894esac]) 895if test -n "${r_cv_prog_f77_append_underscore}"; then 896 AC_MSG_RESULT([${r_cv_prog_f77_append_underscore}]) 897else 898 AC_MSG_RESULT([unknown]) 899 AC_MSG_ERROR([cannot use Fortran]) 900fi 901if test "${r_cv_prog_f77_append_underscore}" = yes; then 902 AC_DEFINE(HAVE_F77_UNDERSCORE, 1, 903 [Define if your Fortran compiler appends an underscore to 904 external names.]) 905fi 906])# R_PROG_F77_APPEND_UNDERSCORE 907 908## R_PROG_F77_CAN_RUN 909## -------------------- 910## Check whether the C/Fortran set up produces runnable code, as 911## a preliminary to the compatibility tests. 912## May fail if Fortran shared libraries are not in the library path. 913AC_DEFUN([R_PROG_F77_CAN_RUN], 914[AC_REQUIRE([AC_CHECK_LIBM]) 915AC_MSG_CHECKING([whether mixed C/Fortran code can be run]) 916AC_CACHE_VAL([r_cv_prog_f77_can_run], 917[cat > conftestf.f <<EOF 918 subroutine cftest(a, b, x, y) 919 integer a(3), b(2) 920 double precision x(3), y(3) 921 end 922EOF 923${F77} ${FFLAGS} -c conftestf.f 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD 924## Yes we need to double quote this ... 925[cat > conftest.c <<EOF 926#include <math.h> 927#include "confdefs.h" 928#ifdef HAVE_F77_UNDERSCORE 929# define F77_SYMBOL(x) x ## _ 930#else 931# define F77_SYMBOL(x) x 932#endif 933int main () { 934 exit(0); 935} 936EOF] 937if ${CC} ${CFLAGS} -c conftest.c 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then 938 ## <NOTE> 939 ## This should really use MAIN_LD, and hence come after this is 940 ## determined (and necessary additions to MAIN_LDFLAGS were made). 941 ## But it seems that we currently can always use the C compiler. 942 ## Also, to be defensive there should be a similar test with SHLIB_LD 943 ## and SHLIB_LDFLAGS (and note that on HPUX with native cc we have to 944 ## use ld for SHLIB_LD) ... 945 if ${CC} ${LDFLAGS} ${MAIN_LDFLAGS} -o conftest${ac_exeext} \ 946 conftest.${ac_objext} conftestf.${ac_objext} ${FLIBS} \ 947 ${LIBM} 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; 948 ## </NOTE> 949 then 950 ## redirect error messages to config.log 951 output=`./conftest${ac_exeext} 2>&AS_MESSAGE_LOG_FD` 952 if test ${?} = 0; then 953 r_cv_prog_f77_can_run=yes 954 fi 955 fi 956fi 957]) 958rm -rf conftest conftest.* conftestf.* core 959if test -n "${r_cv_prog_f77_can_run}"; then 960 AC_MSG_RESULT([yes]) 961else 962 AC_MSG_WARN([cannot run mixed C/Fortan code]) 963 AC_MSG_ERROR([Maybe check LDFLAGS for paths to Fortran libraries?]) 964fi 965])# R_PROG_F77_CAN_RUN 966 967## R_PROG_F77_CC_COMPAT 968## -------------------- 969## Check whether the Fortran 77 and C compilers agree on int and double. 970AC_DEFUN([R_PROG_F77_CC_COMPAT], 971[AC_REQUIRE([AC_CHECK_LIBM]) 972AC_MSG_CHECKING([whether ${F77} and ${CC} agree on int and double]) 973AC_CACHE_VAL([r_cv_prog_f77_cc_compat], 974[cat > conftestf.f <<EOF 975 subroutine cftest(a, b, x, y) 976 integer a(3), b(2) 977 double precision x(3), y(3) 978 979 b(1) = a(3)/a(2) 980 b(2) = a(3) - a(1)*a(2) 981 y(1) = dble(a(3))/x(2) 982 y(2) = x(3)*x(1) 983 y(3) = (x(2)/x(1)) ** a(1) 984 end 985EOF 986${F77} ${FFLAGS} -c conftestf.f 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD 987## Yes we need to double quote this ... 988[cat > conftest.c <<EOF 989#include <math.h> 990#include "confdefs.h" 991#ifdef HAVE_F77_UNDERSCORE 992# define F77_SYMBOL(x) x ## _ 993#else 994# define F77_SYMBOL(x) x 995#endif 996 997extern void F77_SYMBOL(cftest)(int *a, int *b, double *x, double *y); 998 999int main () { 1000 int a[3] = {17, 237, 2000000000}, b[2], res = 0; 1001 double x[3] = {3.14159265, 123.456789, 2.3e34}, z[3]; 1002 double eps = 1e-6; 1003 double zres[3]; 1004 int i, bres[2]; 1005 1006 zres[0] = (double) a[2]/x[1]; 1007 zres[1] = x[2]*x[0]; 1008 zres[2] = pow(x[1]/x[0], 17.0); 1009 bres[0] = a[2]/a[1]; 1010 bres[1] = a[2] - a[0]*a[1]; 1011 F77_SYMBOL(cftest)(a, b, x, z); 1012 if(b[0] != bres[0]) res++; 1013 if(b[1] != bres[1]) res++; 1014 for(i = 0; i < 3; i++) 1015 if(fabs(z[i]/zres[i] - 1) > eps) res++; 1016 printf("number of errors %d\n", res); 1017 exit(res); 1018} 1019EOF] 1020if ${CC} ${CFLAGS} -c conftest.c 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then 1021 ## <NOTE> 1022 ## This should really use MAIN_LD, and hence come after this is 1023 ## determined (and necessary additions to MAIN_LDFLAGS were made). 1024 ## But it seems that we currently can always use the C compiler. 1025 ## Also, to be defensive there should be a similar test with SHLIB_LD 1026 ## and SHLIB_LDFLAGS (and note that on HPUX with native cc we have to 1027 ## use ld for SHLIB_LD) ... 1028 if ${CC} ${LDFLAGS} ${MAIN_LDFLAGS} -o conftest${ac_exeext} \ 1029 conftest.${ac_objext} conftestf.${ac_objext} ${FLIBS} \ 1030 ${LIBM} 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; 1031 ## </NOTE> 1032 then 1033 ## redirect error messages to config.log 1034 output=`./conftest${ac_exeext} 2>&AS_MESSAGE_LOG_FD` 1035 if test ${?} = 0; then 1036 r_cv_prog_f77_cc_compat=yes 1037 fi 1038 fi 1039fi 1040]) 1041rm -rf conftest conftest.* conftestf.* core 1042if test -n "${r_cv_prog_f77_cc_compat}"; then 1043 AC_MSG_RESULT([yes]) 1044else 1045 AC_MSG_WARN([${F77} and ${CC} disagree on int and double]) 1046 AC_MSG_ERROR([Maybe change CFLAGS or FFLAGS?]) 1047fi 1048])# R_PROG_F77_CC_COMPAT 1049 1050## R_PROG_F77_CC_COMPAT_COMPLEX 1051## ---------------------------- 1052## Check whether the Fortran 77 and C compilers agree on double complex. 1053AC_DEFUN([R_PROG_F77_CC_COMPAT_COMPLEX], 1054[AC_REQUIRE([AC_CHECK_LIBM]) 1055AC_MSG_CHECKING([whether ${F77} and ${CC} agree on double complex]) 1056AC_CACHE_VAL([r_cv_prog_f77_cc_compat_complex], 1057[cat > conftestf.f <<EOF 1058 subroutine cftest(x) 1059 complex*16 x(3) 1060 integer i 1061 1062c a few tests of constructs that are sometimes missing 1063 if(x(1) .eq. x(1)) i = 0 1064 x(1) = x(1)*x(2) + x(3) 1065 end 1066EOF 1067${F77} ${FFLAGS} -c conftestf.f 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD 1068## Yes we need to double quote this ... 1069[cat > conftest.c <<EOF 1070#include <math.h> 1071#include "confdefs.h" 1072#ifdef HAVE_F77_UNDERSCORE 1073# define F77_SYMBOL(x) x ## _ 1074#else 1075# define F77_SYMBOL(x) x 1076#endif 1077 1078typedef struct { 1079 double r; 1080 double i; 1081} Rcomplex; 1082 1083extern void F77_SYMBOL(cftest)(Rcomplex *x); 1084 1085int main () { 1086 Rcomplex z[3]; 1087 1088 z[0].r = 3.14159265; 1089 z[0].i = 2.172; 1090 z[1].i = 3.14159265; 1091 z[1].r = 2.172; 1092 z[2].r = 123.456; 1093 z[2].i = 0.123456; 1094 F77_SYMBOL(cftest)(z); 1095 printf("%f %f\n", z[0].r, z[0].i); 1096 if(fabs(z[0].r - 123.456) < 1e-4 && fabs(z[0].i - 14.71065) < 1e-4) 1097 exit(0); 1098 else exit(1); 1099} 1100EOF] 1101if ${CC} ${CFLAGS} -c conftest.c 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then 1102 ## <NOTE> 1103 ## This should really use MAIN_LD, and hence come after this is 1104 ## determined (and necessary additions to MAIN_LDFLAGS were made). 1105 ## But it seems that we currently can always use the C compiler. 1106 ## Also, to be defensive there should be a similar test with SHLIB_LD 1107 ## and SHLIB_LDFLAGS (and note that on HPUX with native cc we have to 1108 ## use ld for SHLIB_LD) ... 1109 if ${CC} ${LDFLAGS} ${MAIN_LDFLAGS} -o conftest${ac_exeext} \ 1110 conftest.${ac_objext} conftestf.${ac_objext} ${FLIBS} \ 1111 ${LIBM} 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; 1112 ## </NOTE> 1113 then 1114 ## redirect error messages to config.log 1115 output=`./conftest${ac_exeext} 2>&AS_MESSAGE_LOG_FD` 1116 if test ${?} = 0; then 1117 r_cv_prog_f77_cc_compat_complex=yes 1118 fi 1119 fi 1120fi 1121]) 1122rm -rf conftest conftest.* conftestf.* core 1123if test -n "${r_cv_prog_f77_cc_compat_complex}"; then 1124 AC_MSG_RESULT([yes]) 1125 AC_DEFINE(HAVE_FORTRAN_DOUBLE_COMPLEX, 1, 1126 [Define if C's Rcomplex and Fortran's COMPLEX*16 can be 1127 interchanged, and can do arithmetic on the latter.]) 1128else 1129 warn_f77_cc_double_complex="${F77} and ${CC} disagree on double complex" 1130 AC_MSG_WARN([${warn_f77_cc_double_complex}]) 1131fi 1132AC_SUBST(HAVE_FORTRAN_DOUBLE_COMPLEX) 1133])# R_PROG_F77_CC_COMPAT_COMPLEX 1134 1135## R_PROG_F77_FLAG(FLAG, [ACTION-IF-TRUE]) 1136## --------------------------------------- 1137## Check whether the Fortran 77 compiler handles command line option 1138## FLAG, and set shell variable r_cv_prog_f77_flag_SFLAG accordingly 1139## (where SFLAG is a shell-safe transliteration of FLAG). 1140## In addition, execute ACTION-IF-TRUE in case of success. 1141AC_DEFUN([R_PROG_F77_FLAG], 1142[ac_safe=AS_TR_SH($1) 1143AC_MSG_CHECKING([whether ${F77} accepts $1]) 1144AC_CACHE_VAL([r_cv_prog_f77_flag_${ac_safe}], 1145[AC_LANG_PUSH(Fortran 77) 1146r_save_FFLAGS="${FFLAGS}" 1147FFLAGS="${FFLAGS} $1" 1148AC_LINK_IFELSE([AC_LANG_PROGRAM()], 1149 [eval "r_cv_prog_f77_flag_${ac_safe}=yes"], 1150 [eval "r_cv_prog_f77_flag_${ac_safe}=no"]) 1151FFLAGS="${r_save_FFLAGS}" 1152AC_LANG_POP(Fortran 77) 1153]) 1154if eval "test \"`echo '$r_cv_prog_f77_flag_'$ac_safe`\" = yes"; then 1155 AC_MSG_RESULT([yes]) 1156 [$2] 1157else 1158 AC_MSG_RESULT([no]) 1159fi 1160])# R_PROG_F77_FLAG 1161 1162### * Library functions 1163 1164## R_FUNC___SETFPUCW 1165## ----------------- 1166AC_DEFUN([R_FUNC___SETFPUCW], 1167[AC_CHECK_FUNC(__setfpucw, 1168[AC_CACHE_CHECK([whether __setfpucw is needed], 1169 [r_cv_func___setfpucw_needed], 1170[AC_RUN_IFELSE([AC_LANG_SOURCE([[ 1171int main () { 1172#include <fpu_control.h> 1173#if defined(_FPU_DEFAULT) && defined(_FPU_IEEE) 1174 exit(_FPU_DEFAULT != _FPU_IEEE); 1175#endif 1176 exit(0); 1177} 1178]])], 1179 [r_cv_func___setfpucw_needed=no], 1180 [r_cv_func___setfpucw_needed=yes], 1181 [r_cv_func___setfpucw_needed=no])]) 1182if test "x${r_cv_func___setfpucw_needed}" = xyes; then 1183 AC_DEFINE(NEED___SETFPUCW, 1, 1184 [Define if your system needs __setfpucw() to control 1185 FPU rounding. 1186 This was used to control floating point precision, 1187 rounding and floating point exceptions on older Linux 1188 systems. 1189 As of GLIBC 2.1 this function is not used anymore.]) 1190fi]) 1191])# R_FUNC___SETFPUCW 1192 1193## R_FUNC_CALLOC 1194## ------------- 1195AC_DEFUN([R_FUNC_CALLOC], 1196[AC_CACHE_CHECK([for working calloc], [r_cv_func_calloc_works], 1197[AC_RUN_IFELSE([AC_LANG_SOURCE([[ 1198#include <stdlib.h> 1199int main () { 1200 int *p = calloc(0, sizeof(int)); 1201 exit(p == 0); 1202} 1203]])], 1204 [r_cv_func_calloc_works=yes], 1205 [r_cv_func_calloc_works=no], 1206 [r_cv_func_calloc_works=no])]) 1207if test "x${r_cv_func_calloc_works}" = xyes; then 1208 AC_DEFINE(HAVE_WORKING_CALLOC, 1, 1209 [Define if calloc(0) returns a null pointer.]) 1210fi 1211])# R_FUNC_CALLOC 1212 1213## R_FUNC_FINITE 1214## ------------- 1215AC_DEFUN([R_FUNC_FINITE], 1216[AC_CACHE_CHECK([for working finite], [r_cv_func_finite_works], 1217[AC_RUN_IFELSE([AC_LANG_SOURCE([[ 1218#include <math.h> 1219#include "confdefs.h" 1220int main () { 1221#ifdef HAVE_FINITE 1222 exit(finite(1./0.) | finite(0./0.) | finite(-1./0.)); 1223#else 1224 exit(1); 1225#endif 1226} 1227]])], 1228 [r_cv_func_finite_works=yes], 1229 [r_cv_func_finite_works=no], 1230 [r_cv_func_finite_works=no])]) 1231if test "x${r_cv_func_finite_works}" = xyes; then 1232 AC_DEFINE(HAVE_WORKING_FINITE, 1, 1233 [Define if finite() is correct for -Inf/NaN/Inf.]) 1234fi 1235])# R_FUNC_FINITE 1236 1237## R_FUNC_ISFINITE 1238## --------------- 1239AC_DEFUN([R_FUNC_ISFINITE], 1240[AC_CACHE_CHECK([for working isfinite], [r_cv_func_isfinite_works], 1241[AC_RUN_IFELSE([AC_LANG_SOURCE([[ 1242#include <math.h> 1243#include "confdefs.h" 1244int main () { 1245#ifdef HAVE_DECL_ISFINITE 1246 exit(isfinite(1./0.) | isfinite(0./0.) | isfinite(-1./0.)); 1247#else 1248 exit(1); 1249#endif 1250} 1251]])], 1252 [r_cv_func_isfinite_works=yes], 1253 [r_cv_func_isfinite_works=no], 1254 [r_cv_func_isfinite_works=no])]) 1255if test "x${r_cv_func_isfinite_works}" = xyes; then 1256 AC_DEFINE(HAVE_WORKING_ISFINITE, 1, 1257 [Define if isfinite() is correct for -Inf/NaN/Inf.]) 1258fi 1259])# R_FUNC_ISFINITE 1260 1261## R_FUNC_LOG 1262## ---------- 1263AC_DEFUN([R_FUNC_LOG], 1264[AC_CACHE_CHECK([for working log], [r_cv_func_log_works], 1265[AC_RUN_IFELSE([AC_LANG_SOURCE([[ 1266#include <math.h> 1267#include "confdefs.h" 1268int main () { 1269/* we require isnan as from R 2.0.0 */ 1270 exit(!(log(0.) == -1. / 0. && isnan(log(-1.)))); 1271} 1272]])], 1273 [r_cv_func_log_works=yes], 1274 [r_cv_func_log_works=no], 1275 [r_cv_func_log_works=no])]) 1276if test "x${r_cv_func_log_works}" = xyes; then 1277 AC_DEFINE(HAVE_WORKING_LOG, 1, 1278 [Define if log() is correct for 0/-1.]) 1279 RMATH_HAVE_WORKING_LOG="# define HAVE_WORKING_LOG 1" 1280else 1281 RMATH_HAVE_WORKING_LOG="# undef HAVE_WORKING_LOG" 1282fi 1283AC_SUBST(RMATH_HAVE_WORKING_LOG) 1284])# R_FUNC_LOG 1285 1286## R_FUNC_LOG1P 1287## ------------ 1288## Suggested by Nelson H. F. Beebe <beebe@math.utah.edu> to deal with 1289## inaccuracies on at least NetBSD 1.6 and OpenBSD 3.2. 1290## However, don't test all the way into denormalized x (he had k > -1074) 1291## and at x = 2^-54 (d - x)/x is around 3e-17. 1292AC_DEFUN([R_FUNC_LOG1P], 1293[AC_CACHE_CHECK([for working log1p], [r_cv_func_log1p_works], 1294[AC_RUN_IFELSE([AC_LANG_SOURCE([[ 1295#include <math.h> 1296#include "confdefs.h" 1297int main () { 1298#ifdef HAVE_LOG1P 1299 int k; 1300 double d; 1301 double x = 1.0; 1302 for(k = 0; k < 53; k++) x /= 2.0; 1303 1304 /* log(1+x) = x - (1/2)x^2 + (1/3)x^3 - (1/4)x^4 ... */ 1305 /* = x for x sufficiently small */ 1306 for(k = -54; k > -1022; --k) { 1307 x /= 2.0; 1308 if(x == 0.0) 1309 exit(0); /* OK: reached underflow limit */ 1310 d = log1p(x); 1311 if(d == 0.0) 1312 exit(1); /* ERROR: inaccurate log1p() */ 1313 /* for large k, ((1/2)x^2)/x might appear in the guard digits */ 1314 if(k < -80 && d != x) 1315 exit(1); /* ERROR: inaccurate log1p() */ 1316 } 1317 exit(0); 1318#else 1319 exit(1); 1320#endif 1321} 1322]])], 1323 [r_cv_func_log1p_works=yes], 1324 [r_cv_func_log1p_works=no], 1325 [r_cv_func_log1p_works=no])]) 1326if test "x${r_cv_func_log1p_works}" = xyes; then 1327 AC_DEFINE(HAVE_WORKING_LOG1P, 1, 1328 [Define if log1p() exists and is accurate enough.]) 1329 RMATH_HAVE_WORKING_LOG1P="# define HAVE_WORKING_LOG1P 1" 1330else 1331 RMATH_HAVE_WORKING_LOG1P="# undef HAVE_WORKING_LOG1P" 1332fi 1333AC_SUBST(RMATH_HAVE_WORKING_LOG1P) 1334])# R_FUNC_LOG1P 1335 1336## R_FUNC_STRPTIME 1337## --------------- 1338AC_DEFUN([R_FUNC_STRPTIME], 1339[AC_CACHE_CHECK([for working strptime], [r_cv_func_strptime_works], 1340[AC_RUN_IFELSE([AC_LANG_SOURCE([[ 1341#include <stdlib.h> 1342#if defined(HAVE_GLIBC2) && !defined(__USE_XOPEN) 1343#define __USE_XOPEN 1344#endif 1345#include <time.h> 1346int main () { 1347#ifdef HAVE_STRPTIME 1348 struct tm tm; 1349 char *p, *q, *p2; 1350 1351 p = strptime("1960-01-01", "%Y-%m-%d", &tm); /* works on MacOS X */ 1352 p2 =strptime("1899-01-01", "%Y-%m-%d", &tm); /* but this one does not */ 1353 q = strptime("2003-02-40", "%Y-%m-%d", &tm); 1354 exit(p == 0 || p2 == 0 || q); 1355#else 1356 exit(1); 1357#endif 1358} 1359]])], 1360 [r_cv_func_strptime_works=yes], 1361 [r_cv_func_strptime_works=no], 1362 [r_cv_func_strptime_works=no])]) 1363if test "x${r_cv_func_strptime_works}" = xyes; then 1364 AC_DEFINE(HAVE_WORKING_STRPTIME, 1, 1365 [Define if strptime() exists, validates and does not fail pre-1970.]) 1366fi 1367])# R_FUNC_STRPTIME 1368 1369## R_FUNC_FTELL 1370## ------------ 1371AC_DEFUN([R_FUNC_FTELL], 1372[AC_CACHE_CHECK([whether ftell works correctly on files opened for append], 1373 [r_cv_working_ftell], 1374[AC_RUN_IFELSE([AC_LANG_SOURCE([[ 1375#include <stdlib.h> 1376#include <stdio.h> 1377 1378main() { 1379 FILE *fp; 1380 int pos; 1381 1382 fp = fopen("testit", "wb"); 1383 fwrite("0123456789\n", 11, 1, fp); 1384 fclose(fp); 1385 fp = fopen("testit", "ab"); 1386 pos = ftell(fp); 1387 fclose(fp); 1388 unlink("testit"); 1389 exit(pos != 11); 1390} 1391]])], 1392 [r_cv_working_ftell=yes], 1393 [r_cv_working_ftell=no], 1394 [r_cv_working_ftell=no])]) 1395if test "x${r_cv_working_ftell}" = xyes; then 1396 AC_DEFINE(HAVE_WORKING_FTELL, 1, 1397 [Define if your ftell works correctly on files opened for append.]) 1398fi 1399])# R_FUNC_FTELL 1400 1401### * Headers 1402 1403## R_HEADER_SETJMP 1404## --------------- 1405AC_DEFUN([R_HEADER_SETJMP], 1406[AC_CACHE_CHECK([whether setjmp.h is POSIX.1 compatible], 1407 [r_cv_header_setjmp_posix], 1408[AC_COMPILE_IFELSE([AC_LANG_PROGRAM( 1409[[#include <setjmp.h>]], 1410[[sigjmp_buf b; 1411sigsetjmp(b, 0); 1412siglongjmp(b, 1);]])], 1413 [r_cv_header_setjmp_posix=yes], 1414 [r_cv_header_setjmp_posix=no])]) 1415AC_CHECK_DECLS([sigsetjmp, siglongjmp], , , [#include <setjmp.h>]) 1416if test "$ac_cv_have_decl_sigsetjmp" = no; then 1417 r_cv_header_setjmp_posix=no 1418fi 1419if test "$ac_cv_have_decl_siglongjmp" = no; then 1420 r_cv_header_setjmp_posix=no 1421fi 1422if test "${r_cv_header_setjmp_posix}" = yes; then 1423 AC_DEFINE(HAVE_POSIX_SETJMP, 1, 1424 [Define if you have POSIX.1 compatible sigsetjmp/siglongjmp.]) 1425fi 1426])# R_HEADER_SETJMP 1427 1428## R_HEADER_GLIBC2 1429## --------------- 1430AC_DEFUN([R_HEADER_GLIBC2], 1431[AC_CACHE_CHECK([for GNU C library with version >= 2], 1432 [r_cv_header_glibc2], 1433[AC_EGREP_CPP([yes], 1434[#include <stdio.h> 1435#if defined __GLIBC__ && __GLIBC__ >= 2 1436 yes 1437#endif 1438], 1439 [r_cv_header_glibc2=yes], 1440 [r_cv_header_glibc2=no], 1441 [r_cv_header_glibc2=no]) 1442]) 1443if test "${r_cv_header_glibc2}" = yes; then 1444 AC_DEFINE(HAVE_GLIBC2, 1, 1445 [Define if you have the GNU C library version >= 2. 1446 This is needed to fix a problem with getting the prototype 1447 of strptime().]) 1448fi 1449])# R_HEADER_GLIBC2 1450 1451### * Types 1452 1453## R_TYPE_SOCKLEN 1454## -------------- 1455AC_DEFUN([R_TYPE_SOCKLEN], 1456[AC_MSG_CHECKING([for type of socket length]) 1457AC_CACHE_VAL([r_cv_type_socklen], 1458[for t in socklen_t size_t int; do 1459 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 1460#include <stddef.h> 1461#include <sys/types.h> 1462#ifdef HAVE_SYS_SOCKET_H 1463# include <sys/socket.h> 1464#endif 1465#ifdef Win32 1466# include <winsock.h> 1467#endif 1468]], 1469[[(void)getsockopt (1, 1, 1, NULL, (${t} *)NULL)]])], 1470 [r_cv_type_socklen=${t}; break], 1471 [r_cv_type_socklen=]) 1472done]) 1473## size_t works on Windows but is unsigned and int is correct 1474case "${host_os}" in 1475 cygwin*|mingw*|windows*|winnt) 1476 r_cv_type_socklen=int 1477 ;; 1478esac 1479if test "x${r_cv_type_socklen}" = x; then 1480 warn_type_socklen="could not determine type of socket length" 1481 AC_MSG_WARN([${warn_type_socklen}]) 1482else 1483 AC_MSG_RESULT([${r_cv_type_socklen} *]) 1484fi 1485AC_DEFINE_UNQUOTED(R_SOCKLEN_T, ${r_cv_type_socklen}, 1486 [Type for socket lengths: socklen_t, sock_t, int?]) 1487])# R_TYPE_SOCKLEN 1488 1489## R_HAVE_KEYSYM 1490## ------------- 1491## Check whether X11/X.h has KeySym typedef-ed. 1492AC_DEFUN([R_TYPE_KEYSYM], 1493[AC_REQUIRE([R_X11]) 1494if test "${use_X11}" = yes; then 1495 r_save_CFLAGS="${CFLAGS}" 1496 CFLAGS="${CFLAGS} ${X_CFLAGS}" 1497 AC_CHECK_TYPE([KeySym], 1498 r_cv_type_keysym=yes, 1499 r_cv_type_keysym=no, 1500 [#include <X11/X.h>]) 1501 CFLAGS="${r_save_CFLAGS}" 1502 if test "${r_cv_type_keysym}" = yes; then 1503 AC_DEFINE(HAVE_KEYSYM, 1, 1504 [Define if you have KeySym defined in X11.]) 1505 fi 1506fi])# R_TYPE_KEYSYM 1507 1508### * System services 1509 1510## R_X11 1511## ----- 1512AC_DEFUN([R_X11], 1513[AC_PATH_XTRA # standard X11 search macro 1514if test -z "${no_x}"; then 1515 ## We force the use of -lX11 (perhaps this is not necessary?). 1516 X_LIBS="${X_LIBS} -lX11 -lXt" 1517 use_X11="yes" 1518 AC_DEFINE(HAVE_X11, 1, 1519 [Define if you have the X11 headers and libraries, and want 1520 the X11 GUI to be built.]) 1521 r_save_LIBS=${LIBS} 1522 if test "$want_utf8_support" == yes ; then 1523 LIBS="${LIBS} ${X_LIBS}" 1524 AC_CHECK_FUNCS(Xutf8DrawString Xutf8DrawImageString Xutf8LookupString \ 1525 Xutf8TextEscapement Xutf8TextExtents \ 1526 XmbDrawString XmbDrawImageString XmbLookupString \ 1527 XmbTextEscapement XmbTextExtents, , , [#include <X11.h>]) 1528 LIBS=${r_save_LIBS} 1529 fi 1530else 1531 use_X11="no" 1532 if test "x${with_x}" != "xno"; then 1533 AC_MSG_ERROR( 1534 [--with-x=yes (default) and X11 headers/libs are not available]) 1535 fi 1536fi 1537 AC_MSG_RESULT([using X11 ... ${use_X11}]) 1538])# R_X11 1539 1540# R_CHECK_FRAMEWORK(function, framework, 1541# [action-if-found], [action-if-not-found], 1542# [other-libs]) 1543# generic check for a framework, a function should be supplied to 1544# make sure the proper framework is found. 1545# default action is to set have_..._fw to yes/no and to define 1546# HAVE_..._FW if present 1547 1548AC_DEFUN([R_CHECK_FRAMEWORK], 1549[ AC_CACHE_CHECK([for $1 in $2 framework], [r_check_fw_$2], 1550 r_check_fw_save_LIBS=$LIBS 1551 r_check_fw_$2=no 1552 LIBS="-framework $2 $5 $LIBS" 1553 AC_LINK_IFELSE([AC_LANG_CALL([],[$1])], 1554 [r_check_fw_$2="-framework $2"],[]) 1555 LIBS=$r_check_fw_save_LIBS 1556 AS_IF([test "$r_check_fw_$2" != no], 1557 [m4_default([$3], [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$2_FW), 1, [Defined if framework $2 is present]) 1558 AS_TR_SH(have_$2_fw)=yes])], 1559 [m4_default([$4], AS_TR_SH(have_$2_fw)=no)]) 1560) 1561])# R_CHECK_FRAMEWORK 1562 1563## R_AQUA 1564## ------ 1565AC_DEFUN([R_AQUA], 1566[use_aqua=no 1567if test "${want_aqua}" = yes; then 1568 case "${host_os}" in 1569 darwin*) 1570 ## we can build AQUA only with CoreFoundation, otherwise 1571 ## Quartz device won't build 1572 if test "${have_CoreFoundation_fw}" = yes; then 1573 use_aqua=yes 1574 fi 1575 ;; 1576 esac 1577fi 1578if test "${use_aqua}" = yes; then 1579 AC_DEFINE(HAVE_AQUA, 1, 1580 [Define if you have the Aqua headers and libraries, 1581 and want the Aqua GUI to be built.]) 1582fi 1583])# R_AQUA 1584 1585## R_IEEE_754 1586## ---------- 1587## According to C99, isnan and isfinite are macros in math.h, 1588## but some older systems have isnan as a function (possibly as well). 1589AC_DEFUN([R_IEEE_754], 1590[AC_CHECK_FUNCS([isnan]) 1591AC_CHECK_DECLS([isfinite, isnan], , , [#include <math.h>]) 1592AC_CACHE_CHECK([whether you have IEEE 754 floating-point arithmetic], 1593 [r_cv_ieee_754], 1594[if (test "${ac_cv_func_isnan}" = yes \ 1595 || test "${ac_cv_have_decl_isnan}" = yes); then 1596 r_cv_ieee_754=yes 1597else 1598 r_cv_ieee_754=no 1599fi]) 1600if test "${r_cv_ieee_754}" = yes; then 1601 AC_DEFINE(IEEE_754, 1, 1602 [Define if you have IEEE 754 floating point arithmetic.]) 1603else 1604 AC_MSG_ERROR([IEEE 754 floating-point arithmetic is required]) 1605fi 1606])# R_IEEE_754 1607 1608## R_BSD_NETWORKING 1609## ---------------- 1610AC_DEFUN([R_BSD_NETWORKING], 1611[AC_CACHE_CHECK([for BSD networking], 1612 [r_cv_bsd_networking], 1613[if test "${ac_cv_header_netdb_h}" = yes \ 1614 && test "${ac_cv_header_netinet_in_h}" = yes \ 1615 && test "${ac_cv_header_sys_socket_h}" = yes \ 1616 && test "${ac_cv_search_connect}" != no \ 1617 && test "${ac_cv_search_gethostbyname}" != no; then 1618 r_cv_bsd_networking=yes 1619else 1620 r_cv_bsd_networking=no 1621fi]) 1622if test "${r_cv_bsd_networking}" = yes; then 1623 AC_DEFINE(HAVE_BSD_NETWORKING, 1, 1624 [Define if you have BSD networking headers and libraries.]) 1625 AC_DEFINE(HAVE_SOCKETS, 1, 1626 [Define if you have support for sockets.]) 1627 AC_DEFINE(HAVE_INTERNET, 1, 1628 [Define if you have support for ftp/http access.]) 1629 AC_DEFINE(SUPPORT_LIBXML, 1, 1630 [Define if you provide support for the libxml ftp/http 1631 functions.]) 1632fi 1633])# R_BSD_NETWORKING 1634 1635## R_BITMAPS 1636## --------- 1637## Here we only need any old -lz, and don't need zlib.h. 1638## However, we do need recent enough libpng and jpeg, and so check both 1639## the header versions and for key routines in the library. 1640## The png code will do a run-time check of the consistency of libpng 1641## versions. 1642AC_DEFUN([R_BITMAPS], 1643[BITMAP_LIBS= 1644if test "${use_jpeglib}" = yes; then 1645 _R_HEADER_JPEGLIB 1646 have_jpeg=${r_cv_header_jpeglib_h} 1647 if test "${have_jpeg}" = yes; then 1648 AC_CHECK_LIB(jpeg, jpeg_destroy_compress, 1649 [have_jpeg=yes], 1650 [have_jpeg=no], 1651 [${LIBS}]) 1652 fi 1653 if test "${have_jpeg}" = yes; then 1654 BITMAP_LIBS="-ljpeg" 1655 AC_DEFINE(HAVE_JPEG, 1, 1656 [Define if you have the JPEG headers and libraries.]) 1657 fi 1658fi 1659if test "${use_libpng}" = yes; then 1660 AC_CHECK_LIB(z, main, [have_png=yes], [have_png=no]) 1661 if test "${have_png}" = yes; then 1662 _R_HEADER_PNG 1663 have_png=${r_cv_header_png_h} 1664 fi 1665 if test "${have_png}" = yes; then 1666 AC_CHECK_LIB(png, png_create_write_struct, 1667 [have_png=yes], 1668 [have_png=no], 1669 [-lz ${LIBS}]) 1670 fi 1671 if test "${have_png}" = yes; then 1672 BITMAP_LIBS="${BITMAP_LIBS} -lpng -lz" 1673 AC_DEFINE(HAVE_PNG, 1, 1674 [Define if you have the PNG headers and libraries.]) 1675 fi 1676fi 1677AC_SUBST(BITMAP_LIBS) 1678])# R_BITMAPS 1679 1680## _R_HEADER_JPEGLIB 1681## ----------------- 1682## Set shell variable r_cv_header_jpeglib_h to 'yes' if a recent enough 1683## jpeglib.h is found, and to 'no' otherwise. 1684AC_DEFUN([_R_HEADER_JPEGLIB], 1685[AC_CACHE_CHECK([if jpeglib version >= 6b], 1686 [r_cv_header_jpeglib_h], 1687AC_EGREP_CPP([yes], 1688[#include <jpeglib.h> 1689#if (JPEG_LIB_VERSION >= 62) 1690 yes 1691#endif 1692], 1693 [r_cv_header_jpeglib_h=yes], 1694 [r_cv_header_jpeglib_h=no])) 1695])# _R_HEADER_JPEGLIB 1696 1697## _R_HEADER_PNG 1698## ------------- 1699## Set shell variable r_cv_header_png_h to 'yes' if a recent enough 1700## 'png.h' is found, and to 'no' otherwise. 1701AC_DEFUN([_R_HEADER_PNG], 1702[AC_CACHE_CHECK([if libpng version >= 1.0.5], 1703 [r_cv_header_png_h], 1704AC_EGREP_CPP([yes], 1705[#include <png.h> 1706#if (PNG_LIBPNG_VER >= 10005) 1707 yes 1708#endif 1709], 1710 [r_cv_header_png_h=yes], 1711 [r_cv_header_png_h=no])) 1712])# _R_HEADER_PNG 1713 1714## _R_PATH_TCL_CONFIG 1715## ------------------ 1716## Try finding tclConfig.sh in common library directories and their 1717## tcl$x.$y subdirectories. Set shell variable r_cv_path_TCL_CONFIG 1718## to the entire path of the script if found, and leave it empty 1719## otherwise. 1720AC_DEFUN([_R_PATH_TCL_CONFIG], 1721[AC_MSG_CHECKING([for tclConfig.sh in library (sub)directories]) 1722AC_CACHE_VAL([r_cv_path_TCL_CONFIG], 1723[for ldir in /opt/lib /sw/lib /usr/local/lib64 /usr/local/lib /usr/lib64 /usr/lib /lib64 /lib ; do 1724 for dir in \ 1725 ${ldir} \ 1726 `ls -d ${ldir}/tcl[[8-9]].[[0-9]]* 2>/dev/null | sort -r`; do 1727 if test -f ${dir}/tclConfig.sh; then 1728 r_cv_path_TCL_CONFIG="${dir}/tclConfig.sh" 1729 break 2 1730 fi 1731 done 1732done]) 1733if test -n "${r_cv_path_TCL_CONFIG}"; then 1734 AC_MSG_RESULT([${r_cv_path_TCL_CONFIG}]) 1735else 1736 AC_MSG_RESULT([no]) 1737fi 1738])# _R_PATH_TCL_CONFIG 1739 1740## _R_PATH_TK_CONFIG 1741## ------------------ 1742## Try finding tkConfig.sh in common library directories and their 1743## tk$x.$y subdirectories. Set shell variable r_cv_path_TK_CONFIG 1744## to the entire path of the script if found, and leave it empty 1745## otherwise. 1746AC_DEFUN([_R_PATH_TK_CONFIG], 1747[AC_MSG_CHECKING([for tkConfig.sh in library (sub)directories]) 1748AC_CACHE_VAL([r_cv_path_TK_CONFIG], 1749[for ldir in /opt/lib /sw/lib /usr/local/lib64 /usr/local/lib /usr/lib64 /usr/lib /lib64 /lib ; do 1750 for dir in \ 1751 ${ldir} \ 1752 `ls -d ${ldir}/tk[[8-9]].[[0-9]]* 2>/dev/null | sort -r`; do 1753 if test -f ${dir}/tkConfig.sh; then 1754 r_cv_path_TK_CONFIG="${dir}/tkConfig.sh" 1755 break 2 1756 fi 1757 done 1758done]) 1759if test -n "${r_cv_path_TK_CONFIG}"; then 1760 AC_MSG_RESULT([${r_cv_path_TK_CONFIG}]) 1761else 1762 AC_MSG_RESULT([no]) 1763fi 1764])# _R_PATH_TK_CONFIG 1765 1766## _R_TCLTK_CONFIG 1767## --------------- 1768## Try finding the tclConfig.sh and tkConfig.sh scripts in PATH as well 1769## as in common library directories and their tcl/tk subdirectories. 1770## Set shell variables TCL_CONFIG and TK_CONFIG to the entire paths to 1771## the scripts if found and check that the corresponding Tcl/Tk versions 1772## are at least 8; if not, set shell variable have_tcltk to 'no'. 1773AC_DEFUN([_R_TCLTK_CONFIG], 1774[AC_PATH_PROGS(TCL_CONFIG, [${TCL_CONFIG} tclConfig.sh]) 1775if test -z "${TCL_CONFIG}"; then 1776 _R_PATH_TCL_CONFIG 1777 if test -n "${r_cv_path_TCL_CONFIG}"; then 1778 TCL_CONFIG="${r_cv_path_TCL_CONFIG}" 1779 fi 1780fi 1781AC_PATH_PROGS(TK_CONFIG, [${TK_CONFIG} tkConfig.sh]) 1782if test -z "${TK_CONFIG}"; then 1783 _R_PATH_TK_CONFIG 1784 if test -n "${r_cv_path_TK_CONFIG}"; then 1785 TK_CONFIG="${r_cv_path_TK_CONFIG}" 1786 fi 1787fi 1788if test -z "${TCLTK_CPPFLAGS}" \ 1789 || test -z "${TCLTK_LIBS}"; then 1790 ## Check whether the versions found via the *Config.sh files are at 1791 ## least 8; otherwise, issue a warning and turn off Tcl/Tk support. 1792 ## Note that in theory a system could have outdated versions of the 1793 ## *Config.sh scripts and yet up-to-date installations of Tcl/Tk in 1794 ## standard places ... 1795 if test -n "${TCL_CONFIG}"; then 1796 . ${TCL_CONFIG} 1797 if test ${TCL_MAJOR_VERSION} -lt 8; then 1798 warn_tcltk_version="Tcl/Tk support requires Tcl version >= 8" 1799 AC_MSG_WARN([${warn_tcltk_version}]) 1800 have_tcltk=no 1801 fi 1802 fi 1803 if test -n "${TK_CONFIG}" \ 1804 && test -z "${warn_tcltk_version}"; then 1805 . ${TK_CONFIG} 1806 if test ${TK_MAJOR_VERSION} -lt 8; then 1807 warn_tcltk_version="Tcl/Tk support requires Tk version >= 8" 1808 AC_MSG_WARN([${warn_tcltk_version}]) 1809 have_tcltk=no 1810 fi 1811 fi 1812 if test -n "${TCL_CONFIG}" \ 1813 && test -n "${TK_CONFIG}" \ 1814 && test -z "${warn_tcltk_version}"; then 1815 if test ${TCL_MAJOR_VERSION} -ne ${TK_MAJOR_VERSION} \ 1816 || test ${TCL_MINOR_VERSION} -ne ${TK_MINOR_VERSION}; then 1817 warn_tcltk_version="Tcl and Tk major or minor versions disagree" 1818 AC_MSG_WARN([${warn_tcltk_version}]) 1819 have_tcltk=no 1820 fi 1821 fi 1822fi 1823])# _R_TCLTK_CONFIG 1824 1825## _R_HEADER_TCL 1826## ------------- 1827## Set shell variable 'r_cv_header_tcl_h' to 'yes' if a recent enough 1828## 'tcl.h' is found, and to 'no' otherwise. 1829AC_DEFUN([_R_HEADER_TCL], 1830[AC_CACHE_CHECK([for tcl.h], [r_cv_header_tcl_h], 1831[AC_EGREP_CPP([yes], 1832[#include <tcl.h> 1833#if (TCL_MAJOR_VERSION >= 8) 1834 yes 1835#endif 1836], 1837 [r_cv_header_tcl_h=yes], 1838 [r_cv_header_tcl_h=no])]) 1839])# _R_HEADER_TCL 1840 1841## _R_HEADER_TK 1842## ------------- 1843## Set shell variable 'r_cv_header_tk_h' to 'yes' if a recent enough 1844## 'tk.h' is found, and to 'no' otherwise. 1845AC_DEFUN([_R_HEADER_TK], 1846[AC_CACHE_CHECK([for tk.h], [r_cv_header_tk_h], 1847[AC_EGREP_CPP([yes], 1848[#include <tk.h> 1849#if (TK_MAJOR_VERSION >= 8) 1850 yes 1851#endif 1852], 1853 [r_cv_header_tk_h=yes], 1854 [r_cv_header_tk_h=no])]) 1855])# _R_HEADER_TK 1856 1857## _R_TCLTK_CPPFLAGS 1858## ----------------- 1859## Need to ensure that we can find the tcl.h and tk.h headers, which 1860## may be in non-standard and/or version-dependent directories, such as 1861## on FreeBSD systems. 1862## 1863## The logic is as follows. If TCLTK_CPPFLAGS was specified, then we 1864## do not investigate any further. Otherwise, if we still think we 1865## have Tcl/Tk, then first try via the corresponding *Config.sh file, 1866## or else try the obvious. 1867AC_DEFUN([_R_TCLTK_CPPFLAGS], 1868[AC_REQUIRE([_R_TCLTK_CONFIG]) 1869if test -z "${TCLTK_CPPFLAGS}"; then 1870 ## We have to do the work. 1871 if test "${have_tcltk}" = yes; then 1872 ## Part 1. Check for tcl.h. 1873 found_tcl_h=no 1874 if test -n "${TCL_CONFIG}"; then 1875 . ${TCL_CONFIG} 1876 ## Look for tcl.h in 1877 ## ${TCL_PREFIX}/include/tcl${TCL_VERSION} 1878 ## ${TCL_PREFIX}/include 1879 ## Also look in 1880 ## ${TCL_PREFIX}/include/tcl${TCL_VERSION}/generic 1881 ## to deal with current FreeBSD layouts. These also link the real 1882 ## thing to the version subdir, but the link cannot be used as it 1883 ## fails to include 'tclDecls.h' which is not linked. Hence we 1884 ## must look for the real thing first. Argh ... 1885 for dir in \ 1886 ${TCL_PREFIX}/include/tcl${TCL_VERSION}/generic \ 1887 ${TCL_PREFIX}/include/tcl${TCL_VERSION} \ 1888 ${TCL_PREFIX}/include; do 1889 AC_CHECK_HEADER([${dir}/tcl.h], 1890 [TCLTK_CPPFLAGS="-I${dir}" 1891 found_tcl_h=yes 1892 break]) 1893 done 1894 fi 1895 if test "${found_tcl_h}" = no; then 1896 _R_HEADER_TCL 1897 if test "${r_cv_header_tcl_h}" = yes; then 1898 found_tcl_h=yes 1899 else 1900 have_tcltk=no 1901 fi 1902 fi 1903 fi 1904 if test "${have_tcltk}" = yes; then 1905 ## Part 2. Check for tk.h. 1906 found_tk_h=no 1907 if test -n "${TK_CONFIG}"; then 1908 . ${TK_CONFIG} 1909 ## Look for tk.h in 1910 ## ${TK_PREFIX}/include/tk${TK_VERSION} 1911 ## ${TK_PREFIX}/include 1912 ## Also look in 1913 ## ${TK_PREFIX}/include/tcl${TK_VERSION} 1914 ## to compensate for Debian madness ... 1915 ## Also look in 1916 ## ${TK_PREFIX}/include/tk${TK_VERSION}/generic 1917 ## to deal with current FreeBSD layouts. See above for details. 1918 ## 1919 ## As the AC_CHECK_HEADER test tries including the header file and 1920 ## tk.h includes tcl.h and X11/Xlib.h, we need to change CPPFLAGS 1921 ## for the check. 1922 r_save_CPPFLAGS="${CPPFLAGS}" 1923 CPPFLAGS="${CPPFLAGS} ${TK_XINCLUDES} ${TCLTK_CPPFLAGS}" 1924 for dir in \ 1925 ${TK_PREFIX}/include/tk${TK_VERSION}/generic \ 1926 ${TK_PREFIX}/include/tk${TK_VERSION} \ 1927 ${TK_PREFIX}/include/tcl${TK_VERSION} \ 1928 ${TK_PREFIX}/include; do 1929 AC_CHECK_HEADER([${dir}/tk.h], 1930 [TCLTK_CPPFLAGS="${TCLTK_CPPFLAGS} -I${dir}" 1931 found_tk_h=yes 1932 break]) 1933 done 1934 CPPFLAGS="${r_save_CPPFLAGS}" 1935 fi 1936 if test "${found_tk_h}" = no; then 1937 _R_HEADER_TK 1938 if test "{r_cv_header_tk_h}" = yes; then 1939 found_tk_h=yes 1940 else 1941 have_tcltk=no 1942 fi 1943 fi 1944 fi 1945fi 1946if test "${have_tcltk}" = yes; then 1947 if test -n "${TK_XINCLUDES}"; then 1948 TCLTK_CPPFLAGS="${TCLTK_CPPFLAGS} ${TK_XINCLUDES}" 1949 else 1950 TCLTK_CPPFLAGS="${TCLTK_CPPFLAGS} ${X_CFLAGS}" 1951 fi 1952fi 1953])# _R_TCLTK_CPPFLAGS 1954 1955## _R_TCLTK_LIBS 1956## ------------- 1957## Find the tcl and tk libraries. 1958AC_DEFUN([_R_TCLTK_LIBS], 1959[AC_REQUIRE([AC_PATH_XTRA]) 1960AC_REQUIRE([_R_TCLTK_CONFIG]) 1961if test -z "${TCLTK_LIBS}"; then 1962 ## We have to do the work. 1963 if test "${have_tcltk}" = yes; then 1964 ## Part 1. Try finding the tcl library. 1965 if test -n "${TCL_CONFIG}"; then 1966 . ${TCL_CONFIG} 1967 TCLTK_LIBS="${TCL_LIB_SPEC}" 1968 else 1969 AC_CHECK_LIB(tcl, Tcl_CreateInterp, 1970 [TCLTK_LIBS=-ltcl], 1971 [have_tcltk=no]) 1972 fi 1973 fi 1974 if test "${have_tcltk}" = yes; then 1975 ## Part 2. Try finding the tk library. 1976 if test -n "${TK_CONFIG}"; then 1977 . ${TK_CONFIG} 1978 TCLTK_LIBS="${TCLTK_LIBS} ${TK_LIB_SPEC} ${TK_XLIBSW}" 1979 else 1980 AC_CHECK_LIB(tk, Tk_Init, , , [${TCLTK_LIBS}]) 1981 if test "${ac_cv_lib_tk_Tk_Init}" = no; then 1982 ## Grr, simple -ltk does not work. 1983 ## But maybe we simply need to add X11 libs. 1984 ## Note that we cannot simply repeat the above test with extra 1985 ## libs, because AC_CHECK_LIB uses the corresponding cache var 1986 ## (ac_cv_lib_tk_Tk_Init in our case) if set. As using unset 1987 ## is not portable shell programming according to the Autoconf 1988 ## docs, we use Tk_SafeInit in the test with X11 libs added. 1989 AC_CHECK_LIB(tk, Tk_SafeInit, 1990 [TCLTK_LIBS="${TCLTK_LIBS} -ltk ${X_LIBS}"], 1991 [have_tcltk=no], 1992 [${TCLTK_LIBS} ${X_LIBS}]) 1993 fi 1994 fi 1995 fi 1996 ## Postprocessing for AIX. 1997 ## On AIX, the *_LIB_SPEC variables need to contain '-bI:' flags for 1998 ## the Tcl export file. These are really flags for ld rather than the 1999 ## C/C++ compilers, and hence may need protection via '-Wl,'. 2000 ## We have two ways of doing that: 2001 ## * Recording whether '-Wl,' is needed for the C or C++ compilers, 2002 ## and getting this info into the TCLTK_LIBS make variable ... mess! 2003 ## * Protecting all entries in TCLTK_LIBS that do not start with '-l' 2004 ## or '-L' with '-Wl,' (hoping that all compilers understand this). 2005 ## Easy, hence ... 2006 case "${host_os}" in 2007 aix*) 2008 orig_TCLTK_LIBS="${TCLTK_LIBS}" 2009 TCLTK_LIBS= 2010 for flag in ${orig_TCLTK_LIBS}; do 2011 case "${flag}" in 2012 -l*|-L*|-Wl,*) ;; 2013 *) flag="-Wl,${flag}" ;; 2014 esac 2015 TCLTK_LIBS="${TCLTK_LIBS} ${flag}" 2016 done 2017 ;; 2018 esac 2019 ## Force evaluation ('-ltcl8.3${TCL_DBGX}' and friends ...). 2020 eval "TCLTK_LIBS=\"${TCLTK_LIBS}\"" 2021fi 2022])# _R_TCLTK_LIBS 2023 2024## _R_TCLTK_WORKS 2025## -------------- 2026## Check whether compiling and linking code using Tcl/Tk works. 2027## Set shell variable r_cv_tcltk_works to 'yes' or 'no' accordingly. 2028AC_DEFUN([_R_TCLTK_WORKS], 2029[AC_CACHE_CHECK([whether compiling/linking Tcl/Tk code works], 2030 [r_cv_tcltk_works], 2031[AC_LANG_PUSH(C) 2032r_save_CPPFLAGS="${CPPFLAGS}" 2033r_save_LIBS="${LIBS}" 2034CPPFLAGS="${CPPFLAGS} ${TCLTK_CPPFLAGS}" 2035LIBS="${LIBS} ${TCLTK_LIBS}" 2036AC_LINK_IFELSE([AC_LANG_PROGRAM( 2037[[#include <tcl.h> 2038#include <tk.h> 2039]], 2040[[static char * p1 = (char *) Tcl_Init; 2041static char * p2 = (char *) Tk_Init; 2042]])], 2043r_cv_tcltk_works=yes, 2044r_cv_tcltk_works=no) 2045CPPFLAGS="${r_save_CPPFLAGS}" 2046LIBS="${r_save_LIBS}" 2047AC_LANG_POP(C)]) 2048])# _R_TCLTK_WORKS 2049 2050## R_TCLTK 2051## ------- 2052AC_DEFUN([R_TCLTK], 2053[if test "${want_tcltk}" = yes; then 2054 have_tcltk=yes 2055 ## (Note that the subsequent 3 macros assume that have_tcltk has been 2056 ## set appropriately.) 2057 _R_TCLTK_CONFIG 2058 _R_TCLTK_CPPFLAGS 2059 _R_TCLTK_LIBS 2060 if test "${have_tcltk}" = yes; then 2061 _R_TCLTK_WORKS 2062 have_tcltk=${r_cv_tcltk_works} 2063 fi 2064else 2065 have_tcltk=no 2066 ## Just making sure. 2067 TCLTK_CPPFLAGS= 2068 TCLTK_LIBS= 2069fi 2070if test "${have_tcltk}" = yes; then 2071 AC_DEFINE(HAVE_TCLTK, 1, 2072 [Define if you have the Tcl/Tk headers and libraries and 2073 want Tcl/Tk support to be built.]) 2074 use_tcltk=yes 2075else 2076 use_tcltk=no 2077fi 2078AC_SUBST(TCLTK_CPPFLAGS) 2079AC_SUBST(TCLTK_LIBS) 2080AC_SUBST(use_tcltk) 2081])# R_TCLTK 2082 2083## R_BLAS_LIBS 2084## ----------- 2085## Look for a library that implements the BLAS linear-algebra interface 2086## (see http://www.netlib.org/blas/). On success, sets BLAS_LIBS to the 2087## requisite library linkages. 2088## 2089## This is based on ACX_BLAS by Steven G. Johnson <stevenj@alum.mit.edu> 2090## from the Official Autoconf Macro Archive 2091## (http://www.gnu.org/software/ac-archive/htmldoc/acx_blas.m4), 2092## with the following changes: 2093## * We also handle HPUX .sl command line specifications. 2094## * We explictly deal with the case of f2c. Most likely pointless. 2095## * We only care about the Fortran 77 interface to Atlas, hence do not 2096## test for -lcblas. 2097## * We do not use BLAS libs that caused problems in the past: Alpha 2098## CXML and DXML, and SGI SCSL and SGIMATH (marked with COMMENT tags). 2099## * As we link with $BLAS_LIBS $FLIBS $LIBS (in that order), we use the 2100## same order in the tests. 2101## * We do not use ACTION-IF-FOUND and ACTION-IF-NOT-FOUND. 2102## The sunperf test calls the library as now required. 2103## Based on acx_blas.m4 version 1.2 (2001-12-13) 2104AC_DEFUN([R_BLAS_LIBS], 2105[AC_REQUIRE([R_PROG_F77_FLIBS]) 2106AC_REQUIRE([R_PROG_F77_APPEND_UNDERSCORE]) 2107 2108acx_blas_ok=no 2109case "${with_blas}" in 2110 yes | "") ;; 2111 no) acx_blas_ok=disable ;; 2112 -* | */* | *.a | *.so | *.so.* | *.sl | *.sl.* | *.o) 2113 BLAS_LIBS="${with_blas}" 2114 ;; 2115 *) BLAS_LIBS="-l${with_blas}" ;; 2116esac 2117 2118if test "${r_cv_prog_f77_append_underscore}" = yes; then 2119 dgemm=dgemm_ 2120 sgemm=sgemm_ 2121 xerbla=xerbla_ 2122else 2123 dgemm=dgemm 2124 sgemm=sgemm 2125 xerbla=xerbla 2126fi 2127 2128acx_blas_save_LIBS="${LIBS}" 2129LIBS="${FLIBS} ${LIBS}" 2130 2131## First, check BLAS_LIBS environment variable 2132if test "${acx_blas_ok}" = no; then 2133 if test "x${BLAS_LIBS}" != x; then 2134 r_save_LIBS="${LIBS}"; LIBS="${BLAS_LIBS} ${LIBS}" 2135 AC_MSG_CHECKING([for ${dgemm} in ${BLAS_LIBS}]) 2136 AC_TRY_LINK([void ${xerbla}(char *srname, int *info){}], ${dgemm}(), 2137 [acx_blas_ok=yes], [BLAS_LIBS=""]) 2138 AC_MSG_RESULT([${acx_blas_ok}]) 2139 LIBS="${r_save_LIBS}" 2140 fi 2141fi 2142 2143## BLAS linked to by default? (happens on some supercomputers) 2144if test "${acx_blas_ok}" = no; then 2145 AC_CHECK_FUNC(${dgemm}, [acx_blas_ok=yes]) 2146fi 2147 2148## BLAS in ATLAS library? (http://math-atlas.sourceforge.net/) 2149if test "${acx_blas_ok}" = no; then 2150 AC_CHECK_LIB(atlas, ATL_xerbla, 2151 [AC_CHECK_LIB(f77blas, ${dgemm}, 2152 [acx_blas_ok=yes 2153 BLAS_LIBS="-lf77blas -latlas"], 2154 [], [-latlas])]) 2155fi 2156 2157## BLAS in PhiPACK libraries? (requires generic BLAS lib, too) 2158if test "${acx_blas_ok}" = no; then 2159 AC_CHECK_LIB(blas, ${dgemm}, 2160 [AC_CHECK_LIB(dgemm, $dgemm, 2161 [AC_CHECK_LIB(sgemm, ${sgemm}, 2162 [acx_blas_ok=yes 2163 BLAS_LIBS="-lsgemm -ldgemm -lblas"], 2164 [], [-lblas])], 2165 [], [-lblas])]) 2166fi 2167 2168## <COMMENT> 2169## ## BLAS in Alpha CXML library? 2170## if test "${acx_blas_ok}" = no; then 2171## AC_CHECK_LIB(cxml, ${sgemm}, 2172## [acx_blas_ok=yes; BLAS_LIBS="-lcxml"]) 2173## fi 2174## </COMMENT> 2175 2176## <COMMENT> 2177## # BLAS in Alpha DXML library? (now called CXML, see above) 2178## if test "${acx_blas_ok}" = no; then 2179## AC_CHECK_LIB(dxml, ${sgemm}, 2180## [acx_blas_ok=yes; BLAS_LIBS="-ldxml"]) 2181## fi 2182## </COMMENT> 2183 2184## BLAS in Sun Performance library? 2185## Some versions require -xlic_lib=sunperf: -lsunperf will not work 2186## Not sure whether -lsunmath is required, but it helps anyway 2187if test "${acx_blas_ok}" = no; then 2188 if test "x$GCC" != xyes; then # only works with Sun CC 2189 AC_MSG_CHECKING([for ${dgemm} in -lsunperf]) 2190 r_save_LIBS="${LIBS}" 2191 LIBS="-xlic_lib=sunperf -lsunmath ${LIBS}" 2192 AC_TRY_LINK_FUNC([${dgemm}], [R_sunperf=yes], [R_sunperf=no]) 2193 if test "${R_sunperf}" = yes; then 2194 BLAS_LIBS="-xlic_lib=sunperf -lsunmath" 2195 acx_blas_ok=yes 2196 fi 2197 LIBS="${r_save_LIBS}" 2198 AC_MSG_RESULT([${acx_blas_ok}]) 2199 fi 2200fi 2201 2202## <COMMENT> 2203## ## BLAS in SCSL library? (SGI/Cray Scientific Library) 2204## if test "${acx_blas_ok}" = no; then 2205## AC_CHECK_LIB(scs, ${sgemm}, 2206## [acx_blas_ok=yes; BLAS_LIBS="-lscs"]) 2207## fi 2208## </COMMENT> 2209 2210## <COMMENT> 2211## ## BLAS in SGIMATH library? 2212## if test "${acx_blas_ok}" = no; then 2213## AC_CHECK_LIB(complib.sgimath, ${sgemm}, 2214## [acx_blas_ok=yes; BLAS_LIBS="-lcomplib.sgimath"]) 2215## fi 2216## </COMMENT> 2217 2218## BLAS in IBM ESSL library? (requires generic BLAS lib, too) 2219if test "${acx_blas_ok}" = no; then 2220 AC_CHECK_LIB(blas, ${dgemm}, 2221 [AC_CHECK_LIB(essl, ${dgemm}, 2222 [acx_blas_ok=yes 2223 BLAS_LIBS="-lessl -lblas"], 2224 [], [-lblas ${FLIBS}])]) 2225fi 2226 2227## Generic BLAS library? 2228if test "${acx_blas_ok}" = no; then 2229 AC_CHECK_LIB(blas, ${dgemm}, 2230 [acx_blas_ok=yes; BLAS_LIBS="-lblas"]) 2231fi 2232 2233## Now check if zdotu works (fails on AMD64 with the wrong compiler; 2234## also fails on OS X with vecLib and gfortran; but in that case we 2235## have a work-around using USE_VECLIB_G95FIX) 2236if test "${acx_blas_ok}" = yes; then 2237 AC_MSG_CHECKING([whether double complex BLAS can be used]) 2238 AC_CACHE_VAL([r_cv_zdotu_is_usable], 2239 [cat > conftestf.f <<EOF 2240c Goto's BLAS at least needs a XERBLA 2241 subroutine xerbla(srname, info) 2242 character*6 srname 2243 integer info 2244 end 2245 2246 subroutine test1(iflag) 2247 double complex zx(2), ztemp, zres, zdotu 2248 integer iflag 2249 zx(1) = (3.1d0,1.7d0) 2250 zx(2) = (1.6d0,-0.6d0) 2251 zres = zdotu(2, zx, 1, zx, 1) 2252 ztemp = (0.0d0,0.0d0) 2253 do 10 i = 1,2 2254 10 ztemp = ztemp + zx(i)*zx(i) 2255 if(abs(zres - ztemp) > 1.0d-10) then 2256 iflag = 1 2257 else 2258 iflag = 0 2259 endif 2260 end 2261EOF 2262${F77} ${FFLAGS} -c conftestf.f 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD 2263## Yes we need to double quote this ... 2264[cat > conftest.c <<EOF 2265#include <stdlib.h> 2266#include "confdefs.h" 2267#ifdef HAVE_F77_UNDERSCORE 2268# define F77_SYMBOL(x) x ## _ 2269#else 2270# define F77_SYMBOL(x) x 2271#endif 2272extern void F77_SYMBOL(test1)(int *iflag); 2273 2274int main () { 2275 int iflag; 2276 F77_SYMBOL(test1)(&iflag); 2277 exit(iflag); 2278} 2279EOF] 2280if ${CC} ${CFLAGS} -c conftest.c 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then 2281 ## <NOTE> 2282 ## This should really use MAIN_LD, and hence come after this is 2283 ## determined (and necessary additions to MAIN_LDFLAGS were made). 2284 ## But it seems that we currently can always use the C compiler. 2285 ## Also, to be defensive there should be a similar test with SHLIB_LD 2286 ## and SHLIB_LDFLAGS (and note that on HPUX with native cc we have to 2287 ## use ld for SHLIB_LD) ... 2288 if ${CC} ${LDFLAGS} ${MAIN_LDFLAGS} -o conftest${ac_exeext} \ 2289 conftest.${ac_objext} conftestf.${ac_objext} ${FLIBS} \ 2290 ${LIBM} ${BLAS_LIBS} 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; 2291 ## </NOTE> 2292 then 2293 ## redirect error messages to config.log 2294 output=`./conftest${ac_exeext} 2>&AS_MESSAGE_LOG_FD` 2295 if test ${?} = 0; then 2296 r_cv_zdotu_is_usable=yes 2297 fi 2298 fi 2299fi 2300]) 2301 rm -rf conftest conftest.* conftestf.* core 2302 if test -n "${r_cv_zdotu_is_usable}"; then 2303 AC_MSG_RESULT([yes]) 2304 else 2305 AC_MSG_RESULT([no]) 2306 if test "${have_vecLib_fw}" = "yes"; then 2307 ## for vecLib we have a work-around by using cblas_..._sub 2308 use_veclib_g95fix=yes 2309 ## The fix may not work with internal lapack, because 2310 ## the lapack dylib won't have the fixed functions. 2311 ## those are available to the lapack module only. 2312 # use_lapack=yes 2313 # with_lapack="" 2314 else 2315 BLAS_LIBS= 2316 acx_blas_ok="no" 2317 fi 2318 fi 2319fi 2320if test "${acx_blas_ok}" = yes; then 2321 AC_MSG_CHECKING([whether the BLAS is complete]) 2322 AC_CACHE_VAL([r_cv_complete_blas], 2323[[cat > conftest.c <<EOF 2324#include <stdlib.h> 2325#include "confdefs.h" 2326#ifdef HAVE_F77_UNDERSCORE 2327# define F77_SYMBOL(x) x ## _ 2328#else 2329# define F77_SYMBOL(x) x 2330#endif 2331void F77_SYMBOL(xerbla)(char *srname, int *info) 2332{} 2333void blas_set () { 2334 F77_SYMBOL(dasum)(); 2335 F77_SYMBOL(daxpy)(); 2336 F77_SYMBOL(dcopy)(); 2337 F77_SYMBOL(ddot)(); 2338 F77_SYMBOL(dgbmv)(); 2339 F77_SYMBOL(dgemm)(); 2340 F77_SYMBOL(dgemv)(); 2341 F77_SYMBOL(dger)(); 2342 F77_SYMBOL(dnrm2)(); 2343 F77_SYMBOL(drot)(); 2344 F77_SYMBOL(drotg)(); 2345 F77_SYMBOL(drotm)(); 2346 F77_SYMBOL(drotmg)(); 2347 F77_SYMBOL(dsbmv)(); 2348 F77_SYMBOL(dscal)(); 2349 F77_SYMBOL(dspmv)(); 2350 F77_SYMBOL(dspr)(); 2351 F77_SYMBOL(dspr2)(); 2352 F77_SYMBOL(dspmv)(); 2353 F77_SYMBOL(dsymm)(); 2354 F77_SYMBOL(dsymv)(); 2355 F77_SYMBOL(dsyr)(); 2356 F77_SYMBOL(dsyr2)(); 2357 F77_SYMBOL(dsyr2k)(); 2358 F77_SYMBOL(dsyrk)(); 2359 F77_SYMBOL(dtbmv)(); 2360 F77_SYMBOL(dtrsm)(); 2361 F77_SYMBOL(idamax)(); 2362 /* F77_SYMBOL(lsame)(); */ 2363 F77_SYMBOL(dcabs1)(); 2364 F77_SYMBOL(dgemv)(); 2365 F77_SYMBOL(dger)(); 2366 F77_SYMBOL(dsymv)(); 2367 F77_SYMBOL(dsyr2)(); 2368 F77_SYMBOL(dsyr2k)(); 2369 F77_SYMBOL(dsyrk)(); 2370 F77_SYMBOL(dtbmv)(); 2371 F77_SYMBOL(dtbsv)(); 2372 F77_SYMBOL(dtpmv)(); 2373 F77_SYMBOL(dtpsv)(); 2374 F77_SYMBOL(dtrmm)(); 2375 F77_SYMBOL(dtrmv)(); 2376 F77_SYMBOL(dtrsv)(); 2377 F77_SYMBOL(dtrsm)(); 2378 F77_SYMBOL(dtrsv)(); 2379/* cmplblas */ 2380 F77_SYMBOL(dzasum)(); 2381 F77_SYMBOL(dznrm2)(); 2382 F77_SYMBOL(izamax)(); 2383 F77_SYMBOL(zaxpy)(); 2384 F77_SYMBOL(zcopy)(); 2385 F77_SYMBOL(zdotc)(); 2386 F77_SYMBOL(zdotu)(); 2387 F77_SYMBOL(zdrot)(); 2388 F77_SYMBOL(zdscal)(); 2389 F77_SYMBOL(zgbmv)(); 2390 F77_SYMBOL(zgemm)(); 2391 F77_SYMBOL(zgemv)(); 2392 F77_SYMBOL(zgerc)(); 2393 F77_SYMBOL(zgeru)(); 2394 F77_SYMBOL(zhbmv)(); 2395 F77_SYMBOL(zhemm)(); 2396 F77_SYMBOL(zhemv)(); 2397 F77_SYMBOL(zher)(); 2398 F77_SYMBOL(zherk)(); 2399 F77_SYMBOL(zher2)(); 2400 F77_SYMBOL(zher2k)(); 2401 F77_SYMBOL(zhpmv)(); 2402 F77_SYMBOL(zhpr)(); 2403 F77_SYMBOL(zhpr2)(); 2404 F77_SYMBOL(zrotg)(); 2405 F77_SYMBOL(zscal)(); 2406 F77_SYMBOL(zswap)(); 2407 F77_SYMBOL(zsymm)(); 2408 F77_SYMBOL(zsyr2k)(); 2409 F77_SYMBOL(zsyrk)(); 2410 F77_SYMBOL(ztbmv)(); 2411 F77_SYMBOL(ztbsv)(); 2412 F77_SYMBOL(ztpmv)(); 2413 F77_SYMBOL(ztpsv)(); 2414 F77_SYMBOL(ztrmm)(); 2415 F77_SYMBOL(ztrmv)(); 2416 F77_SYMBOL(ztrsm)(); 2417 F77_SYMBOL(ztrsv)(); 2418} 2419int main () 2420{ 2421 exit(0); 2422} 2423EOF] 2424if ${CC} ${CFLAGS} -c conftest.c 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then 2425 ## <NOTE> 2426 ## This should really use MAIN_LD, and hence come after this is 2427 ## determined (and necessary additions to MAIN_LDFLAGS were made). 2428 ## But it seems that we currently can always use the C compiler. 2429 ## Also, to be defensive there should be a similar test with SHLIB_LD 2430 ## and SHLIB_LDFLAGS (and note that on HPUX with native cc we have to 2431 ## use ld for SHLIB_LD) ... 2432 if ${CC} ${LDFLAGS} ${MAIN_LDFLAGS} -o conftest${ac_exeext} \ 2433 conftest.${ac_objext} ${FLIBS} \ 2434 ${LIBM} ${BLAS_LIBS} 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; 2435 ## </NOTE> 2436 then 2437 r_cv_complete_blas=yes 2438 fi 2439fi 2440]) 2441 if test x"${r_cv_complete_blas}" != xyes; then 2442 acx_blas_ok="no" 2443 r_cv_complete_blas=no 2444 BLAS_LIBS="" 2445 fi 2446 AC_MSG_RESULT([${r_cv_complete_blas}]) 2447fi 2448 2449LIBS="${acx_blas_save_LIBS}" 2450 2451AC_SUBST(BLAS_LIBS) 2452])# R_BLAS_LIBS 2453 2454## R_LAPACK_LIBS 2455## ------------- 2456## Look for a library that implements LAPACK (see 2457## http://www.netlib.org/lapack/). On success, sets LAPACK_LIBS to the 2458## requisite library linkages. Only used by the lapack module at 2459## present. 2460## 2461## This is roughly based on ACX_LAPACK by Steven G. Johnson 2462## <stevenj@alum.mit.edu> from the Official Autoconf Macro Archive 2463## (http://www.gnu.org/software/ac-archive/htmldoc/acx_lapack.m4), 2464## with the following changes: 2465## * We also handle HPUX .sl command line specifications. 2466## * We explictly deal with the case of f2c. Most likely pointless. 2467## * We test for a LAPACK_LIBS environment variable after checking 2468## whether LAPACK is already linked (see below). 2469## * We do not test for the generic lapack_rs6k library (why not?). 2470## * As we link with $LAPACK_LIBS $BLAS_LIBS $FLIBS $LIBS (in that 2471## order), we use the same order in the tests. 2472## * We do not use ACTION-IF-FOUND and ACTION-IF-NOT-FOUND. 2473## Note that Debian ATLAS has LAPACK libs in /usr/lib/atlas (or $arch 2474## variants) which should be used if ATLAS is used for BLAS, and not 2475## found at configure time but used at run time ... 2476## Note also that (see R-admin) that our main intention is to allow a 2477## LAPACK-containing BLAS to be used ... there are too many slow or 2478## broken LAPACKs out there. 2479## Based on acx_lapack.m4 version 1.3 (2002-03-12). 2480 2481AC_DEFUN([R_LAPACK_LIBS], 2482[AC_REQUIRE([R_PROG_F77_FLIBS]) 2483AC_REQUIRE([R_PROG_F77_APPEND_UNDERSCORE]) 2484AC_REQUIRE([R_BLAS_LIBS]) 2485 2486acx_lapack_ok=no 2487case "${with_lapack}" in 2488 yes | "") ;; 2489 no) acx_lapack_ok=disable ;; 2490 -* | */* | *.a | *.so | *.so.* | *.sl | *.sl.* | *.o) 2491 LAPACK_LIBS="${with_lapack}" 2492 ;; 2493 *) LAPACK_LIBS="-l${with_lapack}" ;; 2494esac 2495 2496if test "${r_cv_prog_f77_append_underscore}" = yes; then 2497 zgeev=zgeev_ 2498else 2499 zgeev=zgeev 2500fi 2501 2502# We cannot use LAPACK if BLAS is not found 2503if test "x${acx_blas_ok}" != xyes; then 2504 acx_lapack_ok=noblas 2505fi 2506 2507acx_lapack_save_LIBS="${LIBS}" 2508LIBS="${BLAS_LIBS} ${FLIBS} ${LIBS}" 2509 2510## LAPACK linked to by default? (Could be in the BLAS libs.) 2511if test "${acx_lapack_ok}" = no; then 2512 AC_CHECK_FUNC(${zgeev}, [acx_lapack_ok=yes]) 2513fi 2514 2515## Next, check LAPACK_LIBS environment variable 2516if test "${acx_lapack_ok}" = no; then 2517 if test "x${LAPACK_LIBS}" != x; then 2518 r_save_LIBS="${LIBS}"; LIBS="${LAPACK_LIBS} ${LIBS}" 2519 AC_MSG_CHECKING([for ${zgeev} in ${LAPACK_LIBS}]) 2520 AC_TRY_LINK_FUNC(${zgeev}, [acx_lapack_ok=yes], [LAPACK_LIBS=""]) 2521 AC_MSG_RESULT([${acx_lapack_ok}]) 2522 LIBS="${r_save_LIBS}" 2523 fi 2524fi 2525 2526## LAPACK in Sun Performance library? 2527## No longer test here as will be picked up by the default test. 2528 2529## Generic LAPACK library? 2530if test "${acx_lapack_ok}" = no; then 2531 AC_CHECK_LIB(lapack, ${zgeev}, 2532 [acx_lapack_ok=yes; LAPACK_LIBS="-llapack"]) 2533fi 2534 2535LIBS="${acx_lapack_save_LIBS}" 2536 2537AC_SUBST(LAPACK_LIBS) 2538])# R_LAPACK_LIBS 2539 2540## R_XDR 2541## ----- 2542## Try finding XDR library functions and headers. 2543## FreeBSD in particular needs rpc/types.h before rpc/xdr.h. 2544AC_DEFUN([R_XDR], 2545[AC_CHECK_HEADER(rpc/types.h) 2546if test "${ac_cv_header_rpc_types_h}" = yes ; then 2547 AC_CHECK_HEADER(rpc/xdr.h, , , [#include <rpc/types.h>]) 2548fi 2549AC_CACHE_CHECK([for XDR support], 2550 [r_cv_xdr], 2551[if test "${ac_cv_header_rpc_types_h}" = yes \ 2552 && test "${ac_cv_header_rpc_xdr_h}" = yes \ 2553 && test "${ac_cv_search_xdr_string}" != no ; then 2554 r_cv_xdr=yes 2555else 2556 r_cv_xdr=no 2557fi 2558]) 2559AM_CONDITIONAL(BUILD_XDR, [test "x${r_cv_xdr}" = xno]) 2560])# R_XDR 2561 2562## R_ZLIB 2563## ------ 2564## Try finding zlib library and headers. 2565## We check that both are installed, and that the header >= 1.2.1 2566## and that gzeof is in the library (which suggests the library 2567## is also recent enough). 2568AC_DEFUN([R_ZLIB], 2569[if test "x${use_system_zlib}" = xyes; then 2570 AC_CHECK_LIB(z, gzeof, [have_zlib=yes], [have_zlib=no]) 2571 if test "${have_zlib}" = yes; then 2572 AC_CHECK_HEADER(zlib.h, [have_zlib=yes], [have_zlib=no]) 2573 fi 2574 if test "${have_zlib}" = yes; then 2575 _R_HEADER_ZLIB 2576 have_zlib=${r_cv_header_zlib_h} 2577 fi 2578else 2579 have_zlib="no" 2580fi 2581AC_MSG_CHECKING([whether zlib support needs to be compiled]) 2582if test "${have_zlib}" = yes; then 2583 AC_MSG_RESULT([no]) 2584 LIBS="-lz ${LIBS}" 2585else 2586 AC_MSG_RESULT([yes]) 2587 _R_ZLIB_MMAP 2588fi 2589AM_CONDITIONAL(BUILD_ZLIB, [test "x${have_zlib}" = xno]) 2590AM_CONDITIONAL(USE_MMAP_ZLIB, 2591[test "x${have_zlib}" = xno && test "x${r_cv_zlib_mmap}" = xyes]) 2592])# R_ZLIB 2593 2594## _R_HEADER_ZLIB 2595## -------------- 2596## Set shell variable r_cv_header_zlib_h to 'yes' if a recent enough 2597## zlib.h is found, and to 'no' otherwise. 2598AC_DEFUN([_R_HEADER_ZLIB], 2599[AC_CACHE_CHECK([if zlib version >= 1.2.1], 2600 [r_cv_header_zlib_h], 2601[AC_RUN_IFELSE([AC_LANG_SOURCE([[ 2602#include <string.h> 2603#include <zlib.h> 2604int main() { 2605#ifdef ZLIB_VERSION 2606 exit(strcmp(ZLIB_VERSION, "1.2.1") < 0); 2607#else 2608 exit(1); 2609#endif 2610} 2611]])], 2612 [r_cv_header_zlib_h=yes], 2613 [r_cv_header_zlib_h=no], 2614 [r_cv_header_zlib_h=no])]) 2615])# _R_HEADER_ZLIB 2616 2617## _R_ZLIB_MMAP 2618## ------------ 2619AC_DEFUN([_R_ZLIB_MMAP], 2620[AC_CACHE_CHECK([mmap support for zlib], 2621 [r_cv_zlib_mmap], 2622[AC_RUN_IFELSE([AC_LANG_SOURCE([[ 2623#include <sys/types.h> 2624#include <sys/mman.h> 2625#include <sys/stat.h> 2626caddr_t hello() { 2627 exit(mmap((caddr_t)0, (off_t)0, PROT_READ, MAP_SHARED, 0, (off_t)0)); 2628} 2629]])], 2630 [r_cv_zlib_mmap=no], 2631 [r_cv_zlib_mmap=yes], 2632 [r_cv_zlib_mmap=yes])]) 2633])# _R_ZLIB_MMAP 2634 2635## R_PCRE 2636## ------ 2637## Try finding pcre library and headers. 2638## RedHat puts the headers in /usr/include/pcre. 2639AC_DEFUN([R_PCRE], 2640[if test "x${use_system_pcre}" = xyes; then 2641 AC_CHECK_LIB(pcre, pcre_fullinfo, [have_pcre=yes], [have_pcre=no]) 2642 if test "${have_pcre}" = yes; then 2643 AC_CHECK_HEADERS(pcre.h pcre/pcre.h) 2644 if test "${ac_cv_header_pcre_h}" = no \ 2645 && test "${ac_cv_header_pcre_pcre_h}" = no; then 2646 have_pcre=no 2647 fi 2648 fi 2649else 2650 have_pcre=no 2651fi 2652if test "x${have_pcre}" = xyes; then 2653AC_CACHE_CHECK([if PCRE version >= 4.0], [r_have_pcre4], 2654[AC_RUN_IFELSE([AC_LANG_SOURCE([[ 2655#ifdef HAVE_PCRE_PCRE_H 2656#include <pcre/pcre.h> 2657#else 2658#ifdef HAVE_PCRE_H 2659#include <pcre.h> 2660#endif 2661#endif 2662int main() { 2663#ifdef PCRE_MAJOR 2664 exit(PCRE_MAJOR<4); 2665#else 2666 exit(1); 2667#endif 2668} 2669]])], [r_have_pcre4=yes], [r_have_pcre4=no], [r_have_pcre4=no])]) 2670fi 2671if test "x${r_have_pcre4}" = xyes; then 2672 LIBS="-lpcre ${LIBS}" 2673fi 2674AC_MSG_CHECKING([whether PCRE support needs to be compiled]) 2675if test "x${r_have_pcre4}" = xyes; then 2676 AC_MSG_RESULT([no]) 2677else 2678 AC_MSG_RESULT([yes]) 2679fi 2680AM_CONDITIONAL(BUILD_PCRE, [test "x${r_have_pcre4}" != xyes]) 2681])# R_PCRE 2682 2683## R_BZLIB 2684## ------- 2685## Try finding bzlib library and headers. 2686## We check that both are installed, 2687## and that BZ2_bzlibVersion is in the library. 2688AC_DEFUN([R_BZLIB], 2689[if test "x${use_system_bzlib}" = xyes; then 2690 AC_CHECK_LIB(bz2, BZ2_bzlibVersion, [have_bzlib=yes], [have_bzlib=no]) 2691 if test "${have_bzlib}" = yes; then 2692 AC_CHECK_HEADER(bzlib.h, [have_bzlib=yes], [have_bzlib=no]) 2693 fi 2694else 2695 have_bzlib=no 2696fi 2697AC_MSG_CHECKING([whether bzip2 support needs to be compiled]) 2698if test "x${have_bzlib}" = xyes; then 2699 AC_MSG_RESULT([no]) 2700 LIBS="-lbz2 ${LIBS}" 2701else 2702 AC_MSG_RESULT([yes]) 2703fi 2704AM_CONDITIONAL(BUILD_BZLIB, [test "x${have_bzlib}" = xno]) 2705])# R_BZLIB 2706 2707## R_SYS_POSIX_LEAPSECONDS 2708## ----------------------- 2709## See if your system time functions do not count leap seconds, as 2710## required by POSIX. 2711AC_DEFUN([R_SYS_POSIX_LEAPSECONDS], 2712[AC_CACHE_CHECK([whether leap seconds are treated according to POSIX], 2713 [r_cv_sys_posix_leapseconds], 2714[AC_RUN_IFELSE([AC_LANG_SOURCE([[ 2715#include <stdlib.h> 2716#include <time.h> 2717#include <stdio.h> 2718#include "confdefs.h" 2719 2720int main () { 2721 struct tm *tm; 2722 time_t ct = 0; /* required on 64bit AIX */ 2723 2724 ctime(&ct); 2725 ct = ct - (ct % 60); 2726 tm = gmtime(&ct); 2727 if(tm->tm_sec == 0) exit(1); else exit(0); 2728} 2729]])], 2730 [r_cv_sys_posix_leapseconds=no], 2731 [r_cv_sys_posix_leapseconds=yes], 2732 [r_cv_sys_posix_leapseconds=yes])]) 2733if test "x${r_cv_sys_posix_leapseconds}" = xyes; then 2734 AC_DEFINE(HAVE_POSIX_LEAPSECONDS, 1, 2735 [Define if your system time functions do not count leap 2736 seconds, as required by POSIX.]) 2737fi 2738])# R_SYS_POSIX_LEAPSECONDS 2739 2740### * Miscellaneous 2741 2742## R_RECOMMENDED_PACKAGES 2743## ---------------------- 2744## See if the sources for the recommended packages are available. 2745AC_DEFUN([R_RECOMMENDED_PACKAGES], 2746[AC_CACHE_CHECK([for recommended packages], 2747 [r_cv_misc_recommended_packages], 2748[r_cv_misc_recommended_packages=yes 2749recommended_pkgs=`grep '^R_PKGS_RECOMMENDED_SOURCES *=' \ 2750 ${srcdir}/share/make/vars.mk | sed 's/.*=//'` 2751for pkg in ${recommended_pkgs}; do 2752 n_pkg=`ls ${srcdir}/src/library/Recommended/${pkg}_*.tar.gz | wc -l` 2753 if test ${n_pkg} -ne 1; then 2754 r_cv_misc_recommended_packages=no 2755 break 2756 fi 2757done]) 2758use_recommended_packages=${r_cv_misc_recommended_packages} 2759if test "x${r_cv_misc_recommended_packages}" = xno; then 2760 AC_MSG_ERROR([Some of the recommended packages are missing 2761 Use --without-recommended-packages if this was intentional]) 2762fi 2763])# R_RECOMMENDED_PACKAGES 2764 2765## R_SIZE_MAX 2766## ---------- 2767## Look for a definition of SIZE_MAX (the maximum of size_t). 2768## C99 has it declared in <inttypes.h>, glibc in <stdint.h> 2769## and Solaris 8 in <limits.h>! 2770## autoconf tests for inttypes.h and stdint.h by default 2771AC_DEFUN([R_SIZE_MAX], 2772[AC_CACHE_CHECK([whether SIZE_MAX is declared], 2773 [r_cv_size_max], 2774[AC_RUN_IFELSE([AC_LANG_SOURCE([[ 2775#include <stdlib.h> 2776#ifdef HAVE_INTTYPES_H 2777# include <inttypes.h> 2778#endif 2779#ifdef HAVE_STDINT_H 2780# include <stdint.h> 2781#endif 2782#ifdef HAVE_LIMITS_H 2783# include <limits.h> 2784#endif 2785 2786int 2787main() { 2788#ifndef SIZE_MAX 2789 char *p = (char *) SIZE_MAX; 2790#endif 2791 2792 ; 2793 return 0; 2794} 2795]])], 2796 [r_cv_size_max=yes], 2797 [r_cv_size_max=no], 2798 [r_cv_size_max=no])]) 2799if test "x${r_cv_size_max}" = xyes; then 2800 AC_DEFINE(HAVE_DECL_SIZE_MAX, 1, 2801 [Define to 1 if you have the declaration of `SIZE_MAX', and to 0 if you don't.]) 2802fi 2803])# R_SIZE_MAX 2804 2805 2806## R_ICONV 2807## ------- 2808## Look for iconv, possibly in libiconv. 2809## Need to include <iconv.h> as this may define iconv as a macro. 2810## libiconv, e.g. on MacOS X, has iconv as a macro and needs -liconv. 2811AC_DEFUN([R_ICONV], 2812[AC_CHECK_HEADERS(iconv.h) 2813## need to ignore cache for this as it may set LIBS 2814unset ac_cv_func_iconv 2815AC_CACHE_CHECK(for iconv, ac_cv_func_iconv, [ 2816 ac_cv_func_iconv="no" 2817 AC_TRY_LINK([#include <stdlib.h> 2818#ifdef HAVE_ICONV_H 2819#include <iconv.h> 2820#endif], 2821 [iconv_t cd = iconv_open("",""); 2822 iconv(cd,NULL,NULL,NULL,NULL); 2823 iconv_close(cd);], 2824 ac_cv_func_iconv=yes) 2825 if test "$ac_cv_func_iconv" != yes; then 2826 r_save_LIBS="$LIBS" 2827 LIBS="$LIBS -liconv" 2828 AC_TRY_LINK([#include <stdlib.h> 2829#ifdef HAVE_ICONV_H 2830#include <iconv.h> 2831#endif], 2832 [iconv_t cd = iconv_open("",""); 2833 iconv(cd,NULL,NULL,NULL,NULL); 2834 iconv_close(cd);], 2835 ac_cv_func_iconv="in libiconv") 2836 if test "$ac_cv_func_iconv" = no; then 2837 LIBS="$r_save_LIBS" 2838 fi 2839 fi 2840]) 2841if test "$ac_cv_func_iconv" != no; then 2842 AC_DEFINE(HAVE_ICONV, 1, [Define if you have the `iconv' function.]) 2843 2844 AC_CACHE_CHECK([whether iconv() accepts "UTF-8", "latin1" and "UCS-*"], 2845 [r_cv_iconv_latin1], 2846 [AC_RUN_IFELSE([AC_LANG_SOURCE([[ 2847#include "confdefs.h" 2848#include <stdlib.h> 2849#ifdef HAVE_ICONV_H 2850#include <iconv.h> 2851#endif 2852 2853int main () { 2854 iconv_t cd; 2855 cd = iconv_open("latin1","UTF-8"); 2856 if(cd == (iconv_t)(-1)) exit(1); 2857 iconv_close(cd); 2858 cd = iconv_open("UTF-8","latin1"); 2859 if(cd == (iconv_t)(-1)) exit(1); 2860 iconv_close(cd); 2861 cd = iconv_open("","latin1"); 2862 if(cd == (iconv_t)(-1)) exit(1); 2863 iconv_close(cd); 2864 cd = iconv_open("","UTF-8"); 2865 if(cd == (iconv_t)(-1)) exit(1); 2866 iconv_close(cd); 2867 cd = iconv_open("latin1", ""); 2868 if(cd == (iconv_t)(-1)) exit(1); 2869 iconv_close(cd); 2870 cd = iconv_open("UTF-8",""); 2871 if(cd == (iconv_t)(-1)) exit(1); 2872 iconv_close(cd); 2873 cd = iconv_open("UCS-2LE",""); 2874 if(cd == (iconv_t)(-1)) exit(1); 2875 iconv_close(cd); 2876 cd = iconv_open("", "UCS-2LE"); 2877 if(cd == (iconv_t)(-1)) exit(1); 2878 iconv_close(cd); 2879 cd = iconv_open("UCS-2BE",""); 2880 if(cd == (iconv_t)(-1)) exit(1); 2881 iconv_close(cd); 2882 cd = iconv_open("", "UCS-2BE"); 2883 if(cd == (iconv_t)(-1)) exit(1); 2884 iconv_close(cd); 2885 cd = iconv_open("UCS-4LE",""); 2886 if(cd == (iconv_t)(-1)) exit(1); 2887 iconv_close(cd); 2888 cd = iconv_open("", "UCS-4LE"); 2889 if(cd == (iconv_t)(-1)) exit(1); 2890 iconv_close(cd); 2891 cd = iconv_open("UCS-4BE",""); 2892 if(cd == (iconv_t)(-1)) exit(1); 2893 iconv_close(cd); 2894 cd = iconv_open("", "UCS-4BE"); 2895 if(cd == (iconv_t)(-1)) exit(1); 2896 iconv_close(cd); 2897 exit(0); 2898} 2899 ]])], [r_cv_iconv_latin1=yes], [r_cv_iconv_latin1=no], 2900 [r_cv_iconv_latin1=no])]) 2901 2902 if test "$r_cv_iconv_latin1" = yes; then 2903 AC_DEFINE(ICONV_LATIN1, 1, 2904 [Define if `iconv' accepts "UTF-8", "latin1" and "UCS-*".]) 2905 fi 2906fi 2907## if the iconv we are using was in libiconv we have already included -liconv 2908AC_CACHE_CHECK(for iconvlist, ac_cv_func_iconvlist, [ 2909 ac_cv_func_iconvlist="no" 2910 AC_TRY_LINK([#include <stdlib.h> 2911#ifdef HAVE_ICONV_H 2912#include <iconv.h> 2913#endif 2914static int count_one (unsigned int namescount, char * *names, void *data) 2915{return 0;}], 2916 [iconvlist(count_one, NULL);], 2917 ac_cv_func_iconvlist=yes) 2918 ]) 2919if test "$ac_cv_func_iconvlist" = yes; then 2920 AC_DEFINE(HAVE_ICONVLIST, 1, [Define if you have the `iconvlist' function.]) 2921fi 2922])# R_ICONV 2923 2924 2925## R_MBCS 2926## ------------- 2927## locales - support for MBCS and specifically UTF-8 2928AC_DEFUN([R_MBCS], 2929[ 2930## require functional iconv 2931if test "$want_mbcs_support" = yes ; then 2932 if test "$r_cv_iconv_latin1" != yes ; then 2933 want_mbcs_support=no 2934 fi 2935fi 2936## Wide character support -- first test for headers (which are assumed in code) 2937if test "$want_mbcs_support" = yes ; then 2938 AC_CHECK_HEADERS(wchar.h wctype.h) 2939 for ac_header in wchar wctype; do 2940 as_ac_var=`echo "ac_cv_header_${ac_header}_h"` 2941 this=`eval echo '${'$as_ac_var'}'` 2942 if test "x$this" = xno; then 2943 want_mbcs_support=no 2944 fi 2945 done 2946fi 2947if test "$want_mbcs_support" = yes ; then 2948## Solaris 8 is missing iswblank, but we can make it from iswctype. 2949 R_CHECK_FUNCS([mbrtowc wcrtomb wcscoll wcsftime], [#include <wchar.h>]) 2950 R_CHECK_FUNCS([mbstowcs wcstombs], [#include <stdlib.h>]) 2951 R_CHECK_FUNCS([wctrans iswblank wctype iswctype], [#include <wctype.h>]) 2952 for ac_func in mbrtowc mbstowcs wcrtomb wcscoll wcsftime wcstombs \ 2953 wctrans wctype iswctype 2954 do 2955 as_ac_var=`echo "ac_cv_func_$ac_func"` 2956 this=`eval echo '${'$as_ac_var'}'` 2957 if test "x$this" = xno; then 2958 want_mbcs_support=no 2959 fi 2960 done 2961fi 2962## it seems IRIX has wctrans but not wctrans_t: we check this when we 2963## know we have the headers and wctrans(). 2964if test "$want_mbcs_support" = yes ; then 2965 AC_CHECK_TYPES([wctrans_t], , , [#include <wchar.h> 2966 #include <wctype.h>]) 2967 if test $ac_cv_type_wctrans_t != yes; then 2968 want_mbcs_support=no 2969 fi 2970fi 2971if test "x${want_mbcs_support}" = xyes; then 2972AC_DEFINE(SUPPORT_UTF8, 1, [Define this to enable support for UTF-8 locales.]) 2973AC_SUBST(SUPPORT_UTF8) 2974AC_DEFINE(SUPPORT_MBCS, 1, [Define this to enable support for MBCS locales.]) 2975AC_SUBST(SUPPORT_MBCS) 2976fi 2977])# R_MBCS 2978 2979 2980## R_C99_COMPLEX 2981## ------------- 2982## C99 complex 2983AC_DEFUN([R_C99_COMPLEX], 2984[ 2985 AC_CACHE_CHECK([whether C99 double complex is supported], 2986 [r_cv_c99_complex], 2987[ AC_MSG_RESULT([]) 2988 AC_CHECK_HEADER(complex.h, [r_cv_c99_complex="yes"], [r_cv_c99_complex="no"]) 2989 if test "${r_cv_c99_complex}" = "yes"; then 2990 AC_CHECK_TYPE([double complex], , r_cv_c99_complex=no, 2991 [#include <complex.h>]) 2992 fi 2993 if test "${r_cv_c99_complex}" = "yes"; then 2994 for ac_func in cexp clog csqrt cpow ccos csin ctan cacos casin catan \ 2995 ccosh csinh ctanh cacosh casinh catanh 2996 do 2997 R_CHECK_DECL($ac_func, , [r_cv_c99_complex=no], [#include<complex.h>]) dnl 2998 done 2999 fi 3000 dnl Now check if the representation is the same as Rcomplex 3001 if test "${r_cv_c99_complex}" = "yes"; then 3002 AC_MSG_CHECKING([whether C99 double complex is compatible with Rcomplex]) 3003AC_RUN_IFELSE([AC_LANG_SOURCE([[ 3004#include "confdefs.h" 3005#include <complex.h> 3006#include <stdlib.h> 3007typedef struct { 3008 double r; 3009 double i; 3010} Rcomplex; 3011 3012void set_it(Rcomplex *z) 3013{ 3014 z[0].r = 3.14159265; 3015 z[0].i = 2.172; 3016 z[1].i = 3.14159265; 3017 z[1].r = 2.172; 3018 z[2].r = 123.456; 3019 z[2].i = 0.123456; 3020} 3021int main () { 3022 double complex z[3]; 3023 3024 set_it(z); 3025 if(cabs(z[2] - 123.456 - 0.123456 * _Complex_I) < 1e-4) exit(0); 3026 else exit(1); 3027} 3028]])], [r_c99_complex=yes], [r_c99_complex=no], [r_c99_complex=no]) 3029 AC_MSG_RESULT(${r_c99_complex}) 3030 r_cv_c99_complex=${r_c99_complex} 3031 fi 3032]) 3033if test "${r_cv_c99_complex}" = "yes"; then 3034AC_DEFINE(HAVE_C99_COMPLEX, 1, [Define this if you have support for C99 complex types.]) 3035AC_SUBST(HAVE_C99_COMPLEX) 3036fi 3037])# R_COMPLEX 3038 3039## R_CHECK_DECL(SYMBOL, 3040## [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], 3041## [INCLUDES = DEFAULT-INCLUDES]) 3042## ------------------------------------------------------- 3043## Check if SYMBOL (a variable or a function) is declared. 3044AC_DEFUN([R_CHECK_DECL], 3045[AS_VAR_PUSHDEF([ac_Symbol], [ac_cv_have_decl_$1]) dnl 3046AC_CACHE_CHECK([whether $1 exists and is declared], ac_Symbol, 3047[AC_LINK_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])], 3048[#ifndef $1 3049 char *p = (char *) $1; 3050#endif 3051])], 3052 [AS_VAR_SET(ac_Symbol, yes)], 3053 [AS_VAR_SET(ac_Symbol, no)])]) 3054AS_IF([test AS_VAR_GET(ac_Symbol) = yes], [$2], [$3])[] dnl 3055AS_VAR_POPDEF([ac_Symbol]) dnl 3056])# R_CHECK_DECL 3057 3058## R_CHECK_FUNCS(SYMBOLS, 3059## [INCLUDES = DEFAULT-INCLUDES]) 3060## -------------------------------------------------------- 3061## Defines HAVE_SYMBOL if declared. SYMBOLS is an m4 list. 3062AC_DEFUN([R_CHECK_FUNCS], 3063[AC_FOREACH([AC_Func], [$1], 3064 [AH_TEMPLATE(AS_TR_CPP([HAVE_]AC_Func), 3065 [Define to 1 if you have the `]AC_Func[' function.])]) dnl 3066for ac_func in $1 3067do 3068R_CHECK_DECL($ac_func, 3069 [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$ac_func]), 1)], , [$2]) dnl 3070done 3071])# R_CHECK_FUNCS 3072 3073## R_GCC4_VISIBILITY 3074## Sets up suitable macros for visibility attributes in gcc4/gfortran 3075AC_DEFUN([R_GCC4_VISIBILITY], 3076[AC_CACHE_CHECK([whether __attribute__((visibility())) is supported], 3077 [r_cv_visibility_attribute], 3078[cat > conftest.c <<EOF 3079int foo __attribute__ ((visibility ("hidden"))) = 1; 3080int bar __attribute__ ((visibility ("default"))) = 1; 3081EOF 3082r_cv_visibility_attribute=no 3083if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then 3084 if grep '\.hidden.*foo' conftest.s >/dev/null; then 3085 r_cv_visibility_attribute=yes 3086 fi 3087fi 3088rm -f conftest.[cs] 3089]) 3090if test $r_cv_visibility_attribute = yes; then 3091 AC_DEFINE(HAVE_VISIBILITY_ATTRIBUTE, 1, 3092 [Define to 1 if __attribute__((visibility())) is supported]) 3093fi 3094## test if visibility flag is accepted: NB Solaris compilers do and ignore, 3095## so only make use of this if HAVE_VISIBILITY_ATTRIBUTE is true. 3096r_save_CFLAGS=$CFLAGS 3097CFLAGS="$CFLAGS -fvisibility=hidden" 3098AC_CACHE_CHECK(whether $CC accepts -fvisibility, r_cv_prog_cc_vis, 3099 [_AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], 3100 [r_cv_prog_cc_vis=yes], [r_cv_prog_cc_vis=no])]) 3101CFLAGS=$r_save_CFLAGS 3102if test "${r_cv_prog_cc_vis}" = yes; then 3103 if test "${r_cv_visibility_attribute}" = yes; then 3104 C_VISIBILITY="-fvisibility=hidden" 3105 fi 3106fi 3107## Need to exclude Intel compilers, where this does not work. 3108## The flag is documented, and is effective but also hides 3109## unsatisfied references. We cannot test for GCC, as icc passes that test. 3110case "${CC}" in 3111 ## Intel compiler 3112 *icc) 3113 C_VISIBILITY= 3114 ;; 3115esac 3116AC_SUBST(C_VISIBILITY) 3117AC_LANG_PUSH(Fortran 77) 3118r_save_FFLAGS=$FFLAGS 3119FFLAGS="$FFLAGS -fvisibility=hidden" 3120AC_CACHE_CHECK(whether $F77 accepts -fvisibility, r_cv_prog_f77_vis, 3121 [_AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], 3122 [r_cv_prog_f77_vis=yes], [r_cv_prog_f77_vis=no])]) 3123FFLAGS=$r_save_FFLAGS 3124AC_LANG_POP(Fortran 77) 3125if test "${r_cv_prog_f77_vis}" = yes; then 3126 if test "${r_cv_visibility_attribute}" = yes; then 3127 F77_VISIBILITY="-fvisibility=hidden" 3128 fi 3129fi 3130## need to exclude Intel compilers. 3131case "${F77}" in 3132 ## Intel compiler 3133 *ifc|*ifort) 3134 F77_VISIBILITY= 3135 ;; 3136esac 3137AC_SUBST(F77_VISIBILITY) 3138])# R_GCC4_VISIBILITY 3139 3140 3141 3142### Local variables: *** 3143### mode: outline-minor *** 3144### outline-regexp: "### [*]+" *** 3145### End: *** 3146