forked from wkliao/parallel-netcdf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
acinclude.m4
1910 lines (1828 loc) · 52.7 KB
/
acinclude.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
dnl $Id$
dnl UD macros for PnetCDF configure
dnl Convert a string to all uppercase.
dnl
define([uppercase],
[translit($1, abcdefghijklmnopqrstuvwxyz, ABCDEFGHIJKLMNOPQRSTUVWXYZ)])
dnl
dnl Check for an m4(1) preprocessor utility.
dnl
AC_DEFUN([UD_PROG_M4],
[
dnl AS_MESSAGE([checking for m4 preprocessor...])
case "${M4-unset}" in
unset) AC_CHECK_PROGS(M4, m4 gm4, m4) ;;
*) AC_CHECK_PROGS(M4, $M4 m4 gm4, m4) ;;
esac
AC_MSG_CHECKING(m4 flags)
case "${M4FLAGS-unset}" in
unset) dnl test if M4 runs fine without option -B10000
`${M4} /dev/null > conftest.err 2>&1`
ac_cv_m4_stdout=`cat conftest.err`
if test "x$ac_cv_m4_stdout" != x; then
M4FLAGS=-B10000
fi
${RM} -f conftest.err
;;
esac
if test "x$M4FLAGS" = x; then
AC_MSG_RESULT("none")
else
AC_MSG_RESULT($M4FLAGS)
fi
M4FFLAGS=`echo $M4FLAGS | sed 's/-s *//g'`
dnl AC_MSG_NOTICE(M4FFLAGS=$M4FFLAGS)
AC_SUBST(M4FLAGS)
AC_SUBST(M4FFLAGS)
])
dnl
dnl Check for an ar(1) utility.
dnl
AC_DEFUN([UD_PROG_AR],
[
dnl AS_MESSAGE([checking for ar utility...])
case "${AR-unset}" in
unset) AC_CHECK_PROGS(AR, ar, ar) ;;
*) AC_CHECK_PROGS(AR, $AR ar, ar) ;;
esac
AC_MSG_CHECKING(ar flags)
case "${ARFLAGS-unset}" in
unset) ARFLAGS=cru ;;
esac
AC_MSG_RESULT($ARFLAGS)
AC_SUBST(ARFLAGS)
])
dnl
dnl Check for an nm(1) utility.
dnl
AC_DEFUN([UD_PROG_NM],
[
dnl AS_MESSAGE([checking for nm utility...])
case "${NM-unset}" in
unset) AC_CHECK_PROGS(NM, nm, nm) ;;
*) AC_CHECK_PROGS(NM, $NM nm, nm) ;;
esac
AC_MSG_CHECKING(nm flags)
case "${NMFLAGS-unset}" in
unset) NMFLAGS= ;;
esac
AC_MSG_RESULT($NMFLAGS)
AC_SUBST(NMFLAGS)
])
dnl
dnl Set the top-level source-directory.
dnl
AC_DEFUN([UD_SRCDIR],
[
AC_MSG_CHECKING(for top-level source-directory)
SRCDIR=`(cd $srcdir && pwd)`
AC_MSG_RESULT($SRCDIR)
AC_SUBST(SRCDIR)
])
dnl
dnl Check for a Standard C compiler. Prefer a native one over the
dnl GNU one to reduce the chance that the environment variable LIBS
dnl will have to be set to reference the GNU C runtime library.
dnl
AC_DEFUN([UD_PROG_CC],
[
# Because we must have a C compiler, we treat an unset CC
# the same as an empty CC.
case "${CC}" in
'')
case `uname` in
ULTRIX)
# The native ULTRIX C compiler isn't standard.
ccs='gcc cc'
;;
*)
# xlc is before c89 because AIX's sizeof(long long)
# differs between the two.
#
ccs='xlc c89 acc cc gcc'
;;
esac
for cc in $ccs; do
AC_CHECK_PROG(CC, $cc, $cc)
case "$CC" in
'') ;;
*) break
;;
esac
done
case "${CC}" in
'')
AC_MSG_ERROR("Could not find C compiler")
;;
esac
;;
esac
#
# On some systems, a discovered compiler nevertheless won't
# work (due to licensing, for example); thus, we check the
# compiler with a test program.
#
AC_MSG_CHECKING([C compiler "$CC"])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[AC_MSG_RESULT(works)],
[AC_MSG_RESULT(failed to compile test program)])
AC_SUBST(CC)
case "$CC" in
*gcc*)
GCC=yes # Expected by autoconf(1) macros
;;
esac
case `uname -sr` in
'HP-UX A.09'*)
AC_DEFINE(_HPUX_SOURCE)
;;
esac
])
dnl
dnl Check for a C++ compiler. Prefer a native one over the
dnl GNU one to reduce the chance that the environment variable LIBS
dnl will have to be set to reference the GNU C runtime library.
dnl
AC_DEFUN([UD_PROG_CXX],
[
case "${CXX-unset}" in
unset)
case `uname` in
AIX)
preferred_cxx='xlC'
;;
esac
possible_cxxs="${preferred_cxx} CC cxx c++ g++ gcc"
;;
'') AC_MSG_WARN("Empty CXX variable")
possible_cxxs=
;;
*) possible_cxxs=$CXX
;;
esac
case "${possible_cxxs}" in
'') CXX=
;;
*) AC_LANG_PUSH([C++])
for cxx in $possible_cxxs; do
AC_CHECK_PROG(CXX, $cxx, $cxx)
case "$CXX" in
'') ;;
*) # On some systems, a discovered compiler nevertheless
# won't work (because it's a script to a non-existent
# executable, for example); thus, we check the
# compiler with a test program. We also test
# for <iostream.h> and the standard C++ library
# because we need these to work.
#
AC_MSG_CHECKING(C++ compiler \"$CXX\")
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <iostream.h>
int main() {
cout << "";
return 0;
}
]])],[
AC_MSG_RESULT(works)
break
],[
AC_MSG_WARN($CXX failed on test program)
CXX=
unset ac_cv_prog_CXX
],[])
;;
esac
done
AC_LANG_POP([C++])
case "${CXX}" in
'') AC_MSG_WARN("Could not find working C++ compiler")
AC_MSG_WARN(Setting CXX to the empty string)
;;
esac
;;
esac
case "${CXX}" in
'') AC_MSG_WARN(The C++ interface will not be built)
;;
esac
AC_SUBST(CXX)
case `uname` in
'HP-UX A.09'*)
AC_DEFINE(_HPUX_SOURCE)
;;
esac
])
dnl
dnl like AC_TYPE_LONG_DOUBLE, except checks for 'long long'
dnl
AC_DEFUN([UD_C_LONG_LONG],
[AC_MSG_CHECKING(for long long)
AC_CACHE_VAL(ac_cv_c_long_long,
[if test "$GCC" = yes; then
ac_cv_c_long_long=yes
else
AC_RUN_IFELSE([AC_LANG_SOURCE([[int main() {
long long foo = 0;
return(sizeof(long long) < sizeof(long)); }]])],
[ac_cv_c_long_long=yes],
[ac_cv_c_long_long=no],[:])
fi])dnl
AC_MSG_RESULT($ac_cv_c_long_long)
if test $ac_cv_c_long_long = yes; then
AC_DEFINE(HAVE_LONG_LONG)
fi
])
dnl
dnl UD_CHECK_IEEE
dnl If the 'double' is not an IEEE double
dnl or the 'float' is not and IEEE single,
dnl define NO_IEEE_FLOAT
dnl
AC_DEFUN([UD_CHECK_IEEE],
[
AC_MSG_CHECKING(for IEEE floating point format)
AC_RUN_IFELSE([AC_LANG_SOURCE([[#ifndef NO_FLOAT_H
#include <float.h>
#endif
#define EXIT_NOTIEEE 1
#define EXIT_MAYBEIEEE 0
int
main()
{
#if defined(FLT_RADIX) && FLT_RADIX != 2
return EXIT_NOTIEEE;
#elif defined(DBL_MAX_EXP) && DBL_MAX_EXP != 1024
return EXIT_NOTIEEE;
#elif defined(DBL_MANT_DIG) && DBL_MANT_DIG != 53
return EXIT_NOTIEEE;
#elif defined(FLT_MAX_EXP) && !(FLT_MAX_EXP == 1024 || FLT_MAX_EXP == 128)
return EXIT_NOTIEEE;
#elif defined(FLT_MANT_DIG) && !(FLT_MANT_DIG == 53 || FLT_MANT_DIG == 24)
return EXIT_NOTIEEE;
#else
/* (assuming eight bit char) */
if(sizeof(double) != 8)
return EXIT_NOTIEEE;
if(!(sizeof(float) == 4 || sizeof(float) == 8))
return EXIT_NOTIEEE;
return EXIT_MAYBEIEEE;
#endif
}]])],[ac_cv_c_ieeefloat=yes],[ac_cv_c_ieeefloat=no],[:])
AC_MSG_RESULT($ac_cv_c_ieeefloat)
if test x$ac_cv_c_ieeefloat = xno; then
AC_DEFINE(NO_IEEE_FLOAT)
fi
])
dnl Check for utility for generating makefile dependencies.
dnl Should only be used at the UPC.
dnl
AC_DEFUN([UD_PROG_CC_MAKEDEPEND],
[
AC_MSG_CHECKING(how to make dependencies)
case `uname -s` in
IRIX*|OSF1)
CC_MAKEDEPEND='cc -M'
;;
SunOS)
case `uname -r` in
4*)
CC_MAKEDEPEND='cc -M'
;;
5*|*)
CC_MAKEDEPEND='cc -xM'
;;
esac
;;
ULTRIX)
case `uname -m` in
RISC)
CC_MAKEDEPEND='cc -M'
;;
VAX) # Can't handle prototypes in netcdf.h
;;
esac
;;
AIX) # Writes to .u files rather than standard out
;;
HP-UX) # Writes escaped newlines to standard error
;;
esac
case "${CC_MAKEDEPEND}" in
'')
CC_MAKEDEPEND=false
;;
esac
AC_MSG_RESULT($CC_MAKEDEPEND)
AC_SUBST(CC_MAKEDEPEND)
])
dnl Check for Fortran-90 compiler.
dnl
AC_DEFUN([UD_PROG_F90],
[
case "${F90+set}" in
set)
AC_MSG_CHECKING(user-defined Fortran-90 compiler \"$F90\")
AC_LANG_PUSH([Fortran])
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE([
subroutine foo(bar)
integer, intent(in) :: bar
end subroutine foo
])],
[AC_MSG_RESULT(works)],
[AC_MSG_RESULT(failed to compile test program)
unset F90
]
)
AC_LANG_POP([Fortran])
;;
*)
case "${FC+set}" in
set)
F90=$FC
F90FLAGS="${F90FLAGS-${FFLAGS--O}}"
F90LIBS="${F90LIBS-${FLIBS}}"
cat <<EOF >conftest.f90
program foo
call bar(1)
end
subroutine bar(bof)
integer, intent(in) :: bof
end
EOF
AC_MSG_CHECKING(\"$F90\" as Fortran-90 compiler)
doit='$F90 -o conftest ${F90FLAGS} conftest.f90 ${F90LIBS}'
if AC_TRY_EVAL(doit); then
doit=./conftest
if AC_TRY_EVAL(doit); then
AC_MSG_RESULT(works)
else
AC_MSG_RESULT(failed to build executable program)
unset F90
fi
else
AC_MSG_RESULT(failed to build test program)
unset F90
fi
${RM} -f conftest*
;;
esac
case "${F90-unset}" in
unset)
cat <<EOF >conftest.f90
program foo
call bar(1)
end
subroutine bar(bof)
integer, intent(in) :: bof
end
EOF
for f90 in xlf90 pgf90 f90; do
AC_CHECK_PROG(F90, $f90, $f90)
case "${F90}" in
'')
;;
*)
AC_MSG_CHECKING(Fortran-90 compiler \"$F90\")
doit='$F90 -o conftest ${F90FLAGS} conftest.f90 ${F90LIBS}'
if AC_TRY_EVAL(doit); then
doit=./conftest
if AC_TRY_EVAL(doit); then
AC_MSG_RESULT(works)
break
else
AC_MSG_RESULT(
failed to build executable program)
unset F90
unset ac_cv_prog_F90
fi
else
AC_MSG_RESULT(failed to build test program)
unset F90
unset ac_cv_prog_F90
fi
;;
esac
done
${RM} -f conftest*
case "${F90}" in
'') AC_MSG_WARN(
"Could not find working Fortran-90 compiler")
;;
esac
;;
esac
;;
esac
case "${F90}" in
'')
AC_MSG_WARN("The Fortran-90 interface will not be built")
;;
*f90*)
case `uname -s` in
IRIX*)
NETCDF_MOD=NETCDF.mod
;;
*)
NETCDF_MOD=netcdf.mod
;;
esac
AC_SUBST(NETCDF_MOD)
;;
esac
AC_SUBST(F90)
AC_SUBST(F90FLAGS)
AC_SUBST(F90LIBS)
])
dnl Check for Fortran-77 compiler.
dnl
AC_DEFUN([UD_PROG_FC],
[
AC_BEFORE([UD_FORTRAN_TYPES])
case "${FC+set}" in
set)
case "$FC" in
'')
AC_MSG_WARN(Fortran-77 compiler is explicitly set to null)
;;
*)
AC_MSG_CHECKING(user-defined Fortran-77 compiler \"$FC\")
AC_LANG_PUSH([Fortran 77])
AC_COMPILE_IFELSE([AC_LANG_CALL([],[FOO])],
[AC_MSG_RESULT(works)],
[AC_MSG_RESULT(failed to compile test program)
FC=
]
)
AC_LANG_POP([Fortran 77])
;;
esac
;;
*)
dnl FC is not set, let's try F90 as FC if F90 is set
case "${F90+set}" in
set)
FC=$F90
FFLAGS="${FFLAGS-${F90FLAGS--O}}"
FLIBS="${FLIBS-${F90LIBS-}}"
AC_MSG_CHECKING(\"$FC\" as Fortran-77 compiler)
AC_LANG_PUSH([Fortran])
AC_COMPILE_IFELSE([AC_LANG_CALL([],[FOO])],
[AC_MSG_RESULT(works)],
[AC_MSG_RESULT(failed to compile test program)
unset FC
]
)
AC_LANG_POP([Fortran])
;;
*)
;;
esac
case "${FC-unset}" in
unset)
case `uname -sr` in
AIX*)
# xlf90(1) thinks fortran/ftest.F has bad syntax.
forts="xlf f77 gfortran"
;;
BSD/OS*|FreeBSD*)
forts="f77 fort77 g77 gfortran"
;;
HP-UX*)
# f77(1) doesn't have the -L option.
forts=fort77
FLIBS=-lU77
;;
IRIX*)
# f90(1) can't link with c89(1)-compiled objects
forts=f77
;;
IRIX64*)
forts='f77 g77 gfortran fort77 '
;;
Linux*)
forts="pgf90 f77 fort77 g77 gfortran"
;;
OSF1*)
# The use of f90(1) results in the following for
# an unknown reason (`make' works in the fortran/
# directory):
# f90 -c -I../libsrc ftest.F
# Last chance handler: pc = 0xa971b8,
# sp = 0x3fece0, ra = 0xa971b8
# Last chance handler: internal exception: unwinding
forts="f77 gfortran"
;;
'SunOS 4'*)
forts='f77 g77 gfortran fort77'
;;
'SunOS 5'*)
# SunOS's f90(1) has problems passing a C `char'
# as a Fortran `integer*1' => use f77(1)
forts="pgf90 f77"
;;
sn*|UNICOS*|unicos*)
forts="fort77 cf77 f77 g77 gfortran f90"
;;
*)
forts="xlf fort77 ghf77 f77 cf77 g77 gfortran xlf90 f90"
;;
esac
for fc in $forts; do
AC_CHECK_PROG(FC, $fc, $fc)
case "${FC}" in
'')
;;
*)
#
# On some systems, a discovered compiler
# nevertheless won't work (due to licensing,
# for example); thus, we check the compiler
# with a test program.
#
AC_LANG_PUSH([Fortran])
AC_COMPILE_IFELSE([AC_LANG_CALL([],[FOO])],
[AC_MSG_RESULT(works)],
[AC_MSG_RESULT(failed to compile test program)
unset FC
unset ac_cv_prog_FC
]
)
AC_LANG_POP([Fortran])
;;
esac
done
${RM} -f conftest.*
case "${FC}" in
'') AC_MSG_WARN(
"Could not find working Fortran-77 compiler")
;;
esac
;;
esac
;;
esac
case "${FC}" in
'') AC_MSG_WARN("The Fortran-77 interface will not be built")
;;
esac
AC_SUBST(FC)
AC_SUBST(FFLAGS)
AC_SUBST(FLIBS)
#
# Set the make(1) macro for compiling a .F file.
#
case "${FPP-}" in
'')
AC_MSG_CHECKING(for Fortran .F compiler)
AC_MSG_RESULT($COMPILE_F)
case "${COMPILE_F-unset}" in
unset)
case "${FC}" in
'')
COMPILE_F=
;;
*)
cat >conftest.h <<\EOF
#define J 1
EOF
AC_LANG_PUSH([Fortran])
AC_FC_SRCEXT([F])
AC_MSG_CHECKING(if Fortran-77 compiler handles *.F files)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[
#include "conftest.h"
#define N 5
real r(J,N)
])],
[AC_MSG_RESULT(yes)
COMPILE_F='$(COMPILE.f)'],
[AC_MSG_RESULT(no)
COMPILE_F=
]
)
AC_FC_SRCEXT([f])
AC_LANG_POP([Fortran])
${RM} -f conftest.h
;;
esac
;;
esac
;;
*)
unset COMPILE_F
;;
esac
case "${COMPILE_F-}" in
'') UD_PROG_FPP;;
esac
AC_SUBST(COMPILE_F)
FPPFLAGS=${FPPFLAGS-}
AC_SUBST(FPPFLAGS)
])
dnl Check for Fortran preprocessor.
dnl
AC_DEFUN([UD_PROG_FPP],
[
AC_MSG_CHECKING(for Fortran preprocessor)
case "$FPP" in
'')
AC_REQUIRE([AC_PROG_CPP])
FPP="$CPP"
;;
esac
AC_MSG_RESULT($FPP)
AC_SUBST(FPP)
])
dnl Check for a Fortran type equivalent to a netCDF type.
dnl
dnl UD_CHECK_FORTRAN_NCTYPE(forttype, possibs, nctype)
dnl
AC_DEFUN([UD_CHECK_FORTRAN_NCTYPE],
[
AC_MSG_CHECKING([for Fortran-equivalent to netCDF "$3"])
dnl for type in $2; do
dnl cat >conftest.f <<EOF
dnl $type foo
dnl end
dnl EOF
dnl doit='$FC -c ${FFLAGS} conftest.f'
dnl if AC_TRY_EVAL(doit); then
dnl break
dnl fi
dnl done
dnl ${RM} -f conftest.f conftest.o
AC_LANG_PUSH([Fortran])
for type in $2; do
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE([
$type foo
end
])],
[break]
)
done
AC_LANG_POP([Fortran])
AC_DEFINE_UNQUOTED($1, $type)
AC_MSG_RESULT($type)
$1=$type
])
dnl Check for a Fortran type equivalent to a C type.
dnl
dnl UD_CHECK_FORTRAN_CTYPE(v3forttype, v2forttype, ctype, min, max)
dnl
AC_DEFUN([UD_CHECK_FORTRAN_CTYPE],
[
AC_MSG_CHECKING([for Fortran-equivalent to C "$3"])
AC_LANG_PUSH([Fortran])
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE([
subroutine sub(values, minval, maxval)
implicit none
$2 values(5), minval, maxval
minval = values(2)
maxval = values(4)
if (values(2) .ge. values(4)) then
minval = values(4)
maxval = values(2)
endif
end
])],
[found_f2c=yes], [found_f2c=no]
)
AC_LANG_POP([Fortran])
if test "x${found_f2c}" = xyes ; then
dnl cat >conftest.f <<EOF
dnl subroutine sub(values, minval, maxval)
dnl implicit none
dnl $2 values(5), minval, maxval
dnl minval = values(2)
dnl maxval = values(4)
dnl if (values(2) .ge. values(4)) then
dnl minval = values(4)
dnl maxval = values(2)
dnl endif
dnl end
dnl EOF
dnl doit='$FC -c ${FFLAGS} conftest.f'
dnl if AC_TRY_EVAL(doit); then
dnl mv conftest.o conftestf.o
cat >conftest.c <<EOF
#include <limits.h>
#include <float.h>
void main()
{
$3 values[[]] = {0, $4, 0, $5, 0};
$3 minval, maxval;
int $FCALLSCSUB($3*, $3*, $3*);
$FCALLSCSUB(values, &minval, &maxval);
return(!(minval == $4 && maxval == $5));
}
EOF
doit='$CC -o conftest ${CPPFLAGS} ${CFLAGS} ${LDFLAGS} conftest.c conftestf.o ${LIBS}'
if AC_TRY_EVAL(doit); then
doit=./conftest
if AC_TRY_EVAL(doit); then
AC_MSG_RESULT($2)
$1=$2
AC_DEFINE_UNQUOTED($1,$2)
else
AC_MSG_RESULT(no equivalent type)
unset $1
fi
else
AC_MSG_ERROR(Could not compile-and-link conftest.c and conftestf.o)
fi
else
AC_MSG_ERROR(Could not compile conftest.f)
fi
${RM} -f conftest*
unset found_f2c
])
dnl Check for a Fortran data type.
dnl
dnl UD_CHECK_FORTRAN_TYPE(varname, ftypes)
dnl
AC_DEFUN([UD_CHECK_FORTRAN_TYPE],
[
AC_LANG_PUSH([Fortran])
for ftype in $2; do
AC_MSG_CHECKING([for Fortran "$ftype"])
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE([
subroutine sub(value)
$ftype value
end
])],
[AC_MSG_RESULT(yes)
$1=$ftype
AC_DEFINE_UNQUOTED([$1], [$ftype])
break],
[AC_MSG_RESULT(no)]
)
done
AC_LANG_POP([Fortran])
])
dnl Check for the name format of a Fortran-callable C routine.
dnl
dnl UD_CHECK_FCALLSCSUB
AC_DEFUN([UD_CHECK_FCALLSCSUB],
[
dnl AC_REQUIRE([UD_PROG_FC])
case "$FC" in
'') ;;
*)
AC_REQUIRE([UD_PROG_NM])
AC_BEFORE([UD_CHECK_FORTRAN_CTYPE])
AC_BEFORE([UD_CHECK_CTYPE_FORTRAN])
AC_MSG_CHECKING([for C-equivalent to Fortran routine "SUB"])
AC_FC_FUNC([sub], [FCALLSCSUB])
AC_MSG_RESULT([$FCALLSCSUB])
;;
esac
])
dnl Check for a C type equivalent to a Fortran type.
dnl
dnl UD_CHECK_CTYPE_FORTRAN(ftype, ctypes, fmacro_root)
dnl
AC_DEFUN([UD_CHECK_CTYPE_FORTRAN],
[
cat >conftestf.f <<EOF
$1 values(4)
integer status, sub
data values /-1, -2, -3, -4/
status = sub(values)
end
EOF
ac_cv_ctype_fortran=no
AC_MSG_CHECKING([if Fortran "$1" is ])
for ctype in $2; do
dnl AC_MSG_CHECKING(if Fortran \"$1\" is C \"$ctype\")
cat >conftest.c <<EOF
int $FCALLSCSUB($ctype values[[4]])
{
return(values[[1]] != -2 || values[[2]] != -3);
}
EOF
doit='$CC -c ${CPPFLAGS} ${CFLAGS} conftest.c'
if AC_TRY_EVAL(doit); then
doit='$FC ${FFLAGS} -c conftestf.f'
if AC_TRY_EVAL(doit); then
doit='$FC -o conftest ${FFLAGS} ${FLDFLAGS} conftestf.o conftest.o ${LDFLAGS} ${LIBS}'
if AC_TRY_EVAL(doit); then
doit=./conftest
if AC_TRY_EVAL(doit); then
dnl AC_MSG_RESULT(yes)
AC_MSG_RESULT(["$ctype" in C])
cname=`echo $ctype | tr ' abcdefghijklmnopqrstuvwxyz' \
_ABCDEFGHIJKLMNOPQRSTUVWXYZ`
AC_DEFINE_UNQUOTED(NF_$3[]_IS_C_$cname)
ac_cv_ctype_fortran=yes
break
fi
else
AC_MSG_ERROR([Could not link conftestf.o and conftest.o])
fi
else
AC_MSG_ERROR([Could not compile conftestf.f])
fi
else
AC_MSG_ERROR([Could not compile conftest.c])
fi
done
${RM} -f conftest*
if test "$ac_cv_ctype_fortran" = no ; then
AC_MSG_RESULT(no correspond data type in C)
fi
unset ac_cv_ctype_fortran
])
dnl Get information about Fortran data types.
dnl
AC_DEFUN([UD_FORTRAN_TYPES],
[
dnl AC_REQUIRE([UD_PROG_FC])
case "$FC" in
'')
;;
*)
AC_REQUIRE([UD_CHECK_FCALLSCSUB])
UD_CHECK_FORTRAN_TYPE([NF_INT1_T], [integer*1 byte "integer(kind=1)"])
UD_CHECK_FORTRAN_TYPE([NF_INT2_T], [integer*2 "integer(kind=2)"])
UD_CHECK_FORTRAN_TYPE([NF_INT8_T], [integer*8 "integer(kind=8)"])
case "${NF_INT1_T}" in
'') ;;
*) UD_CHECK_CTYPE_FORTRAN($NF_INT1_T, "signed char" short int long, INT1)
;;
esac
case "${NF_INT2_T}" in
'') ;;
*) UD_CHECK_CTYPE_FORTRAN($NF_INT2_T, short int long, INT2)
;;
esac
case "${NF_INT8_T}" in
'') ;;
*) UD_CHECK_CTYPE_FORTRAN($NF_INT8_T, int long "long long", INT8)
;;
esac
UD_CHECK_CTYPE_FORTRAN(integer, int long, INT)
UD_CHECK_CTYPE_FORTRAN(real, float double, REAL)
UD_CHECK_CTYPE_FORTRAN(doubleprecision, double float, DOUBLEPRECISION)
UD_CHECK_FORTRAN_NCTYPE(NCBYTE_T, byte integer*1 integer, byte)
UD_CHECK_FORTRAN_NCTYPE(NCSHORT_T, integer*2 integer, short)
dnl UD_CHECK_FORTRAN_CTYPE(NF_SHORT_T, $NCSHORT_T, short, SHRT_MIN, SHRT_MAX)
dnl UD_CHECK_FORTRAN_NCTYPE(NCLONG_T, integer*4 integer, long)
dnl UD_CHECK_FORTRAN_CTYPE(NF_INT_T, integer, int, INT_MIN, INT_MAX)
dnl UD_CHECK_FORTRAN_NCTYPE(NCFLOAT_T, real*4 real, float)
dnl UD_CHECK_FORTRAN_CTYPE(NF_FLOAT_T, $NCFLOAT_T, float, FLT_MIN, FLT_MAX)
dnl UD_CHECK_FORTRAN_NCTYPE(NCDOUBLE_T, real*8 doubleprecision real, double)
dnl UD_CHECK_FORTRAN_CTYPE(NF_DOUBLE_T, $NCDOUBLE_T, double, DBL_MIN, DBL_MAX)
;;
esac
])
dnl Setup for making a manual-page database.
dnl
AC_DEFUN([UD_MAKEWHATIS],
[
#
# NB: We always want to define WHATIS to prevent the
# $(MANDIR)/$(WHATIS) make(1) target from being just $(MANDIR)/ and
# conflicting with the (directory creation) target with the same name.
#
WHATIS=whatis
case `uname -sr` in
BSD/OS*|FreeBSD*)
# Can't generate a user-database -- only /usr/share/man/whatis.db.
MAKEWHATIS_CMD=
;;
'IRIX64 6.5'|'IRIX 6.5')
MAKEWHATIS_CMD='/usr/lib/makewhatis -M $(MANDIR) $(MANDIR)/whatis'
;;
'IRIX 6'*)
# Can't generate a user-database.
MAKEWHATIS_CMD=
;;
HP-UX*)
# Can't generate a user-database -- only /usr/lib/whatis.
MAKEWHATIS_CMD=
;;
'Linux '*)
# /usr/sbin/makewhatis doesn't work
MAKEWHATIS_CMD=
;;
ULTRIX*)
# Can't generate a user-database -- only /usr/lib/whatis.
MAKEWHATIS_CMD=
;;
*)
if test -r /usr/man/windex; then
WHATIS=windex
fi
AC_CHECK_PROGS(prog, catman makewhatis /usr/lib/makewhatis)
case "$prog" in
*catman*)
MAKEWHATIS_CMD=$prog' -w -M $(MANDIR)'
;;
*makewhatis*)
MAKEWHATIS_CMD=$prog' $(MANDIR)'
;;
esac
;;
esac
AC_SUBST(WHATIS)
AC_SUBST(MAKEWHATIS_CMD)
AC_MSG_CHECKING(for manual-page index command)
AC_MSG_RESULT($MAKEWHATIS_CMD)
])
dnl Check for the math library.
dnl
AC_DEFUN([UD_CHECK_LIB_MATH],
[
dnl AS_MESSAGE([checking for math library...])
case "${MATHLIB}" in
'')
AC_CHECK_LIB(c, floor, MATHLIB=,
AC_CHECK_LIB(m, floor, MATHLIB=-lm, MATHLIB=))
;;
*)
AC_MSG_RESULT($MATHLIB (user defined))
;;
esac
AC_SUBST(MATHLIB)
])
dnl steal from autoconf 2.69
AC_DEFUN([UD_FC_PP_SRCEXT],
[AC_LANG_PUSH(Fortran)dnl
AC_CACHE_CHECK([for Fortran flag to compile preprocessed .$1 files],
ac_cv_fc_pp_srcext_$1,