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).
5 #This file is part of GNU Fortran.
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)
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.
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
22 AC_INIT(libF77/Version.c)
27 dnl Gives misleading `(cached)' message from the check.
29 if test "$CC_FOR_TARGET"; then
32 CC="../../xgcc -B../../xgcc/"
36 dnl Checks for programs.
37 # For g77 we'll set CC to point at the built gcc, but this will get it into
43 dnl These should be inherited in the recursive make, but ensure they are
47 if test "$RANLIB"; then :
49 dnl Make sure that RANLIB_TEST is set also.
50 if test -z "$RANLIB_TEST"; then
59 dnl not needed for g77?
62 dnl Checks for libraries.
64 dnl Checks for header files.
65 # Sanity check for the cross-compilation case:
66 AC_CHECK_HEADER(stdio.h,:,
67 [AC_MSG_ERROR([Can't find stdio.h.
68 You must have a usable C system for the target already installed, at least
69 including headers and, preferably, the library, before you can configure
70 the G77 runtime system. If necessary, install gcc now with \`LANGUAGES=c',
71 then the target library, then build with \`LANGUAGES=f77'.])])
74 dnl We could do this if we didn't know we were using gcc
75 dnl AC_MSG_CHECKING(for prototype-savvy compiler)
76 dnl AC_CACHE_VAL(g77_cv_sys_proto,
78 dnl dnl looks screwy because TRY_LINK expects a function body
79 dnl [return 0;} int foo (int * bar) {],
80 dnl g77_cv_sys_proto=yes,
81 dnl [g77_cv_sys_proto=no
82 dnl AC_DEFINE(KR_headers)])])
83 dnl AC_MSG_RESULT($g77_cv_sys_proto)
86 dnl AC_CHECK_HEADERS(unistd.h)
88 AC_MSG_CHECKING(for posix)
89 AC_CACHE_VAL(g77_cv_header_posix,
91 [#include <sys/types.h>
97 g77_cv_header_posix=yes,
98 g77_cv_header_posix=no))
99 AC_MSG_RESULT($g77_cv_header_posix)
101 # We can rely on the GNU library being posix-ish. I guess checking the
102 # header isn't actually like checking the functions, though...
103 AC_MSG_CHECKING(for GNU library)
104 AC_CACHE_VAL(g77_cv_lib_gnu,
107 #ifdef __GNU_LIBRARY__
111 g77_cv_lib_gnu=yes, g77_cv_lib_gnu=no))
112 AC_MSG_RESULT($g77_cv_lib_gnu)
114 # Apparently cygwin needs to be special-cased.
115 AC_MSG_CHECKING([for cyg\`win'32])
116 AC_CACHE_VAL(g77_cv_sys_cygwin32,
122 g77_cv_sys_cygwin32=yes,
123 g77_cv_sys_cygwin32=no))
124 AC_MSG_RESULT($g77_cv_sys_cygwin32)
127 AC_MSG_CHECKING([for mingw32])
128 AC_CACHE_VAL(g77_cv_sys_mingw32,
134 g77_cv_sys_mingw32=yes,
135 g77_cv_sys_mingw32=no))
136 AC_MSG_RESULT($g77_cv_sys_mingw32)
139 AC_CHECK_HEADER(fcntl.h,
140 test $g77_cv_header_posix = yes && AC_DEFINE(_POSIX_SOURCE),
141 AC_DEFINE(NO_FCNTL) AC_DEFINE(OPEN_DECL))
143 dnl Checks for typedefs, structures, and compiler characteristics.
147 dnl Checks for library functions.
149 # we'll get atexit by default
150 if test $ac_cv_header_stdc != yes; then
151 AC_CHECK_FUNC(atexit,
152 AC_DEFINE(onexit,atexit),dnl just in case
153 [AC_DEFINE(NO_ONEXIT)
154 AC_CHECK_FUNC(onexit,,
155 [AC_CHECK_FUNC(on_exit,
156 AC_DEFINE(onexit,on_exit),)])])
160 # This should always succeed on unix.
161 # Apparently positive result on cygwin loses re. NON_UNIX_STDIO
162 # (as of cygwin b18). Likewise on mingw.
164 AC_MSG_CHECKING([need for NON_UNIX_STDIO])
165 if test $g77_cv_sys_cygwin32 = yes \
166 || test $g77_cv_sys_mingw32 = yes \
167 || test $ac_cv_func_fstat = no; then
169 AC_DEFINE(NON_UNIX_STDIO)
174 # This is necessary for e.g. Linux:
175 AC_MSG_CHECKING([for necessary members of struct FILE])
176 AC_CACHE_VAL(g77_cv_struct_FILE,
177 [AC_TRY_COMPILE([#include <stdio.h>],
178 [FILE s; s._ptr; s._base; s._flag;],g77_cv_struct_FILE=yes,
179 g77_cv_struct_FILE=no)])dnl
180 AC_MSG_RESULT($g77_cv_struct_FILE)
181 if test $g77_cv_struct_FILE = no; then
182 AC_DEFINE(MISSING_FILE_ELEMS)
185 dnl perhaps should check also for remainder
186 dnl Unfortunately, the message implies we're just checking for -lm...
187 AC_CHECK_LIB(m,drem,AC_DEFINE(IEEE_drem))
190 dnl AC_CHECK_FUNCS(symlink getcwd lstat)
191 dnl test $ac_cv_func_symlink = yes && SYMLNK=symlnk_.o
192 dnl test $ac_cv_func_lstat = yes && SYMLNK="$SYMLNK lstat_.o"
195 AC_CHECK_FUNCS(tempnam)
197 # posix will guarantee the right behaviour for sprintf, else we can't be
198 # sure; HEADER_STDC wouldn't be the right check in sunos4, for instance.
199 # However, on my sunos4/gcc setup unistd.h leads us wrongly to believe
200 # we're posix-conformant, so always do the test.
201 AC_MSG_CHECKING(for ansi/posix sprintf result)
202 dnl This loses if included as an argument to AC_CACHE_VAL because the
203 dnl changequote doesn't take effect and the [] vanish.
204 dnl fixme: use cached value
205 AC_TRY_RUN(changequote(<<, >>)dnl
207 /* does sprintf return the number of chars transferred? */
208 main () {char foo[2]; (sprintf(foo, "1") == 1) ? exit(0) : exit(1);}
210 g77_cv_sys_sprintf_ansi=yes,
211 g77_cv_sys_sprintf_ansi=no,
212 g77_cv_sys_sprintf_ansi=no)
213 AC_CACHE_VAL(g77_cv_sys_sprintf_ansi,
214 g77_cv_sys_sprintf_ansi=$g77_cv_sys_sprintf_ansi)
215 dnl We get a misleading `(cached)' message...
216 if test $ac_cv_c_cross = no; then
217 AC_MSG_RESULT($g77_cv_sys_sprintf_ansi)
219 AC_MSG_RESULT([can't tell -- assuming no])
221 # The cygwin patch takes steps to avoid defining USE_STRLEN here -- I don't
223 if test $g77_cv_sys_sprintf_ansi != yes; then
224 AC_DEFINE(USE_STRLEN)
227 # define NON_ANSI_RW_MODES on unix (can't hurt)
228 AC_MSG_CHECKING(NON_ANSI_RW_MODES)
239 ], is_unix=yes, is_unix=no)
240 if test $g77_cv_sys_cygwin32 = yes || test $g77_cv_sys_mingw32 = yes; then
243 if test $is_unix = yes; then
244 AC_DEFINE(NON_ANSI_RW_MODES)
251 # We have to firkle with the info in hconfig.h to figure out suitable types
252 # (via com.h). proj.h and com.h are in $srcdir/.., config.h which they need
253 # is in ../.. and the config files are in $srcdir/../../config.
254 AC_MSG_CHECKING(f2c integer type)
256 ac_cpp="$late_ac_cpp -I../../gcc/f -I../../gcc -I../../gcc/config"
257 if test "$subdir" != . ; then
258 ac_cpp="$ac_cpp -I$srcdir/../gcc/f -I$srcdir/../gcc -I$srcdir/../gcc/config"
260 AC_CACHE_VAL(g77_cv_sys_f2cinteger,
261 echo "configure:__oline__: using $ac_cpp" >&AC_FD_CC
262 AC_EGREP_CPP(F2C_INTEGER=long int,
264 #define FFECOM_DETERMINE_TYPES 1
266 #if FFECOM_f2cINTEGER == FFECOM_f2ccodeLONG
268 #elif FFECOM_f2cINTEGER == FFECOM_f2ccodeINT
271 # error "Cannot find a suitable type for F2C_INTEGER"
274 g77_cv_sys_f2cinteger="long int",)
275 if test "$g77_cv_sys_f2cinteger" = ""; then
276 echo "configure:__oline__: using $ac_cpp" >&AC_FD_CC
277 AC_EGREP_CPP(F2C_INTEGER=int,
279 #define FFECOM_DETERMINE_TYPES 1
281 #if FFECOM_f2cINTEGER == FFECOM_f2ccodeLONG
283 #elif FFECOM_f2cINTEGER == FFECOM_f2ccodeINT
286 # error "Cannot find a suitable type for F2C_INTEGER"
289 g77_cv_sys_f2cinteger=int,)
291 if test "$g77_cv_sys_f2cinteger" = ""; then
293 AC_MSG_ERROR([Can't determine type for f2c integer; config.log may help.])
296 AC_MSG_RESULT($g77_cv_sys_f2cinteger)
297 F2C_INTEGER=$g77_cv_sys_f2cinteger
299 AC_SUBST(F2C_INTEGER)
301 AC_MSG_CHECKING(f2c long int type)
303 ac_cpp="$late_ac_cpp -I../../gcc/f -I../../gcc -I../../gcc/config"
304 if test "$subdir" != . ; then
305 ac_cpp="$ac_cpp -I$srcdir/../gcc/f -I$srcdir/../gcc -I$srcdir/../gcc/config"
307 AC_CACHE_VAL(g77_cv_sys_f2clongint,
308 echo "configure:__oline__: using $ac_cpp" >&AC_FD_CC
309 AC_EGREP_CPP(F2C_LONGINT=long int,
311 #define FFECOM_DETERMINE_TYPES 1
313 #if FFECOM_f2cLONGINT == FFECOM_f2ccodeLONG
315 #elif FFECOM_f2cLONGINT == FFECOM_f2ccodeLONGLONG
316 F2C_LONGINT=long long int
318 # error "Cannot find a suitable type for F2C_LONGINT"
321 g77_cv_sys_f2clongint="long int",)
322 if test "$g77_cv_sys_f2clongint" = ""; then
323 echo "configure:__oline__: using $ac_cpp" >&AC_FD_CC
324 AC_EGREP_CPP(F2C_LONGINT=long long int,
326 #define FFECOM_DETERMINE_TYPES 1
328 #if FFECOM_f2cLONGINT == FFECOM_f2ccodeLONG
330 #elif FFECOM_f2cLONGINT == FFECOM_f2ccodeLONGLONG
331 F2C_LONGINT=long long int
333 # error "Cannot find a suitable type for F2C_LONGINT"
336 g77_cv_sys_f2clongint="long long int",)
338 if test "$g77_cv_sys_f2clongint" = ""; then
340 AC_MSG_ERROR([Can't determine type for f2c long int; config.log may help.])
343 AC_MSG_RESULT($g77_cv_sys_f2clongint)
344 F2C_LONGINT=$g77_cv_sys_f2clongint
346 AC_SUBST(F2C_LONGINT)
348 dnl maybe check for drem/remainder
353 # This EOF_CHAR is a misfeature on unix.
354 AC_DEFINE(NO_EOF_CHAR_CHECK)
356 AC_DEFINE(Skip_f2c_Undefs)
358 dnl Craig had these in f2c.h, but they're only relevant for building libf2c
361 dnl For GNU Fortran (g77), we always enable the following behaviors for
362 dnl libf2c, to make things easy on the programmer. The alternate
363 dnl behaviors have their uses, and g77 might provide them as compiler,
364 dnl rather than library, options, so only a single copy of a shared libf2c
365 dnl need be built for a system.
367 dnl This makes unformatted I/O more consistent in relation to other
368 dnl systems. It is not required by the F77 standard.
370 AC_DEFINE(Pad_UDread)
372 dnl This makes ERR= and IOSTAT= returns work properly in disk-full
373 dnl situations, making things work more as expected. It slows things
374 dnl down, so g77 will probably someday choose the original implementation
375 dnl on a case-by-case basis when it can be shown to not be necessary
376 dnl (e.g. no ERR= or IOSTAT=) or when it is given the appropriate
377 dnl compile-time option or, perhaps, source-code directive.
379 dnl AC_DEFINE(ALWAYS_FLUSH)
381 dnl Most Fortran implementations do this, so to make it easier
382 dnl to compare the output of g77-compiled programs to those compiled
383 dnl by most other compilers, tell libf2c to put leading zeros in
384 dnl appropriate places on output
386 AC_DEFINE(WANT_LEAD_0)
388 # avoid confusion in case the `makefile's from the f2c distribution have
390 test -f libF77/makefile && mv libF77/makefile libF77/makefile.ori
391 test -f libI77/makefile && mv libI77/makefile libI77/makefile.ori
392 test -f libU77/makefile && mv libU77/makefile libU77/makefile.ori
394 AC_CONFIG_SUBDIRS(libU77)
395 AC_OUTPUT(Makefile f2c.h libI77/Makefile libF77/Makefile)
397 dnl We might have configuration options to:
398 dnl * allow non-standard string concatenation (use libF77 s_catow.o,
400 dnl * change unit preconnexion in libI77/err.c (f_init.c)
401 dnl * -DALWAYS_FLUSH in libI77
402 dnl * -DOMIT_BLANK_CC in libI77
405 dnl comment-start: "dnl "
407 dnl comment-start-skip: "\\bdnl\\b\\s *"