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)
26 dnl Checks for programs.
27 # For g77 we'll set CC to point at the built gcc, but this will get it into
31 dnl These should be inherited in the recursive make, but ensure they are
35 if test "$RANLIB"; then :
37 dnl Make sure that RANLIB_TEST is set also.
38 if test -z "$RANLIB_TEST"; then
47 dnl not needed for g77?
50 dnl Checks for libraries.
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'.])])
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,
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)
74 dnl AC_CHECK_HEADERS(unistd.h)
76 AC_MSG_CHECKING(for posix)
77 AC_CACHE_VAL(g77_cv_header_posix,
79 [#include <sys/types.h>
85 g77_cv_header_posix=yes,
86 g77_cv_header_posix=no))
87 AC_MSG_RESULT($g77_cv_header_posix)
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,
95 #ifdef __GNU_LIBRARY__
99 g77_cv_lib_gnu=yes, g77_cv_lib_gnu=no))
100 AC_MSG_RESULT($g77_cv_lib_gnu)
102 # Apparently cygwin needs to be special-cased.
103 AC_MSG_CHECKING([for cyg\`win'32])
104 AC_CACHE_VAL(g77_cv_sys_cygwin32,
110 g77_cv_sys_cygwin32=yes,
111 g77_cv_sys_cygwin32=no))
112 AC_MSG_RESULT($g77_cv_sys_cygwin32)
115 AC_MSG_CHECKING([for mingw32])
116 AC_CACHE_VAL(g77_cv_sys_mingw32,
122 g77_cv_sys_mingw32=yes,
123 g77_cv_sys_mingw32=no))
124 AC_MSG_RESULT($g77_cv_sys_mingw32)
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))
131 dnl Checks for typedefs, structures, and compiler characteristics.
135 dnl Checks for library functions.
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),)])])
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.
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
157 AC_DEFINE(NON_UNIX_STDIO)
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)
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))
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"
183 AC_CHECK_FUNCS(tempnam)
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
195 /* does sprintf return the number of chars transferred? */
196 main () {char foo[2]; (sprintf(foo, "1") == 1) ? exit(0) : exit(1);}
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...
204 AC_MSG_RESULT($g77_cv_sys_sprintf_ansi)
206 # The cygwin patch takes steps to avoid defining USE_STRLEN here -- I don't
208 if test $g77_cv_sys_sprintf_ansi != yes; then
209 AC_DEFINE(USE_STRLEN)
212 # define NON_ANSI_RW_MODES on unix (can't hurt)
213 AC_MSG_CHECKING(NON_ANSI_RW_MODES)
224 ], is_unix=yes, is_unix=no)
225 if test $g77_cv_sys_cygwin32 = yes || test $g77_cv_sys_mingw32 = yes; then
228 if test $is_unix = yes; then
229 AC_DEFINE(NON_ANSI_RW_MODES)
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)
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"
245 AC_CACHE_VAL(g77_cv_sys_f2cinteger,
246 echo "configure:__oline__: using $ac_cpp" >&AC_FD_CC
247 AC_EGREP_CPP(F2C_INTEGER=long int,
249 #define FFECOM_DETERMINE_TYPES 1
251 #if FFECOM_f2cINTEGER == FFECOM_f2ccodeLONG
253 #elif FFECOM_f2cINTEGER == FFECOM_f2ccodeINT
256 # error "Cannot find a suitable type for F2C_INTEGER"
259 g77_cv_sys_f2cinteger="long int",)
260 if test "$g77_cv_sys_f2cinteger" = ""; then
261 echo "configure:__oline__: using $ac_cpp" >&AC_FD_CC
262 AC_EGREP_CPP(F2C_INTEGER=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=int,)
276 if test "$g77_cv_sys_f2cinteger" = ""; then
278 AC_MSG_ERROR([Can't determine type for f2c integer; config.log may help.])
281 AC_MSG_RESULT($g77_cv_sys_f2cinteger)
282 F2C_INTEGER=$g77_cv_sys_f2cinteger
284 AC_SUBST(F2C_INTEGER)
286 AC_MSG_CHECKING(f2c long int type)
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"
292 AC_CACHE_VAL(g77_cv_sys_f2clongint,
293 echo "configure:__oline__: using $ac_cpp" >&AC_FD_CC
294 AC_EGREP_CPP(F2C_LONGINT=long int,
296 #define FFECOM_DETERMINE_TYPES 1
298 #if FFECOM_f2cLONGINT == FFECOM_f2ccodeLONG
300 #elif FFECOM_f2cLONGINT == FFECOM_f2ccodeLONGLONG
301 F2C_LONGINT=long long int
303 # error "Cannot find a suitable type for F2C_LONGINT"
306 g77_cv_sys_f2clongint="long int",)
307 if test "$g77_cv_sys_f2clongint" = ""; then
308 echo "configure:__oline__: using $ac_cpp" >&AC_FD_CC
309 AC_EGREP_CPP(F2C_LONGINT=long 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 long int",)
323 if test "$g77_cv_sys_f2clongint" = ""; then
325 AC_MSG_ERROR([Can't determine type for f2c long int; config.log may help.])
328 AC_MSG_RESULT($g77_cv_sys_f2clongint)
329 F2C_LONGINT=$g77_cv_sys_f2clongint
331 AC_SUBST(F2C_LONGINT)
333 dnl maybe check for drem/remainder
335 # This EOF_CHAR is a misfeature on unix.
336 AC_DEFINE(NO_EOF_CHAR_CHECK)
338 AC_DEFINE(Skip_f2c_Undefs)
340 # avoid confusion in case the `makefile's from the f2c distribution have
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
346 AC_CONFIG_SUBDIRS(libU77)
347 AC_OUTPUT(Makefile g2c.h libI77/Makefile libF77/Makefile)
349 dnl We might have configuration options to:
350 dnl * change unit preconnexion in libI77/err.c (f_init.c)
351 dnl * -DALWAYS_FLUSH in libI77
352 dnl * -DOMIT_BLANK_CC in libI77
355 dnl comment-start: "dnl "
357 dnl comment-start-skip: "\\bdnl\\b\\s *"