-
Notifications
You must be signed in to change notification settings - Fork 0
/
aclocal.m4
207 lines (206 loc) · 5.26 KB
/
aclocal.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
dnl
dnl Local macros. This are based on files provided with autoconf
dnl so the GNU GPL applies to them.
dnl
dnl
dnl See if the given fortran program compiles OK. This requires the
dnl shell variable F77SUF to be defined.
dnl arg1: echo text
dnl arg2: optional code (main is already provided)
dnl arg3: additional compiler arguments
dnl arg4: success action
dnl arg5: fail action
dnl
define(AC_FC_COMPILE_CHECK,
[AC_PROVIDE([$0])dnl
ifelse([$1], , , [AC_CHECKING([for $1])]
)dnl
cat > conftest.$F77SUF <<EOF
PROGRAM MAIN
CALL X()
STOP
END
SUBROUTINE X()
[$2]
RETURN
END
EOF
dnl Don't try to run the program, which would prevent cross-configuring.
if eval $FC [$3] -o conftest conftest.${F77SUF} ${FLIBS} > /dev/null 2>&1; then
ifelse([$4], , :, [rm -rf conftest*
$4
])
ifelse([$5], , , [else
rm -rf conftest*
$5
])dnl
fi
rm -f conftest*]
)dnl
dnl
dnl See if the given C program is processed by the C compiler OK. Does
dnl not necessarily compile. If you want to compile give a -c to the compiler
dnl arguments. To compile and link give a -o conftest.
dnl arg1: echo text
dnl arg2: optional code (main is already provided)
dnl arg3: additional compiler arguments
dnl arg4: success action
dnl arg5: fail action
dnl
define(AC_CC_PROCESS_CHECK,
[AC_PROVIDE([$0])dnl
ifelse([$1], , , [AC_CHECKING([for $1])]
)dnl
cat > conftest.c <<EOF
[$2]
main() {}
EOF
dnl Don't try to run the program, which would prevent cross-configuring.
if eval $CC [$3] conftest.c >/dev/null 2>&1; then
ifelse([$4], , :, [rm -rf conftest*
$4
])
ifelse([$5], , , [else
rm -rf conftest*
$5
])dnl
fi
rm -f conftest*]
)dnl
dnl
dnl This checks for the existence of fortran libraries. It is much
dnl like AC_HAVE_LIBRARY, except it uses AC_FC_COMPILE_CHECK
dnl
define(AC_HAVE_FC_LIBRARY, [dnl
changequote(/,/)dnl
define(/AC_LIB_NAME/, dnl
patsubst(patsubst($1, /lib\([^\.]*\)\.a/, /\1/), /-l/, //))dnl
changequote([,])dnl
ac_save_FLIBS="${FLIBS}"
FLIBS="${FLIBS} -l[]AC_LIB_NAME[]"
ac_have_lib=""
AC_FC_COMPILE_CHECK([-l[]AC_LIB_NAME[]], , -o conftest, [ac_have_lib="1"])dnl
FLIBS="${ac_save_FLIBS}"
ifelse($#, 1, [dnl
if test -n "${ac_have_lib}"; then
AC_DEFINE([HAVE_LIB]translit(AC_LIB_NAME, [a-z], [A-Z]))
FLIBS="${FLIBS} -l[]AC_LIB_NAME[]"
fi
undefine(AC_LIB_NAME)dnl
], [dnl
if test -n "${ac_have_lib}"; then
:; $2
else
:; $3
fi
])])dnl
dnl
dnl try to determine what main is called, and how to link
dnl c and fortran codes
dnl shell variable F77SUF to be defined.
dnl arg1: echo text
dnl arg2: additional compiler arguments
dnl
define(AC_FC_LINKAGE_CHECK,
[AC_PROVIDE([$0])dnl
ifelse([$1], , , [AC_CHECKING([for $1])]
)dnl
cat > conftest.$F77SUF <<EOF
PROGRAM FOO
STOP
END
SUBROUTINE FOO2
RETURN
END
EOF
dnl check to see if this is gnu egrep which uses -q for silent mode,
dnl or a more generic one which uses -s
if eval egrep -q FOO2 conftest.$F77SUF > /dev/null 2>&1; then
ac_egrep_silent=-q
else
ac_egrep_silent=-s
fi
dnl compile conftest.f and look for main and foo2 symbols
$FC [$2] -c conftest.${F77SUF} ${FLIBS} > /dev/null 2>&1
if eval nm -p conftest.o | egrep $ac_egrep_silent MAIN__; then
MAIN_FUNC=MAIN__
elif eval nm -p conftest.o | egrep $ac_egrep_silent MAIN_; then
MAIN_FUNC=MAIN_
elif eval nm -p conftest.o | egrep $ac_egrep_silent MAIN; then
MAIN_FUNC=MAIN
elif eval nm -p conftest.o | egrep $ac_egrep_silent main__; then
MAIN_FUNC=main__
elif eval nm -p conftest.o | egrep $ac_egrep_silent main_; then
MAIN_FUNC=main_
elif eval nm -p conftest.o | egrep $ac_egrep_silent main; then
MAIN_FUNC=main
fi
CDEF="$CDEF -DMAIN_FUNC=$MAIN_FUNC"
dnl
if eval nm -p conftest.o | egrep $ac_egrep_silent foo2_; then
CDEF="$CDEF -DFCLINK=1"
elif eval nm -p conftest.o | egrep $ac_egrep_silent foo2; then
CDEF="$CDEF -DFCLINK=2"
elif eval nm -p conftest.o | egrep $ac_egrep_silent FOO2; then
CDEF="$CDEF -DFCLINK=3"
fi
rm -f conftest*]
)dnl
dnl
dnl try to determine the sizes of some c basic types
dnl arg1: echo text
dnl
define(AC_C_SIZES_CHECK,
[AC_PROVIDE([$0])dnl
ifelse([$1], , , [AC_CHECKING([for $1])]
)dnl
cat > conftest.c <<EOF
#include <stdio.h>
main()
{
printf("#!/bin/sh\n");
printf("ac_sizeof_int=%d\n",sizeof(int));
printf("ac_sizeof_long=%d\n",sizeof(long));
printf("ac_sizeof_long_long=%d\n",sizeof(long long));
printf("ac_sizeof_double=%d\n",sizeof(double));
printf("ac_sizeof_long_double=%d\n",sizeof(long double));
printf("ac_sizeof_pointer=%d\n",sizeof(int*));
return 0;
}
EOF
$CC conftest.c -o conftest
./conftest > conftest.sh
. conftest.sh
cat > conftest.$F77SUF <<EOF
program foo
real*8 a(2)
double precision d(2)
integer i(2)
integer aa1 , aa2, ai1, ai2, ad1, ad2
aa1 = %loc(a(1))
aa2 = %loc(a(2))
ai1 = %loc(i(1))
ai2 = %loc(i(2))
ad1 = %loc(d(1))
ad2 = %loc(d(2))
write(6,12)
write(6,10) aa2-aa1
write(6,11) ai2-ai1
write(6,13) ad2-ad1
10 format('ac_sizeof_real=',i1)
11 format('ac_sizeof_integer=',i1)
12 format('#!/bin/sh')
13 format('ac_sizeof_dprec=',i1)
stop
end
EOF
if eval $FC $FOTH conftest.${F77SUF} -o conftest > /dev/null 2>&1; then
./conftest > conftest.sh
. conftest.sh
else
ac_sizeof_real=$ac_sizeof_double
ac_sizeof_dprec=$ac_sizeof_double
ac_sizeof_integer=$ac_sizeof_int
fi
rm -f conftest*]
)dnl