/
R.m4
3678 lines (3488 loc) · 111 KB
/
R.m4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
### R.m4 -- extra macros for configuring R -*- Autoconf -*-
###
### Copyright (C) 1998-2006 R Core Team
###
### This file is part of R.
###
### R is free software; you can redistribute it and/or modify it under
### the terms of the GNU General Public License as published by the Free
### Software Foundation; either version 2 of the License, or (at your
### option) any later version.
###
### R is distributed in the hope that it will be useful, but WITHOUT ANY
### WARRANTY; without even the implied warranty of MERCHANTABILITY or
### FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
### License for more details.
###
### You should have received a copy of the GNU General Public License
### along with R; if not, a copy is available at
### http://www.r-project.org/Licenses/
### * General support macros
## R_ARG_USE
## ---------
AC_DEFUN([R_ARG_USE],
[if test "${withval}" = no; then
use_$1=no
else
use_$1=yes
fi
])# R_ARG_USE
## R_ARG_USE_SYSTEM
## ----------------
AC_DEFUN([R_ARG_USE_SYSTEM],
[if test "${withval}" = no; then
use_system_$1=no
else
use_system_$1=yes
fi
])# R_ARG_USE_SYSTEM
## R_SH_VAR_ADD(VARIABLE, VALUE, [SEPARATOR = " "])
## ------------------------------------------------
## Set sh variable VARIABLE to VALUE if empty (or undefined), or append
## VALUE to the value of VARIABLE, separated by SEPARATOR.
## Currently, safe only if all arguments are literals.
## Useful mostly when we do not know whether VARIABLE is empty or not.
## Should maybe also have a fourth argument to control whether adding
## happens by appending (default) or prepending ...
AC_DEFUN([R_SH_VAR_ADD],
[separator="$3"
test -z "${separator}" && separator=" "
if test -z "${[$1]}"; then
$1="$2"
else
$1="${[$1]}${separator}$2"
fi])# R_SH_VAR_ADD
## R_MISSING_PROG(NAME, PROGRAM)
## -----------------------------
## Simplified variant of AM_MISSING_PROG.
## Set NAME to PROGRAM if this is found and works (in the sense of
## properly implementing --version, or to an appropriate invocation
## if the missing script otherwise.
AC_DEFUN([R_MISSING_PROG],
[AC_MSG_CHECKING([for working $2])
if ($2 --version) < /dev/null > /dev/null 2>&1; then
$1=$2
AC_MSG_RESULT([found])
else
$1="\$(SHELL) \$(top_srcdir)/tools/missing $2"
AC_MSG_RESULT([missing])
fi
AC_SUBST($1)
])# R_MISSING_PROG
### * Programs
## R_PROG_AR
## ---------
AC_DEFUN([R_PROG_AR],
[AC_CHECK_PROGS(AR, [${AR} ar])
: ${ARFLAGS="rc"}
AC_SUBST(ARFLAGS)
])# R_PROG_AR
## R_PROG_INSTALL
## --------------
## Find a good install program.
## We like to provide INSTALL in the top-level Makeconf.
## Hence, if AC_PROG_INSTALL ends up with the 'tools/install-sh' script,
## we need to ensure a relative path (i.e., in case we build in srcdir)
## gets prefixed by top_srcdir. (This would not be necessary if we had
## '@INSTALL@' in each Makefile.in, but we prefer to share ...)
AC_DEFUN([R_PROG_INSTALL],
[AC_REQUIRE([AC_PROG_INSTALL])
case "${INSTALL}" in
[[\\/]]* | ?:[[\\/]]* ) # absolute
;;
*)
INSTALL="\$\(top_srcdir\)/tools/install-sh -c"
;;
esac
case "${host_os}" in
hpux*)
## On some versions of HP-UX (seen on both 10.20 and 11.0) we end up
## a broken install (seen in /opt/imake/bin) which has the default
## permissions wrong (PR#2091). Let's just always use install-sh on
## HP-UX.
INSTALL="\$\(top_srcdir\)/tools/install-sh -c"
;;
esac
])# R_PROG_INSTALL
## R_PROG_PAGER
## ------------
AC_DEFUN([R_PROG_PAGER],
[AC_PATH_PROGS(PAGER, [${PAGER} less more page pg], false)
if test "${PAGER}" = false; then
warn_pager="I could not determine a pager"
AC_MSG_WARN([${warn_pager}])
fi
])# R_PROG_PAGER
## R_PROG_PERL
## -----------
AC_DEFUN([R_PROG_PERL],
[AC_PATH_PROGS(PERL, [${PERL} perl])
if test -n "${PERL}"; then
_R_PROG_PERL_VERSION
fi
if test "${r_cv_prog_perl_v5}" != yes; then
AC_MSG_ERROR([Building R requires Perl >= 5.8.0])
fi
])# R_PROG_PERL
## _R_PROG_PERL_VERSION
## --------------------
## Building the R documentation system (Rdconv and friends) requires
## Perl version 5.8.0 or better.
## Set shell variable r_cv_prog_perl_v5 to 'yes' if a recent enough
## Perl is found, and to 'no' otherwise.
AC_DEFUN([_R_PROG_PERL_VERSION],
[AC_CACHE_CHECK([whether perl version is at least 5.8.0],
[r_cv_prog_perl_v5],
[if ${PERL} -e 'require 5.8.0 or exit 1'; then
r_cv_prog_perl_v5=yes
else
r_cv_prog_perl_v5=no
fi])
])# _R_PROG_PERL_VERSION
## R_PROG_TEXMF
## ------------
AC_DEFUN([R_PROG_TEXMF],
[AC_REQUIRE([R_PROG_PERL])
AC_PATH_PROGS(DVIPS, [${DVIPS} dvips], false)
AC_PATH_PROGS(TEX, [${TEX} tex], false)
AC_PATH_PROGS(LATEX, [${LATEX} latex], false)
if test -z "${ac_cv_path_TEX}" ; then
warn_dvi="you cannot build DVI versions of the R manuals"
elif test -z "${ac_cv_path_LATEX}"; then
warn_dvi="you cannot build DVI versions of all the help pages"
fi
if test -n "${warn_dvi}"; then
AC_MSG_WARN([${warn_dvi}])
fi
AC_PATH_PROGS(MAKEINDEX, [${MAKEINDEX} makeindex], false)
AC_PATH_PROGS(PDFTEX, [${PDFTEX} pdftex], false)
AC_PATH_PROGS(PDFLATEX, [${PDFLATEX} pdflatex], false)
if test -z "${ac_cv_path_PDFTEX}" ; then
warn_pdf="you cannot build PDF versions of the R manuals"
elif test -z "${ac_cv_path_PDFLATEX}" ; then
warn_pdf="you cannot build PDF versions of all the help pages"
fi
if test -n "${warn_pdf}"; then
AC_MSG_WARN([${warn_pdf}])
fi
R_PROG_MAKEINFO
AC_PATH_PROGS(TEXI2DVI, [${TEXI2DVI} texi2dvi], false)
## This test admittedly looks a bit strange ... see R_PROG_PERL.
if test "${PERL}" = "${FALSE}"; then
AC_PATH_PROGS(INSTALL_INFO, [${INSTALL_INFO} install-info], false)
else
INSTALL_INFO="\$(PERL) \$(top_srcdir)/tools/install-info.pl"
AC_SUBST(INSTALL_INFO)
fi
: ${R_RD4DVI="ae"}
AC_SUBST(R_RD4DVI)
: ${R_RD4PDF="times,hyper"}
AC_SUBST(R_RD4PDF)
])# R_PROG_TEXMF
## R_PROG_MAKEINFO
## ---------------
AC_DEFUN([R_PROG_MAKEINFO],
[AC_PATH_PROGS(MAKEINFO, [${MAKEINFO} makeinfo])
if test -n "${MAKEINFO}"; then
_R_PROG_MAKEINFO_VERSION
fi
if test "${r_cv_prog_makeinfo_v4}" != yes; then
warn_info="you cannot build info or HTML versions of the R manuals"
AC_MSG_WARN([${warn_info}])
MAKEINFO=false
else
MAKEINFO="${MAKEINFO}"
fi
])# R_PROG_MAKEINFO
## _R_PROG_MAKEINFO_VERSION
## ------------------------
## Building the R Texinfo manuals requires Makeinfo v4.7 or better.
## Set shell variable r_cv_prog_makeinfo_v4 to 'yes' if a recent
## enough Makeinfo is found, and to 'no' otherwise.
## If you change the minimum version here, also change it in
## doc/manual/Makefile.in and doc/manual/R-admin.texi.
AC_DEFUN([_R_PROG_MAKEINFO_VERSION],
[AC_CACHE_CHECK([whether makeinfo version is at least 4.7],
[r_cv_prog_makeinfo_v4],
[makeinfo_version=`${MAKEINFO} --version | \
grep "^makeinfo" | sed 's/[[^)]]*) \(.*\)/\1/'`
makeinfo_version_maj=`echo ${makeinfo_version} | cut -f1 -d.`
makeinfo_version_min=`echo ${makeinfo_version} | \
cut -f2 -d. | tr -dc '0123456789.' `
if test -z "${makeinfo_version_maj}" \
|| test -z "${makeinfo_version_min}"; then
r_cv_prog_makeinfo_v4=no
elif test ${makeinfo_version_maj} -lt 4 \
|| test ${makeinfo_version_min} -lt 7; then
r_cv_prog_makeinfo_v4=no
else
r_cv_prog_makeinfo_v4=yes
fi])
])# _R_PROG_MAKEINFO_VERSION
## R_PROG_BROWSER
## --------------
## xdg-open is the freedesktop.org interface to kfmclient/gnome-open
AC_DEFUN([R_PROG_BROWSER],
[if test -z "${R_BROWSER}"; then
AC_PATH_PROGS(R_BROWSER, [firefox mozilla galeon opera xdg-open kfmclient gnome-moz-remote open])
fi
if test -z "${R_BROWSER}"; then
warn_browser="I could not determine a browser"
AC_MSG_WARN([${warn_browser}])
else
AC_MSG_RESULT([using default browser ... ${R_BROWSER}])
fi
AC_SUBST(R_BROWSER)
])# R_BROWSER
## R_PROG_PDFVIEWER
## ----------------
## Try to determine a PDF viewer.
## According to Jeff Gentry <jgentry@jimmy.harvard.edu>, 'acroread4' is
## the FreeBSD acroread port.
AC_DEFUN([R_PROG_PDFVIEWER],
[AC_PATH_PROGS(R_PDFVIEWER,
[${R_PDFVIEWER} acroread acroread4 evince xpdf gv gnome-gv ggv kghostview open gpdf])
if test -z "${R_PDFVIEWER}"; then
warn_pdfviewer="I could not determine a PDF viewer"
AC_MSG_WARN([${warn_pdfviewer}])
fi
AC_SUBST(R_PDFVIEWER)
])# R_PDFVIEWER
### * C compiler and its characteristics.
## R_PROG_CPP_CPPFLAGS
## -------------------
## In case of gcc, check whether the C preprocessor complains about
## having '/usr/local/include' in its header search path (no matter how
## it came there). GCC 3.1 and 3.2 (at least) give warnings about
## 'changing search order for system directory "/usr/local/include" as
## it has already been specified as a non-system directory' which are at
## least quite annoying.
## <NOTE>
## We currently do not distinguish whether '/usr/local/include' was
## added as the R default, or by an explicit CPPFLAGS arg to configure.
## If we wanted to, we should change
## : ${CPPFLAGS="-I/usr/local/include"}
## in 'configure.ac' by something like
## : ${CPPFLAGS=${r_default_CPPFLAGS="-I/usr/local/include"}}
## and test whether r_default_CPPFLAGS is non-empty.
## </NOTE>
AC_DEFUN([R_PROG_CPP_CPPFLAGS],
[AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AC_PROG_CPP])
if test "${GCC}" = yes; then
AC_LANG_PUSH(C)
AC_LANG_CONFTEST([AC_LANG_PROGRAM()])
if ${CPP} ${CPPFLAGS} conftest.${ac_ext} 2>&1 1>/dev/null | \
grep 'warning:.*system directory.*/usr/local/include' >/dev/null; then
CPPFLAGS=`echo ${CPPFLAGS} | \
sed 's|\(.*\)-I/usr/local/include *\(.*\)|\1\2|'`
fi
rm -f conftest.${ac_ext}
AC_LANG_POP(C)
fi])# R_PROG_CPP_CPPFLAGS
## R_PROG_CC_VERSION
## -----------------
## Determine the version of the C compiler (currently only for gcc).
AC_DEFUN([R_PROG_CC_VERSION],
[AC_REQUIRE([AC_PROG_CC])
CC_VERSION=
if test "${GCC}" = yes; then
CC_VERSION=`${CC} -v 2>&1 | grep "^.*g.. version" | \
sed -e 's/^.*g.. version *//'`
fi])# R_PROG_CC_VERSION
## R_PROG_CC_M
## -----------
## Check whether we can figure out C Make dependencies.
AC_DEFUN([R_PROG_CC_M],
[AC_REQUIRE([R_PROG_CC_VERSION])
AC_MSG_CHECKING([whether we can compute C Make dependencies])
AC_CACHE_VAL([r_cv_prog_cc_m],
[echo "#include <math.h>" > conftest.c
## No real point in using AC_LANG_* and ${ac_ext}, as we need to create
## hard-wired suffix rules.
## Another obvious candidate to try is '${MAKEDEPEND-makedepend} -f-'.
## However, this does not work out of the box when srcdir and builddir
## are different, as it creates dependencies of the form
## ${srcdir}/foo.o: /path/to/bar.h
## Could be made to work, of course ...
## Note also that it does not create a 'conftest.o: conftest.c' line.
## For gcc 3.2 or better, we want to use '-MM' in case this works.
cc_minus_MM=false
if test "${GCC}" = yes; then
case "${CC_VERSION}" in
1.*|2.*|3.[[01]]*) ;;
*) cc_minus_MM="${CC} -MM" ;;
esac
fi
for prog in "${cc_minus_MM}" "${CC} -M" "${CPP} -M" "cpp -M"; do
if ${prog} conftest.c 2>/dev/null | \
grep 'conftest.o: conftest.c' >/dev/null; then
r_cv_prog_cc_m="${prog}"
break
fi
done])
if test -z "${r_cv_prog_cc_m}"; then
AC_MSG_RESULT([no])
else
AC_MSG_RESULT([yes, using ${r_cv_prog_cc_m}])
fi
])# R_PROG_CC_M
## R_PROG_CC_C_O_LO
## ----------------
## Check whether the C compiler supports '-c -o FILE.lo'.
AC_DEFUN([R_PROG_CC_C_O_LO],
[AC_CACHE_CHECK([whether ${CC} supports -c -o FILE.lo],
[r_cv_prog_cc_c_o_lo],
[test -d TMP || mkdir TMP
echo "int some_variable = 0;" > conftest.c
## No real point in using AC_LANG_* and ${ac_ext}, as we need to create
## hard-wired suffix rules.
ac_try='${CC} ${CFLAGS} -c conftest.c -o TMP/conftest.lo 1>&AS_MESSAGE_LOG_FD'
if AC_TRY_EVAL(ac_try) \
&& test -f TMP/conftest.lo \
&& AC_TRY_EVAL(ac_try); then
r_cv_prog_cc_c_o_lo=yes
else
r_cv_prog_cc_c_o_lo=no
fi
rm -rf conftest* TMP])
])# R_PROG_CC_C_O_LO
## R_PROG_CC_MAKEFRAG
## ------------------
## Generate a Make fragment with suffix rules for the C compiler.
## Used for both building R (Makeconf) and add-ons (etc/Makeconf).
AC_DEFUN([R_PROG_CC_MAKEFRAG],
[r_cc_rules_frag=Makefrag.cc
AC_REQUIRE([R_PROG_CC_M])
cat << \EOF > ${r_cc_rules_frag}
.c.o:
$(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c $< -o $[@]
EOF
if test -n "${r_cv_prog_cc_m}"; then
cat << EOF >> ${r_cc_rules_frag}
.c.d:
@echo "making \$[@] from \$<"
@${r_cv_prog_cc_m} \$(ALL_CPPFLAGS) $< > \$[@]
EOF
else
cat << \EOF >> ${r_cc_rules_frag}
.c.d:
@echo > $[@]
EOF
fi
AC_SUBST_FILE(r_cc_rules_frag)
])# R_PROG_CC_MAKEFRAG
## R_PROG_CC_LO_MAKEFRAG
## ---------------------
## Generate a Make fragment with suffix rules for the C compiler.
## Used for both building R (Makeconf) and add-ons (etc/Makeconf).
## Need to make .lo files in src/nmath/standalone only
## NB test -d .libs || mkdir .libs can be run more than once
## and hence race when a parallel make is used
AC_DEFUN([R_PROG_CC_LO_MAKEFRAG],
[r_cc_lo_rules_frag=Makefrag.cc_lo
AC_REQUIRE([R_PROG_CC_C_O_LO])
if test "${r_cv_prog_cc_c_o_lo}" = yes; then
cat << \EOF > ${r_cc_lo_rules_frag}
.c.lo:
$(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS_LO) -c $< -o $[@]
EOF
else
cat << \EOF > ${r_cc_lo_rules_frag}
.c.lo:
@-test -d .libs || mkdir .libs
$(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS_LO) -c $< -o .libs/$[*].o
mv .libs/$[*].o $[*].lo
EOF
fi
AC_SUBST_FILE(r_cc_lo_rules_frag)
])# R_PROG_CC_LO_MAKEFRAG
## R_PROG_CC_FLAG(FLAG, [ACTION-IF-TRUE])
## ---------------------------------------
## Check whether the C compiler handles command line option FLAG,
## and set shell variable r_cv_prog_cc_flag_SFLAG accordingly (where
## SFLAG is a shell-safe transliteration of FLAG).
## In addition, execute ACTION-IF-TRUE in case of success.
AC_DEFUN([R_PROG_CC_FLAG],
[ac_safe=AS_TR_SH($1)
AC_MSG_CHECKING([whether ${CC} accepts $1])
AC_CACHE_VAL([r_cv_prog_cc_flag_${ac_safe}],
[AC_LANG_PUSH(C)
r_save_CFLAGS="${CFLAGS}"
CFLAGS="${CFLAGS} $1"
AC_LINK_IFELSE([AC_LANG_PROGRAM()],
[eval "r_cv_prog_cc_flag_${ac_safe}=yes"],
[eval "r_cv_prog_cc_flag_${ac_safe}=no"])
CFLAGS="${r_save_CFLAGS}"
AC_LANG_POP(C)
])
if eval "test \"`echo '$r_cv_prog_cc_flag_'$ac_safe`\" = yes"; then
AC_MSG_RESULT([yes])
[$2]
else
AC_MSG_RESULT([no])
fi
])# R_PROG_CC_FLAG
## R_PROG_CC_FLAG_D__NO_MATH_INLINES
## ---------------------------
## In glibc 2.1, inline version [x86] of exp was broken (exp(-Inf) = NaN).
## We fix this by adding '-D__NO_MATH_INLINES' to R_XTRA_CFLAGS rather
## than AC_DEFINE(__NO_MATH_INLINES) as the former also takes care of
## compiling C code for add-on packages.
AC_DEFUN([R_PROG_CC_FLAG_D__NO_MATH_INLINES],
[AC_CACHE_CHECK([whether C runtime needs -D__NO_MATH_INLINES],
[r_cv_c_no_math_inlines],
[AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <math.h>
#if defined(__GLIBC__)
#include <math.h>
int main () {
double x, y;
x = -1./0.;
y = exp(x);
exit (y != 0.);
}
#else
int main () {
exit(0);
}
#endif
]])],
[r_cv_c_no_math_inlines=no],
[r_cv_c_no_math_inlines=yes],
[r_cv_c_no_math_inlines=no])])
if test "${r_cv_c_no_math_inlines}" = yes; then
R_SH_VAR_ADD(R_XTRA_CFLAGS, [-D__NO_MATH_INLINES])
fi
])# R_PROG_CC_FLAG_D__NO_MATH_INLINES
## R_C_OPTIEEE
## -----------
## Check whether the C compiler needs '-OPT:IEEE_NaN_inf=ON' to
## correctly deal with IEEE NaN/Inf.
## This flag is needed for the native SGI C compiler.
## If needed, add the flag to R_XTRA_CFLAGS.
AC_DEFUN([R_C_OPTIEEE],
[AC_CACHE_CHECK([whether C compiler needs -OPT:IEEE_NaN_inf=ON],
[r_cv_c_optieee],
[AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <math.h>
#include <stdlib.h>
#include <ieeefp.h>
int main () {
double x = 0;
fpsetmask(0); x = x / x; exit (x != x);
}
]])],
[r_cv_c_optieee=yes],
[r_cv_c_optieee=no],
[r_cv_c_optieee=no])])
if test "${r_cv_c_optieee}" = yes; then
R_SH_VAR_ADD(R_XTRA_CFLAGS, [-OPT:IEEE_NaN_inf=ON])
fi
])# R_C_OPTIEEE
## R_C_INLINE
## ----------
## modified version of AC_C_INLINE to use R_INLINE not inline
AC_DEFUN([R_C_INLINE],
[AC_REQUIRE([AC_PROG_CC_STDC])dnl
AC_CACHE_CHECK([for inline], r_cv_c_inline,
[r_cv_c_inline=""
for ac_kw in inline __inline__ __inline; do
AC_COMPILE_IFELSE([AC_LANG_SOURCE(
[#ifndef __cplusplus
static $ac_kw int static_foo () {return 0; }
$ac_kw int foo () {return 0; }
#endif
])],
[r_cv_c_inline=$ac_kw; break])
done
])
case $r_cv_c_inline in
no) AC_DEFINE(R_INLINE,,
[Define as `inline', or `__inline__' or `__inline'
if that's what the C compiler calls it,
or to nothing if it is not supported.]) ;;
*) AC_DEFINE_UNQUOTED(R_INLINE, $r_cv_c_inline) ;;
esac
])# R_C_INLINE
### * C++ compiler and its characteristics.
## R_PROG_CXX_M
## ------------
## Check whether the C++ compiler accepts '-M' for generating
## dependencies.
AC_DEFUN([R_PROG_CXX_M],
[AC_REQUIRE([R_PROG_CC_M])
AC_CACHE_CHECK([whether ${CXX} accepts -M for generating dependencies],
[r_cv_prog_cxx_m],
[echo "#include <math.h>" > conftest.cc
## No real point in using AC_LANG_* and ${ac_ext}, as we need to create
## hard-wired suffix rules. We could be a bit more careful as we
## actually only test suffix '.cc'.
if test -n "`${CXX} -M conftest.cc 2>/dev/null | grep conftest`"; then
r_cv_prog_cxx_m=yes
else
r_cv_prog_cxx_m=no
fi])
])# R_PROG_CXX_M
## R_PROG_CXX_MAKEFRAG
## -------------------
## Generate a Make fragment with suffix rules for the C++ compiler.
## Used for both building R (Makeconf) and add-ons (etc/Makeconf).
AC_DEFUN([R_PROG_CXX_MAKEFRAG],
[r_cxx_rules_frag=Makefrag.cxx
AC_REQUIRE([R_PROG_CXX_M])
cat << \EOF > ${r_cxx_rules_frag}
.cc.o:
$(CXX) $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) -c $< -o $[@]
.cpp.o:
$(CXX) $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) -c $< -o $[@]
.C.o:
$(CXX) $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) -c $< -o $[@]
EOF
if test "${r_cv_prog_cxx_m}" = yes; then
cat << \EOF >> ${r_cxx_rules_frag}
.cc.d:
@echo "making $[@] from $<"
@$(CXX) -M $(ALL_CPPFLAGS) $< > $[@]
.cpp.d:
@echo "making $[@] from $<"
@$(CXX) -M $(ALL_CPPFLAGS) $< > $[@]
.C.d:
@echo "making $[@] from $<"
@$(CXX) -M $(ALL_CPPFLAGS) $< > $[@]
EOF
else
cat << \EOF >> ${r_cxx_rules_frag}
.cc.d:
@echo > $[@]
.cpp.d:
@echo > $[@]
.C.d:
@echo > $[@]
EOF
fi
AC_SUBST_FILE(r_cxx_rules_frag)
])# R_PROG_CXX_MAKEFRAG
## R_PROG_CXX_FLAG
## ---------------
## Check whether the C++ compiler handles command line option FLAG,
## and set shell variable r_cv_prog_cc_flag_SFLAG accordingly (where
## SFLAG is a shell-safe transliteration of FLAG).
## In addition, execute ACTION-IF-TRUE in case of success.
AC_DEFUN([R_PROG_CXX_FLAG],
[ac_safe=AS_TR_SH($1)
AC_MSG_CHECKING([whether ${CXX-c++} accepts $1])
AC_CACHE_VAL([r_cv_prog_cxx_flag_${ac_safe}],
[AC_LANG_PUSH(C++)
r_save_CXXFLAGS="${CXXFLAGS}"
CXXFLAGS="${CXXFLAGS} $1"
AC_LINK_IFELSE([AC_LANG_PROGRAM()],
[eval "r_cv_prog_cxx_flag_${ac_safe}=yes"],
[eval "r_cv_prog_cxx_flag_${ac_safe}=no"])
CXXFLAGS="${r_save_CXXFLAGS}"
AC_LANG_POP(C++)
])
if eval "test \"`echo '$r_cv_prog_cxx_flag_'$ac_safe`\" = yes"; then
AC_MSG_RESULT([yes])
[$2]
else
AC_MSG_RESULT([no])
fi
])# R_PROG_CXX_FLAG
### * Fortran 77 compiler/converter and its characteristics.
## R_PROG_F77
## ----------
## Find a Fortran 77 compiler
##
## If we have not been forced to use a particular Fortran compiler, try
## to find one using one of the several common names. The list is based
## on what the current autoconf CVS contains (2005-05-21). This says,
##
## <QUOTE>
## Known compilers:
## f77/f90/f95: generic compiler names
## g77: GNU Fortran 77 compiler
## gfortran: putative GNU Fortran 95+ compiler (in progress)
## ftn: native Fortran 95 compiler on Cray X1
## cf77: native F77 compiler under older Crays (prefer over fort77)
## fort77: native F77 compiler under HP-UX (and some older Crays)
## frt: Fujitsu F77 compiler
## pgf77/pgf90/pghpf/pgf95: Portland Group F77/F90/F95 compilers
## xlf/xlf90/xlf95: IBM (AIX) F77/F90/F95 compilers
## lf95: Lahey-Fujitsu F95 compiler
## fl32: Microsoft Fortran 77 "PowerStation" compiler
## af77: Apogee F77 compiler for Intergraph hardware running CLIX
## epcf90: "Edinburgh Portable Compiler" F90
## fort: Compaq (now HP) Fortran 90/95 compiler for Tru64 and Linux/Alpha
## ifort, previously ifc: Intel Fortran 95 compiler for Linux/x86
## efc: Intel Fortran 95 compiler for IA64
## </QUOTE>
##
## and uses the following lists:
## F95: f95 fort xlf95 ifort ifc efc pgf95 lf95 gfortran ftn
## F90: f90 xlf90 pgf90 pghpf epcf90
## F77: g77 f77 xlf frt pgf77 cf77 fort77 fl32 af77
##
## We use basically the same, with the following exceptions:
## * On HP-UX fort77 is the POSIX-compatible native compiler and
## f77 is not: hence we need look for fort77 first!
## <FIXME>
## Is this still true?
## </FIXME>
## * It seems that g95 has been resurrected, see www.g95.org, hence we
## add this to the list of F95 compilers.
## * Older versions of the Autoconf code used to have 'fc' as a wrapper
## around f2c (last in the list). It no longer has, but we still do,
## in src/scripts, but it must be specified manually.
## <FIXME>
## Is this still needed?
## </FIXME>
## * If the C compiler is gcc, we try looking for a matching GCC Fortran
## compiler (gfortran for 4.x, g77 for 3.x) first. This should handle
## problems if GCC 4.x and 3.x suites are installed and, depending on
## the gcc default, the "wrong" GCC Fortran compiler is picked up (as
## reported by Bill Northcott <w.northcott@unsw.edu.au> for OSX with
## 4.0 as default and g77 around and the "old" search order F77 F95
## F90 in use).
AC_DEFUN([R_PROG_F77],
[AC_BEFORE([$0], [AC_PROG_LIBTOOL])
AC_REQUIRE([R_PROG_CC_VERSION])
if test -n "${F77}"; then
AC_MSG_RESULT([defining F77 to be ${F77}])
else
F77=
F95_compilers="f95 fort xlf95 ifort ifc efc pgf95 lf95 gfortran ftn g95"
F90_compilers="f90 xlf90 pgf90 pghpf epcf90"
case "${host_os}" in
hpux*)
F77_compilers="g77 fort77 f77 xlf frt pgf77 cf77 fl32 af77" ;;
*)
F77_compilers="g77 f77 xlf frt pgf77 cf77 fort77 fl32 af77" ;;
esac
GCC_Fortran_compiler=
if test "${GCC}" = yes; then
case "${CC_VERSION}" in
3.*) GCC_Fortran_compiler=g77 ;;
4.*) GCC_Fortran_compiler=gfortran ;;
esac
fi
AC_CHECK_PROGS(F77, [ ${GCC_Fortran_compiler} ${F95_compilers} \
${F90_compilers} ${F77_compilers} fc ])
fi
if test -n "${F77}"; then
## If the above 'found' a Fortran 77 compiler, we run AC_PROG_F77 as
## this does additional testing (GNU, '-g', ...).
AC_PROG_F77
else
AC_MSG_ERROR([No F77 compiler found])
fi
])# R_PROG_F77
## R_PROG_F77_FLIBS
## ----------------
## Run AC_F77_LIBRARY_LDFLAGS, and fix some known problems with FLIBS.
## Only do this if the user has not already set FLIBS.
AC_DEFUN([R_PROG_F77_FLIBS],
[AC_BEFORE([$0], [AC_F77_LIBRARY_LDFLAGS])
if test -z "${FLIBS}"; then
##
## Currently (Autoconf 2.50 or better, it seems) FLIBS also contains all
## elements of LIBS when AC_F77_LIBRARY_LDFLAGS is run. This is because
## _AC_PROG_F77_V_OUTPUT() uses 'eval $ac_link' for obtaining verbose
## linker output, and AC_LANG(Fortran 77) sets up ac_link to contain
## LIBS. Most likely a bug, and a nuisance in any case ...
## But we cannot simply eliminate the elements in FLIBS duplicated from
## LIBS (e.g. '-lm' should be preserved). Hence, we try to call
## AC_F77_LIBRARY_LDFLAGS() with LIBS temporarily set to empty.
r_save_LIBS="${LIBS}"
LIBS=
AC_F77_LIBRARY_LDFLAGS
if test -z "${MAIN_LD}" ; then
LIBS=
R_C_LIBRARY_LDFLAGS
else
CLIBS=
fi
LIBS="${r_save_LIBS}"
## Currently g77 on Darwin links against '-lcrt1.o' (and for GCC 3.1 or
## better also against '-lcrtbegin.o'), which (unlike '-lcrt0.o') are
## not stripped by AC_F77_LIBRARY_LDFLAGS. This in particular causes
## R_PROG_F77_CC_COMPAT to fail. Hence, we make sure all -lcrt*.o are
## removed. In Addition, -lmx and -lSystem are implicit and their
## manual inclusion leads to ordering problems (remove when autoconf
## is fixed - supposedly the CVS version is, but 2.6.0 is not).
##
## Native f90 on HPUX 11 comes up with '-l:libF90.a' causing trouble
## when using gcc for linking. The '-l:' construction is similar to
## plain '-l' except that search order (archive/shared) given by '-a'
## is not important. We escape such flags via '-Wl,' in case of gcc.
## Note that the current Autoconf CVS uses _AC_LINKER_OPTION for a
## similar purpose when computing FLIBS: this uses '-Xlinker' escapes
## for gcc and does nothing otherwise. Note also that we cannot simply
## unconditionally escape with '${wl}' from libtool as on HPUX we need
## SHLIB_LD=ld for native C compilers (problem with non-PIC 'crt0.o',
## see 'Individual platform overrides' in section 'DLL stuff' in file
## 'configure.ac'.
##
## Using the Intel Fortran compiler (ifc) one typically gets incorrect
## flags, as the output from _AC_PROG_F77_V_OUTPUT() contains double
## quoted options, e.g. "-mGLOB_options_string=......", see also e.g.
## http://www.octave.org/octave-lists/archive/octave-maintainers.2002/msg00038.html.
## One possible solution is to change AC_F77_LIBRARY_LDFLAGS() to remove
## double quotes for ifc, as it already does for the Cray cft90. As we
## prefer not to overload Autoconf code, we try to fix things here ...
##
## As of 2.1.0 we try to tidy this up a bit.
## 1) -lfrtbegin and -lgfortranbegin are used by g77/gfortran only for a
## Fortran main program, which we do not have.
## 2) g77 also tends to duplicate paths via ../../.., so we canonicalize
## paths and remove duplicates.
## 3) We do not need -L/lib etc, nor those in LDFLAGS
## 4) We exclude path with CC will include when linking.
##
## First try to fathom out what -Lfoo commands are unnecessary.
case "${host_os}" in
linux*)
r_libpath_default="/usr/lib64 /lib64 /usr/lib /lib"
;;
solaris*)
r_libpath_default="/usr/lib /lib"
;;
*)
r_libpath_default=
;;
esac
r_extra_libs=
for arg in ${LDFLAGS} ${CLIBS}; do
case "${arg}" in
-L*)
lib=`echo ${arg} | sed "s/^-L//"`
test -d "${lib}" || continue
## Canonicalize (/usr/lib/gcc-lib/i686-linux/3.4.3/../../..).
lib=`cd "${lib}" && ${GETWD}`
r_extra_libs="${r_extra_libs} $lib"
;;
esac
done
flibs=
if test "${GCC}" = yes; then
linker_option="-Wl,"
else
linker_option=
fi
r_save_flibs=""
for arg in ${FLIBS}; do
case "${arg}" in
## this is not for a Fortran main program
-lcrt*.o | -lfrtbegin | -lgfortranbegin | -lmx | -lSystem)
;;
-[[a-zA-Z]]/*\" | -[[a-zA-Z]]*\\) # ifc
;;
-l:*)
flibs="${flibs} ${linker_option}${arg}"
;;
-L*)
lib=`echo ${arg} | sed "s/^-L//"`
## Do not add non-existent directories.
test -d "${lib}" || continue
## Canonicalize (/usr/lib/gcc-lib/i686-linux/3.4.3/../../..).
lib=`cd "${lib}" && ${GETWD}`
r_want_lib=true
## Do not add something twice nor default paths nor those in LDFLAGS
for dir in ${r_save_flibs} ${r_libpath_default} ${r_extra_libs}; do
if test "${dir}" = "${lib}"; then
r_want_lib=false
break
fi
done
if test x"${r_want_lib}" = xtrue; then
flibs="${flibs} -L${lib}"
r_save_flibs="${r_save_flibs} ${lib}"
fi
;;
*)
flibs="${flibs} ${arg}"
;;
esac
done
FLIBS="${flibs}"
fi
])# R_PROG_F77_FLIBS
## R_PROG_F77_APPEND_UNDERSCORE
## ----------------------------
## See if the Fortran 77 compiler appends underscores.
## What we really should do is determine how to properly mangle the
## names of C/C++ identifiers (potentially containing underscores) so
## that they match the name-mangling scheme used by the Fortran 77
## compiler. Autoconf 2.50 or better has macros F77_FUNC(name, NAME)
## and F77_FUNC_(name, NAME) for this. However, the F77_* macros in
## the R API have one argument only and therefore cannot deal with
## Fortran 77 compilers which convert to upper case or add an extra
## underscore for identifiers containing underscores. We give an error
## in the former case; as ISO Fortran 77 does not allow underscores in
## function names, we do nothing about the latter.
AC_DEFUN([R_PROG_F77_APPEND_UNDERSCORE],
[AC_REQUIRE([AC_F77_WRAPPERS])
## DANGER! We really needs the results of _AC_F77_NAME_MANGLING as
## stored in the cache var ac_cv_f77_mangling which is not documented
## and hence may change ...
case "${ac_cv_f77_mangling}" in
"upper "*)
AC_MSG_WARN([Fortran compiler uses uppercase external names])
AC_MSG_ERROR([cannot use Fortran])
;;
esac
AC_MSG_CHECKING([whether ${F77} appends underscores to external names])
AC_CACHE_VAL([r_cv_prog_f77_append_underscore],
[case "${ac_cv_f77_mangling}" in
*", underscore, "*)
r_cv_prog_f77_append_underscore=yes
;;
*", no underscore, "*)
r_cv_prog_f77_append_underscore=no
;;
esac])
if test -n "${r_cv_prog_f77_append_underscore}"; then
AC_MSG_RESULT([${r_cv_prog_f77_append_underscore}])
else
AC_MSG_RESULT([unknown])
AC_MSG_ERROR([cannot use Fortran])
fi
if test "${r_cv_prog_f77_append_underscore}" = yes; then
AC_DEFINE(HAVE_F77_UNDERSCORE, 1,
[Define if your Fortran compiler appends an underscore to
external names.])
fi
AC_MSG_CHECKING([whether ${F77} appends extra underscores to external names])
AC_CACHE_VAL([r_cv_prog_f77_append_second_underscore],
[case "${ac_cv_f77_mangling}" in
*", extra underscore")
r_cv_prog_f77_append_second_underscore=yes
;;
*", no extra underscore")
r_cv_prog_f77_append_second_underscore=no
;;
esac])
if test -n "${r_cv_prog_f77_append_second_underscore}"; then
AC_MSG_RESULT([${r_cv_prog_f77_append_second_underscore}])
else
AC_MSG_RESULT([unknown])
AC_MSG_ERROR([cannot use Fortran])
fi
if test "${r_cv_prog_f77_append_second_underscore}" = yes; then
AC_DEFINE(HAVE_F77_EXTRA_UNDERSCORE, 1,
[Define if your Fortran compiler appends an extra_underscore to
external names containing an underscore.])
fi
])# R_PROG_F77_APPEND_UNDERSCORE
## R_PROG_F77_CAN_RUN
## --------------------
## Check whether the C/Fortran set up produces runnable code, as
## a preliminary to the compatibility tests.
## May fail if Fortran shared libraries are not in the library path.
## As from 2.4.0 use the same code as the compatibility test, as
## on at least one system the latter actually used -lgfortran
## (which was broken) and the previous test here did not.
AC_DEFUN([R_PROG_F77_CAN_RUN],
[AC_REQUIRE([AC_CHECK_LIBM])
AC_MSG_CHECKING([whether mixed C/Fortran code can be run])
AC_CACHE_VAL([r_cv_prog_f77_can_run],
[cat > conftestf.f <<EOF
subroutine cftest(a, b, x, y)
integer a(3), b(2)
double precision x(3), y(3)
b(1) = a(3)/a(2)
b(2) = a(3) - a(1)*a(2)
y(1) = dble(a(3))/x(2)
y(2) = x(3)*x(1)
y(3) = (x(2)/x(1)) ** a(1)
end
EOF
${F77} ${FFLAGS} -c conftestf.f 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD
## Yes we need to double quote this ...
[cat > conftest.c <<EOF
#include <math.h>
#include <stdlib.h>
#include "confdefs.h"
#ifdef HAVE_F77_UNDERSCORE
# define F77_SYMBOL(x) x ## _
#else
# define F77_SYMBOL(x) x
#endif
int main () {
exit(0);
}
EOF]
if ${CC} ${CFLAGS} -c conftest.c 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
## <NOTE>
## This should really use MAIN_LD, and hence come after this is
## determined (and necessary additions to MAIN_LDFLAGS were made).
## But it seems that we currently can always use the C compiler.
## Also, to be defensive there should be a similar test with SHLIB_LD
## and SHLIB_LDFLAGS (and note that on HPUX with native cc we have to
## use ld for SHLIB_LD) ...
if ${CC} ${LDFLAGS} ${MAIN_LDFLAGS} -o conftest${ac_exeext} \
conftest.${ac_objext} conftestf.${ac_objext} ${FLIBS} \
${LIBM} 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD;
## </NOTE>
then
## redirect error messages to config.log
output=`./conftest${ac_exeext} 2>&AS_MESSAGE_LOG_FD`
if test ${?} = 0; then
r_cv_prog_f77_can_run=yes
fi
fi
fi
])
rm -rf conftest conftest.* conftestf.* core
if test -n "${r_cv_prog_f77_can_run}"; then
AC_MSG_RESULT([yes])
else
if test "${cross_compiling}" = yes; then
AC_MSG_RESULT([don't know (cross-compiling)])
else
AC_MSG_WARN([cannot run mixed C/Fortran code])
AC_MSG_ERROR([Maybe check LDFLAGS for paths to Fortran libraries?])
fi
fi
])# R_PROG_F77_CAN_RUN
## R_PROG_F77_CC_COMPAT
## --------------------
## Check whether the Fortran 77 and C compilers agree on int and double.
AC_DEFUN([R_PROG_F77_CC_COMPAT],
[AC_REQUIRE([AC_CHECK_LIBM])
AC_MSG_CHECKING([whether ${F77} and ${CC} agree on int and double])
AC_CACHE_VAL([r_cv_prog_f77_cc_compat],
[cat > conftestf.f <<EOF
subroutine cftest(a, b, x, y)
integer a(3), b(2)
double precision x(3), y(3)