OSDN Git Service

* Previous contents of gcc/f/runtime moved into toplevel
[pf3gnuchains/gcc-fork.git] / libf2c / configure.in
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
24 AC_REVISION(1.10)
25
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
30 dnl AC_C_CROSS
31 dnl Gives misleading `(cached)' message from the check.
32 if test "$CROSS";then
33   ac_cv_c_cross=yes
34 else
35   ac_cv_c_cross=no
36 fi
37
38 dnl These should be inherited in the recursive make, but ensure they are
39 dnl defined:
40 test "$AR" || AR=ar
41 AC_SUBST(AR)
42 if test "$RANLIB"; then :
43   AC_SUBST(RANLIB)
44 dnl Make sure that RANLIB_TEST is set also.
45   if test -z "$RANLIB_TEST"; then
46     RANLIB_TEST=true
47   fi
48 else
49   RANLIB_TEST=true
50   AC_PROG_RANLIB
51 fi
52 AC_SUBST(RANLIB_TEST)
53
54 dnl not needed for g77?
55 dnl AC_PROG_MAKE_SET
56
57 dnl Checks for libraries.
58
59 dnl Checks for header files.
60 # Sanity check for the cross-compilation case:
61 AC_CHECK_HEADER(stdio.h,:,
62   [AC_MSG_ERROR([Can't find stdio.h.
63 You must have a usable C system for the target already installed, at least
64 including headers and, preferably, the library, before you can configure
65 the G77 runtime system.  If necessary, install gcc now with \`LANGUAGES=c',
66 then the target library, then build with \`LANGUAGES=f77'.])])
67
68 AC_HEADER_STDC
69 dnl We could do this if we didn't know we were using gcc
70 dnl AC_MSG_CHECKING(for prototype-savvy compiler)
71 dnl AC_CACHE_VAL(g77_cv_sys_proto,                
72 dnl   [AC_TRY_LINK(,                             
73 dnl dnl looks screwy because TRY_LINK expects a function body
74 dnl    [return 0;} int foo (int * bar) {],       
75 dnl    g77_cv_sys_proto=yes,                      
76 dnl    [g77_cv_sys_proto=no                       
77 dnl     AC_DEFINE(KR_headers)])])                
78 dnl AC_MSG_RESULT($g77_cv_sys_proto)              
79
80 dnl for U77
81 dnl AC_CHECK_HEADERS(unistd.h)
82
83 AC_MSG_CHECKING(for posix)
84 AC_CACHE_VAL(g77_cv_header_posix,
85   AC_EGREP_CPP(yes,
86   [#include <sys/types.h>
87 #include <unistd.h>
88 #ifdef _POSIX_VERSION
89   yes
90 #endif
91 ], 
92   g77_cv_header_posix=yes,
93   g77_cv_header_posix=no))
94 AC_MSG_RESULT($g77_cv_header_posix)
95
96 # We can rely on the GNU library being posix-ish.  I guess checking the 
97 # header isn't actually like checking the functions, though...
98 AC_MSG_CHECKING(for GNU library)
99 AC_CACHE_VAL(g77_cv_lib_gnu,
100   AC_EGREP_CPP(yes,
101     [#include <stdio.h>
102 #ifdef __GNU_LIBRARY__
103   yes
104 #endif
105 ], 
106   g77_cv_lib_gnu=yes, g77_cv_lib_gnu=no))
107 AC_MSG_RESULT($g77_cv_lib_gnu)
108
109 # Apparently cygwin needs to be special-cased.
110 AC_MSG_CHECKING([for cyg\`win'32])
111 AC_CACHE_VAL(g77_cv_sys_cygwin32,
112   AC_EGREP_CPP(yes,
113   [#ifdef __CYGWIN32__
114   yes
115 #endif
116 ],
117   g77_cv_sys_cygwin32=yes,
118   g77_cv_sys_cygwin32=no))
119 AC_MSG_RESULT($g77_cv_sys_cygwin32)
120
121 # ditto for mingw32.
122 AC_MSG_CHECKING([for mingw32])
123 AC_CACHE_VAL(g77_cv_sys_mingw32,
124   AC_EGREP_CPP(yes,
125   [#ifdef __MINGW32__
126   yes
127 #endif
128 ],
129   g77_cv_sys_mingw32=yes,
130   g77_cv_sys_mingw32=no))
131 AC_MSG_RESULT($g77_cv_sys_mingw32)
132
133
134 AC_CHECK_HEADER(fcntl.h,
135    test $g77_cv_header_posix = yes && AC_DEFINE(_POSIX_SOURCE),
136    AC_DEFINE(NO_FCNTL) AC_DEFINE(OPEN_DECL))
137
138 dnl Checks for typedefs, structures, and compiler characteristics.
139 AC_C_CONST
140 AC_TYPE_SIZE_T
141
142 dnl Checks for library functions.
143 AC_TYPE_SIGNAL
144 # we'll get atexit by default
145 if test $ac_cv_header_stdc != yes; then
146 AC_CHECK_FUNC(atexit,
147   AC_DEFINE(onexit,atexit),dnl just in case
148   [AC_DEFINE(NO_ONEXIT)
149   AC_CHECK_FUNC(onexit,,
150     [AC_CHECK_FUNC(on_exit,
151      AC_DEFINE(onexit,on_exit),)])])
152 else true
153 fi
154
155 # This should always succeed on unix.
156 # Apparently positive result on cygwin loses re. NON_UNIX_STDIO
157 # (as of cygwin b18). Likewise on mingw.
158 AC_CHECK_FUNC(fstat)
159 AC_MSG_CHECKING([need for NON_UNIX_STDIO])
160 if test $g77_cv_sys_cygwin32 = yes \
161   || test $g77_cv_sys_mingw32 = yes \
162   || test $ac_cv_func_fstat = no; then
163   AC_MSG_RESULT(yes)
164   AC_DEFINE(NON_UNIX_STDIO)
165 else
166   AC_MSG_RESULT(no)
167 fi
168
169 # This is necessary for e.g. Linux:
170 AC_MSG_CHECKING([for necessary members of struct FILE])
171 AC_CACHE_VAL(g77_cv_struct_FILE,
172 [AC_TRY_COMPILE([#include <stdio.h>],
173   [FILE s; s._ptr; s._base; s._flag;],g77_cv_struct_FILE=yes,
174   g77_cv_struct_FILE=no)])dnl
175 AC_MSG_RESULT($g77_cv_struct_FILE)
176 if test $g77_cv_struct_FILE = no; then
177   AC_DEFINE(MISSING_FILE_ELEMS)
178 fi
179
180 dnl perhaps should check also for remainder
181 dnl Unfortunately, the message implies we're just checking for -lm...
182 AC_CHECK_LIB(m,drem,AC_DEFINE(IEEE_drem))
183
184 dnl for U77:
185 dnl AC_CHECK_FUNCS(symlink getcwd lstat)
186 dnl test $ac_cv_func_symlink = yes && SYMLNK=symlnk_.o
187 dnl test $ac_cv_func_lstat = yes && SYMLNK="$SYMLNK lstat_.o"
188 dnl AC_SUBST(SYMLNK)
189
190 # posix will guarantee the right behaviour for sprintf, else we can't be
191 # sure; HEADER_STDC wouldn't be the right check in sunos4, for instance.
192 # However, on my sunos4/gcc setup unistd.h leads us wrongly to believe
193 # we're posix-conformant, so always do the test.
194 AC_MSG_CHECKING(for ansi/posix sprintf result)
195 dnl This loses if included as an argument to AC_CACHE_VAL because the
196 dnl changequote doesn't take effect and the [] vanish.
197 dnl fixme: use cached value
198 AC_TRY_RUN(changequote(<<, >>)dnl
199   <<#include <stdio.h>
200     /* does sprintf return the number of chars transferred? */
201     main () {char foo[2]; (sprintf(foo, "1") == 1) ? exit(0) : exit(1);}
202 >>changequote([, ]),
203     g77_cv_sys_sprintf_ansi=yes,
204     g77_cv_sys_sprintf_ansi=no,
205     g77_cv_sys_sprintf_ansi=no)
206 AC_CACHE_VAL(g77_cv_sys_sprintf_ansi,
207      g77_cv_sys_sprintf_ansi=$g77_cv_sys_sprintf_ansi)
208 dnl We get a misleading `(cached)' message...
209 if test $ac_cv_c_cross = no; then
210   AC_MSG_RESULT($g77_cv_sys_sprintf_ansi)
211 else
212   AC_MSG_RESULT([can't tell -- assuming no])
213 fi
214 # The cygwin patch takes steps to avoid defining USE_STRLEN here -- I don't
215 # understand why.
216 if test $g77_cv_sys_sprintf_ansi != yes; then 
217   AC_DEFINE(USE_STRLEN)
218 fi
219
220 # define NON_ANSI_RW_MODES on unix (can't hurt)
221 AC_MSG_CHECKING(NON_ANSI_RW_MODES)
222 AC_EGREP_CPP(yes,
223 [#ifdef unix
224   yes
225 #endif
226 #ifdef __unix
227   yes
228 #endif
229 #ifdef __unix__
230   yes
231 #endif
232 ], is_unix=yes, is_unix=no)
233 if test $g77_cv_sys_cygwin32 = yes || test $g77_cv_sys_mingw32 = yes; then
234   AC_MSG_RESULT(no)
235 else
236   if test $is_unix = yes; then
237     AC_DEFINE(NON_ANSI_RW_MODES)
238     AC_MSG_RESULT(yes)
239   else
240     AC_MSG_RESULT(no)
241   fi
242 fi
243
244 # We have to firkle with the info in hconfig.h to figure out suitable types
245 # (via com.h).  proj.h and com.h are in $srcdir/.., config.h which they need
246 # is in ../.. and the config files are in $srcdir/../../config.
247 AC_MSG_CHECKING(f2c integer type)
248 late_ac_cpp=$ac_cpp
249 ac_cpp="$late_ac_cpp -I$srcdir/.. -I../.. -I$srcdir/../.. -I$srcdir/../../config"
250 AC_CACHE_VAL(g77_cv_sys_f2cinteger,
251 AC_EGREP_CPP(F2C_INTEGER=long int,
252 [#include "proj.h"
253 #define FFECOM_DETERMINE_TYPES 1
254 #include "com.h"
255 #if FFECOM_f2cINTEGER == FFECOM_f2ccodeLONG
256 F2C_INTEGER=long int
257 #elif FFECOM_f2cINTEGER == FFECOM_f2ccodeINT
258 F2C_INTEGER=int
259 #else
260 #  error "Cannot find a suitable type for F2C_INTEGER"
261 #endif
262 ],
263  g77_cv_sys_f2cinteger="long int",)
264 if test "$g77_cv_sys_f2cinteger" = ""; then
265   AC_EGREP_CPP(F2C_INTEGER=int,
266 [#include "proj.h"
267 #define FFECOM_DETERMINE_TYPES 1
268 #include "com.h"
269 #if FFECOM_f2cINTEGER == FFECOM_f2ccodeLONG
270 F2C_INTEGER=long int
271 #elif FFECOM_f2cINTEGER == FFECOM_f2ccodeINT
272 F2C_INTEGER=int
273 #else
274 #  error "Cannot find a suitable type for F2C_INTEGER"
275 #endif
276 ],
277    g77_cv_sys_f2cinteger=int,)
278 fi
279 if test "$g77_cv_sys_f2cinteger" = ""; then
280   AC_MSG_RESULT("")
281   AC_MSG_ERROR([Can't determine type for f2c integer; config.log may help.])
282 fi
283 )
284 AC_MSG_RESULT($g77_cv_sys_f2cinteger)
285 F2C_INTEGER=$g77_cv_sys_f2cinteger
286 ac_cpp=$late_ac_cpp
287 AC_SUBST(F2C_INTEGER)
288
289 AC_MSG_CHECKING(f2c long int type)
290 late_ac_cpp=$ac_cpp
291 ac_cpp="$late_ac_cpp -I$srcdir/.. -I../.. -I$srcdir/../.. -I$srcdir/../../config"
292 AC_CACHE_VAL(g77_cv_sys_f2clongint,
293 AC_EGREP_CPP(F2C_LONGINT=long int,
294 [#include "proj.h"
295 #define FFECOM_DETERMINE_TYPES 1
296 #include "com.h"
297 #if FFECOM_f2cLONGINT == FFECOM_f2ccodeLONG
298 F2C_LONGINT=long int
299 #elif FFECOM_f2cLONGINT == FFECOM_f2ccodeLONGLONG
300 F2C_LONGINT=long long int
301 #else
302 #  error "Cannot find a suitable type for F2C_LONGINT"
303 #endif
304 ],
305  g77_cv_sys_f2clongint="long int",)
306 if test "$g77_cv_sys_f2clongint" = ""; then
307   AC_EGREP_CPP(F2C_LONGINT=long long int,
308 [#include "proj.h"
309 #define FFECOM_DETERMINE_TYPES 1
310 #include "com.h"
311 #if FFECOM_f2cLONGINT == FFECOM_f2ccodeLONG
312 F2C_LONGINT=long int
313 #elif FFECOM_f2cLONGINT == FFECOM_f2ccodeLONGLONG
314 F2C_LONGINT=long long int
315 #else
316 #  error "Cannot find a suitable type for F2C_LONGINT"
317 #endif
318 ],
319    g77_cv_sys_f2clongint="long long int",)
320 fi
321 if test "$g77_cv_sys_f2clongint" = ""; then
322   AC_MSG_RESULT("")
323   AC_MSG_ERROR([Can't determine type for f2c long int; config.log may help.])
324 fi
325 )
326 AC_MSG_RESULT($g77_cv_sys_f2clongint)
327 F2C_LONGINT=$g77_cv_sys_f2clongint
328 ac_cpp=$late_ac_cpp
329 AC_SUBST(F2C_LONGINT)
330
331 dnl maybe check for drem/remainder
332
333 AC_SUBST(CROSS)
334
335
336 # This EOF_CHAR is a misfeature on unix.
337 AC_DEFINE(NO_EOF_CHAR_CHECK)
338
339 AC_DEFINE(Skip_f2c_Undefs)
340
341 dnl Craig had these in f2c.h, but they're only relevant for building libf2c
342 dnl anyway.
343
344 dnl   For GNU Fortran (g77), we always enable the following behaviors for
345 dnl   libf2c, to make things easy on the programmer.  The alternate
346 dnl   behaviors have their uses, and g77 might provide them as compiler,
347 dnl   rather than library, options, so only a single copy of a shared libf2c
348 dnl   need be built for a system.
349
350 dnl   This makes unformatted I/O more consistent in relation to other
351 dnl   systems.  It is not required by the F77 standard.
352
353 AC_DEFINE(Pad_UDread)
354
355 dnl   This makes ERR= and IOSTAT= returns work properly in disk-full
356 dnl   situations, making things work more as expected.  It slows things
357 dnl   down, so g77 will probably someday choose the original implementation
358 dnl   on a case-by-case basis when it can be shown to not be necessary
359 dnl   (e.g. no ERR= or IOSTAT=) or when it is given the appropriate
360 dnl   compile-time option or, perhaps, source-code directive.
361
362 dnl AC_DEFINE(ALWAYS_FLUSH)
363
364 dnl   Most Fortran implementations do this, so to make it easier
365 dnl   to compare the output of g77-compiled programs to those compiled
366 dnl   by most other compilers, tell libf2c to put leading zeros in
367 dnl   appropriate places on output
368
369 AC_DEFINE(WANT_LEAD_0)
370
371 # avoid confusion in case the `makefile's from the f2c distribution have
372 # got put here
373 test -f libF77/makefile && mv libF77/makefile  libF77/makefile.ori
374 test -f libI77/makefile && mv libI77/makefile  libI77/makefile.ori
375 test -f libU77/makefile && mv libU77/makefile  libU77/makefile.ori
376
377 AC_CONFIG_SUBDIRS(libU77)
378 AC_OUTPUT(Makefile f2c.h libI77/Makefile libF77/Makefile)
379
380 dnl We might have configuration options to:
381 dnl * allow non-standard string concatenation (use libF77 s_catow.o,
382 dnl   not s_cat.o)
383 dnl * change unit preconnexion in libI77/err.c (f_init.c)
384 dnl * -DALWAYS_FLUSH in libI77
385 dnl * -DOMIT_BLANK_CC in libI77
386
387 dnl Local Variables:
388 dnl comment-start: "dnl "
389 dnl comment-end: ""
390 dnl comment-start-skip: "\\bdnl\\b\\s *"
391 dnl End: