]>
Commit | Line | Data |
---|---|---|
81fea2b1 JL |
1 | # Process this file with autoconf to produce a configure script. |
2 | # Copyright (C) 1995, 1997 Free Software Foundation, Inc. | |
3 | # Contributed by Dave Love (d.love@dl.ac.uk). | |
4 | # | |
5 | #This file is part of GNU Fortran. | |
6 | # | |
7 | #GNU Fortran is free software; you can redistribute it and/or modify | |
8 | #it under the terms of the GNU General Public License as published by | |
9 | #the Free Software Foundation; either version 2, or (at your option) | |
10 | #any later version. | |
11 | # | |
12 | #GNU Fortran is distributed in the hope that it will be useful, | |
13 | #but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | #GNU General Public License for more details. | |
16 | # | |
17 | #You should have received a copy of the GNU General Public License | |
18 | #along with GNU Fortran; see the file COPYING. If not, write to | |
19 | #the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA | |
20 | #02111-1307, USA. | |
21 | ||
22 | AC_INIT(libF77/Version.c) | |
23 | ||
f30bc2e7 | 24 | AC_REVISION(1.11) |
81fea2b1 | 25 | |
f30bc2e7 CB |
26 | dnl Checks for programs. |
27 | # For g77 we'll set CC to point at the built gcc, but this will get it into | |
28 | # the makefiles | |
29 | AC_PROG_CC | |
81fea2b1 JL |
30 | |
31 | dnl These should be inherited in the recursive make, but ensure they are | |
32 | dnl defined: | |
33 | test "$AR" || AR=ar | |
34 | AC_SUBST(AR) | |
35 | if test "$RANLIB"; then : | |
36 | AC_SUBST(RANLIB) | |
37 | dnl Make sure that RANLIB_TEST is set also. | |
38 | if test -z "$RANLIB_TEST"; then | |
39 | RANLIB_TEST=true | |
40 | fi | |
41 | else | |
42 | RANLIB_TEST=true | |
43 | AC_PROG_RANLIB | |
44 | fi | |
45 | AC_SUBST(RANLIB_TEST) | |
46 | ||
47 | dnl not needed for g77? | |
48 | dnl AC_PROG_MAKE_SET | |
49 | ||
50 | dnl Checks for libraries. | |
51 | ||
52 | dnl Checks for header files. | |
53 | # Sanity check for the cross-compilation case: | |
54 | AC_CHECK_HEADER(stdio.h,:, | |
55 | [AC_MSG_ERROR([Can't find stdio.h. | |
56 | You must have a usable C system for the target already installed, at least | |
57 | including headers and, preferably, the library, before you can configure | |
58 | the G77 runtime system. If necessary, install gcc now with \`LANGUAGES=c', | |
59 | then the target library, then build with \`LANGUAGES=f77'.])]) | |
60 | ||
61 | AC_HEADER_STDC | |
62 | dnl We could do this if we didn't know we were using gcc | |
63 | dnl AC_MSG_CHECKING(for prototype-savvy compiler) | |
64 | dnl AC_CACHE_VAL(g77_cv_sys_proto, | |
65 | dnl [AC_TRY_LINK(, | |
66 | dnl dnl looks screwy because TRY_LINK expects a function body | |
67 | dnl [return 0;} int foo (int * bar) {], | |
68 | dnl g77_cv_sys_proto=yes, | |
69 | dnl [g77_cv_sys_proto=no | |
70 | dnl AC_DEFINE(KR_headers)])]) | |
71 | dnl AC_MSG_RESULT($g77_cv_sys_proto) | |
72 | ||
73 | dnl for U77 | |
74 | dnl AC_CHECK_HEADERS(unistd.h) | |
75 | ||
76 | AC_MSG_CHECKING(for posix) | |
77 | AC_CACHE_VAL(g77_cv_header_posix, | |
78 | AC_EGREP_CPP(yes, | |
79 | [#include <sys/types.h> | |
80 | #include <unistd.h> | |
81 | #ifdef _POSIX_VERSION | |
82 | yes | |
83 | #endif | |
84 | ], | |
85 | g77_cv_header_posix=yes, | |
86 | g77_cv_header_posix=no)) | |
87 | AC_MSG_RESULT($g77_cv_header_posix) | |
88 | ||
89 | # We can rely on the GNU library being posix-ish. I guess checking the | |
90 | # header isn't actually like checking the functions, though... | |
91 | AC_MSG_CHECKING(for GNU library) | |
92 | AC_CACHE_VAL(g77_cv_lib_gnu, | |
93 | AC_EGREP_CPP(yes, | |
94 | [#include <stdio.h> | |
95 | #ifdef __GNU_LIBRARY__ | |
96 | yes | |
97 | #endif | |
98 | ], | |
99 | g77_cv_lib_gnu=yes, g77_cv_lib_gnu=no)) | |
100 | AC_MSG_RESULT($g77_cv_lib_gnu) | |
101 | ||
102 | # Apparently cygwin needs to be special-cased. | |
103 | AC_MSG_CHECKING([for cyg\`win'32]) | |
104 | AC_CACHE_VAL(g77_cv_sys_cygwin32, | |
105 | AC_EGREP_CPP(yes, | |
106 | [#ifdef __CYGWIN32__ | |
107 | yes | |
108 | #endif | |
109 | ], | |
110 | g77_cv_sys_cygwin32=yes, | |
111 | g77_cv_sys_cygwin32=no)) | |
112 | AC_MSG_RESULT($g77_cv_sys_cygwin32) | |
113 | ||
114 | # ditto for mingw32. | |
115 | AC_MSG_CHECKING([for mingw32]) | |
116 | AC_CACHE_VAL(g77_cv_sys_mingw32, | |
117 | AC_EGREP_CPP(yes, | |
118 | [#ifdef __MINGW32__ | |
119 | yes | |
120 | #endif | |
121 | ], | |
122 | g77_cv_sys_mingw32=yes, | |
123 | g77_cv_sys_mingw32=no)) | |
124 | AC_MSG_RESULT($g77_cv_sys_mingw32) | |
125 | ||
126 | ||
127 | AC_CHECK_HEADER(fcntl.h, | |
128 | test $g77_cv_header_posix = yes && AC_DEFINE(_POSIX_SOURCE), | |
129 | AC_DEFINE(NO_FCNTL) AC_DEFINE(OPEN_DECL)) | |
130 | ||
131 | dnl Checks for typedefs, structures, and compiler characteristics. | |
132 | AC_C_CONST | |
133 | AC_TYPE_SIZE_T | |
134 | ||
135 | dnl Checks for library functions. | |
136 | AC_TYPE_SIGNAL | |
137 | # we'll get atexit by default | |
138 | if test $ac_cv_header_stdc != yes; then | |
139 | AC_CHECK_FUNC(atexit, | |
140 | AC_DEFINE(onexit,atexit),dnl just in case | |
141 | [AC_DEFINE(NO_ONEXIT) | |
142 | AC_CHECK_FUNC(onexit,, | |
143 | [AC_CHECK_FUNC(on_exit, | |
144 | AC_DEFINE(onexit,on_exit),)])]) | |
145 | else true | |
146 | fi | |
147 | ||
148 | # This should always succeed on unix. | |
149 | # Apparently positive result on cygwin loses re. NON_UNIX_STDIO | |
150 | # (as of cygwin b18). Likewise on mingw. | |
151 | AC_CHECK_FUNC(fstat) | |
152 | AC_MSG_CHECKING([need for NON_UNIX_STDIO]) | |
153 | if test $g77_cv_sys_cygwin32 = yes \ | |
154 | || test $g77_cv_sys_mingw32 = yes \ | |
155 | || test $ac_cv_func_fstat = no; then | |
156 | AC_MSG_RESULT(yes) | |
157 | AC_DEFINE(NON_UNIX_STDIO) | |
158 | else | |
159 | AC_MSG_RESULT(no) | |
160 | fi | |
161 | ||
162 | # This is necessary for e.g. Linux: | |
163 | AC_MSG_CHECKING([for necessary members of struct FILE]) | |
164 | AC_CACHE_VAL(g77_cv_struct_FILE, | |
165 | [AC_TRY_COMPILE([#include <stdio.h>], | |
166 | [FILE s; s._ptr; s._base; s._flag;],g77_cv_struct_FILE=yes, | |
167 | g77_cv_struct_FILE=no)])dnl | |
168 | AC_MSG_RESULT($g77_cv_struct_FILE) | |
169 | if test $g77_cv_struct_FILE = no; then | |
170 | AC_DEFINE(MISSING_FILE_ELEMS) | |
171 | fi | |
172 | ||
173 | dnl perhaps should check also for remainder | |
174 | dnl Unfortunately, the message implies we're just checking for -lm... | |
175 | AC_CHECK_LIB(m,drem,AC_DEFINE(IEEE_drem)) | |
176 | ||
177 | dnl for U77: | |
178 | dnl AC_CHECK_FUNCS(symlink getcwd lstat) | |
179 | dnl test $ac_cv_func_symlink = yes && SYMLNK=symlnk_.o | |
180 | dnl test $ac_cv_func_lstat = yes && SYMLNK="$SYMLNK lstat_.o" | |
181 | dnl AC_SUBST(SYMLNK) | |
182 | ||
2731cc56 JL |
183 | AC_CHECK_FUNCS(tempnam) |
184 | ||
81fea2b1 JL |
185 | # posix will guarantee the right behaviour for sprintf, else we can't be |
186 | # sure; HEADER_STDC wouldn't be the right check in sunos4, for instance. | |
187 | # However, on my sunos4/gcc setup unistd.h leads us wrongly to believe | |
188 | # we're posix-conformant, so always do the test. | |
189 | AC_MSG_CHECKING(for ansi/posix sprintf result) | |
190 | dnl This loses if included as an argument to AC_CACHE_VAL because the | |
191 | dnl changequote doesn't take effect and the [] vanish. | |
192 | dnl fixme: use cached value | |
193 | AC_TRY_RUN(changequote(<<, >>)dnl | |
194 | <<#include <stdio.h> | |
195 | /* does sprintf return the number of chars transferred? */ | |
196 | main () {char foo[2]; (sprintf(foo, "1") == 1) ? exit(0) : exit(1);} | |
197 | >>changequote([, ]), | |
198 | g77_cv_sys_sprintf_ansi=yes, | |
199 | g77_cv_sys_sprintf_ansi=no, | |
200 | g77_cv_sys_sprintf_ansi=no) | |
201 | AC_CACHE_VAL(g77_cv_sys_sprintf_ansi, | |
202 | g77_cv_sys_sprintf_ansi=$g77_cv_sys_sprintf_ansi) | |
203 | dnl We get a misleading `(cached)' message... | |
f30bc2e7 CB |
204 | AC_MSG_RESULT($g77_cv_sys_sprintf_ansi) |
205 | ||
81fea2b1 JL |
206 | # The cygwin patch takes steps to avoid defining USE_STRLEN here -- I don't |
207 | # understand why. | |
208 | if test $g77_cv_sys_sprintf_ansi != yes; then | |
209 | AC_DEFINE(USE_STRLEN) | |
210 | fi | |
211 | ||
212 | # define NON_ANSI_RW_MODES on unix (can't hurt) | |
213 | AC_MSG_CHECKING(NON_ANSI_RW_MODES) | |
214 | AC_EGREP_CPP(yes, | |
215 | [#ifdef unix | |
216 | yes | |
217 | #endif | |
218 | #ifdef __unix | |
219 | yes | |
220 | #endif | |
221 | #ifdef __unix__ | |
222 | yes | |
223 | #endif | |
224 | ], is_unix=yes, is_unix=no) | |
225 | if test $g77_cv_sys_cygwin32 = yes || test $g77_cv_sys_mingw32 = yes; then | |
226 | AC_MSG_RESULT(no) | |
227 | else | |
228 | if test $is_unix = yes; then | |
229 | AC_DEFINE(NON_ANSI_RW_MODES) | |
230 | AC_MSG_RESULT(yes) | |
231 | else | |
232 | AC_MSG_RESULT(no) | |
233 | fi | |
234 | fi | |
235 | ||
236 | # We have to firkle with the info in hconfig.h to figure out suitable types | |
237 | # (via com.h). proj.h and com.h are in $srcdir/.., config.h which they need | |
238 | # is in ../.. and the config files are in $srcdir/../../config. | |
239 | AC_MSG_CHECKING(f2c integer type) | |
240 | late_ac_cpp=$ac_cpp | |
8746c235 RH |
241 | ac_cpp="$late_ac_cpp -I../../gcc/f -I../../gcc -I../../gcc/config" |
242 | if test "$subdir" != . ; then | |
243 | ac_cpp="$ac_cpp -I$srcdir/../gcc/f -I$srcdir/../gcc -I$srcdir/../gcc/config" | |
fcce69a9 | 244 | fi |
81fea2b1 | 245 | AC_CACHE_VAL(g77_cv_sys_f2cinteger, |
8746c235 | 246 | echo "configure:__oline__: using $ac_cpp" >&AC_FD_CC |
81fea2b1 JL |
247 | AC_EGREP_CPP(F2C_INTEGER=long int, |
248 | [#include "proj.h" | |
249 | #define FFECOM_DETERMINE_TYPES 1 | |
250 | #include "com.h" | |
251 | #if FFECOM_f2cINTEGER == FFECOM_f2ccodeLONG | |
252 | F2C_INTEGER=long int | |
253 | #elif FFECOM_f2cINTEGER == FFECOM_f2ccodeINT | |
254 | F2C_INTEGER=int | |
255 | #else | |
256 | # error "Cannot find a suitable type for F2C_INTEGER" | |
257 | #endif | |
258 | ], | |
259 | g77_cv_sys_f2cinteger="long int",) | |
260 | if test "$g77_cv_sys_f2cinteger" = ""; then | |
8746c235 | 261 | echo "configure:__oline__: using $ac_cpp" >&AC_FD_CC |
81fea2b1 JL |
262 | AC_EGREP_CPP(F2C_INTEGER=int, |
263 | [#include "proj.h" | |
264 | #define FFECOM_DETERMINE_TYPES 1 | |
265 | #include "com.h" | |
266 | #if FFECOM_f2cINTEGER == FFECOM_f2ccodeLONG | |
267 | F2C_INTEGER=long int | |
268 | #elif FFECOM_f2cINTEGER == FFECOM_f2ccodeINT | |
269 | F2C_INTEGER=int | |
270 | #else | |
271 | # error "Cannot find a suitable type for F2C_INTEGER" | |
272 | #endif | |
273 | ], | |
274 | g77_cv_sys_f2cinteger=int,) | |
275 | fi | |
276 | if test "$g77_cv_sys_f2cinteger" = ""; then | |
277 | AC_MSG_RESULT("") | |
278 | AC_MSG_ERROR([Can't determine type for f2c integer; config.log may help.]) | |
279 | fi | |
280 | ) | |
281 | AC_MSG_RESULT($g77_cv_sys_f2cinteger) | |
282 | F2C_INTEGER=$g77_cv_sys_f2cinteger | |
283 | ac_cpp=$late_ac_cpp | |
284 | AC_SUBST(F2C_INTEGER) | |
285 | ||
286 | AC_MSG_CHECKING(f2c long int type) | |
287 | late_ac_cpp=$ac_cpp | |
8746c235 RH |
288 | ac_cpp="$late_ac_cpp -I../../gcc/f -I../../gcc -I../../gcc/config" |
289 | if test "$subdir" != . ; then | |
290 | ac_cpp="$ac_cpp -I$srcdir/../gcc/f -I$srcdir/../gcc -I$srcdir/../gcc/config" | |
fcce69a9 | 291 | fi |
81fea2b1 | 292 | AC_CACHE_VAL(g77_cv_sys_f2clongint, |
8746c235 | 293 | echo "configure:__oline__: using $ac_cpp" >&AC_FD_CC |
81fea2b1 JL |
294 | AC_EGREP_CPP(F2C_LONGINT=long int, |
295 | [#include "proj.h" | |
296 | #define FFECOM_DETERMINE_TYPES 1 | |
297 | #include "com.h" | |
298 | #if FFECOM_f2cLONGINT == FFECOM_f2ccodeLONG | |
299 | F2C_LONGINT=long int | |
300 | #elif FFECOM_f2cLONGINT == FFECOM_f2ccodeLONGLONG | |
301 | F2C_LONGINT=long long int | |
302 | #else | |
303 | # error "Cannot find a suitable type for F2C_LONGINT" | |
304 | #endif | |
305 | ], | |
306 | g77_cv_sys_f2clongint="long int",) | |
307 | if test "$g77_cv_sys_f2clongint" = ""; then | |
8746c235 | 308 | echo "configure:__oline__: using $ac_cpp" >&AC_FD_CC |
81fea2b1 JL |
309 | AC_EGREP_CPP(F2C_LONGINT=long long int, |
310 | [#include "proj.h" | |
311 | #define FFECOM_DETERMINE_TYPES 1 | |
312 | #include "com.h" | |
313 | #if FFECOM_f2cLONGINT == FFECOM_f2ccodeLONG | |
314 | F2C_LONGINT=long int | |
315 | #elif FFECOM_f2cLONGINT == FFECOM_f2ccodeLONGLONG | |
316 | F2C_LONGINT=long long int | |
317 | #else | |
318 | # error "Cannot find a suitable type for F2C_LONGINT" | |
319 | #endif | |
320 | ], | |
321 | g77_cv_sys_f2clongint="long long int",) | |
322 | fi | |
323 | if test "$g77_cv_sys_f2clongint" = ""; then | |
324 | AC_MSG_RESULT("") | |
325 | AC_MSG_ERROR([Can't determine type for f2c long int; config.log may help.]) | |
326 | fi | |
327 | ) | |
328 | AC_MSG_RESULT($g77_cv_sys_f2clongint) | |
329 | F2C_LONGINT=$g77_cv_sys_f2clongint | |
330 | ac_cpp=$late_ac_cpp | |
331 | AC_SUBST(F2C_LONGINT) | |
332 | ||
333 | dnl maybe check for drem/remainder | |
334 | ||
81fea2b1 JL |
335 | # This EOF_CHAR is a misfeature on unix. |
336 | AC_DEFINE(NO_EOF_CHAR_CHECK) | |
337 | ||
338 | AC_DEFINE(Skip_f2c_Undefs) | |
339 | ||
81fea2b1 JL |
340 | # avoid confusion in case the `makefile's from the f2c distribution have |
341 | # got put here | |
342 | test -f libF77/makefile && mv libF77/makefile libF77/makefile.ori | |
343 | test -f libI77/makefile && mv libI77/makefile libI77/makefile.ori | |
344 | test -f libU77/makefile && mv libU77/makefile libU77/makefile.ori | |
345 | ||
487eb4b8 | 346 | # Get the version number from the toplevel |
6174dcf3 MH |
347 | if test x${with_gcc_version} = x; then |
348 | # Try to get the version number from a hopefully existing gcc directory. | |
349 | if test -d ${srcdir}/../gcc; then | |
350 | gcc_version=`sed -e 's/.*\"\([[^ \"]]*\)[[ \"]].*/\1/' < ${srcdir}/../gcc/version.c` | |
351 | else | |
352 | gcc_version=UNKNOWN | |
353 | fi | |
354 | else | |
355 | gcc_version=${with_gcc_version} | |
356 | fi | |
357 | AC_SUBST(gcc_version) | |
487eb4b8 JL |
358 | AC_CANONICAL_SYSTEM |
359 | AC_SUBST(target_alias) | |
360 | ||
81fea2b1 | 361 | AC_CONFIG_SUBDIRS(libU77) |
f30bc2e7 | 362 | AC_OUTPUT(Makefile g2c.h libI77/Makefile libF77/Makefile) |
81fea2b1 JL |
363 | |
364 | dnl We might have configuration options to: | |
81fea2b1 JL |
365 | dnl * change unit preconnexion in libI77/err.c (f_init.c) |
366 | dnl * -DALWAYS_FLUSH in libI77 | |
367 | dnl * -DOMIT_BLANK_CC in libI77 | |
368 | ||
369 | dnl Local Variables: | |
370 | dnl comment-start: "dnl " | |
371 | dnl comment-end: "" | |
372 | dnl comment-start-skip: "\\bdnl\\b\\s *" | |
373 | dnl End: |