Merge from vendor branch NTPD:
[dragonfly.git] / contrib / libf2c / configure.in
1 # Process this file with autoconf to produce a configure script.
2 #   Copyright (C) 1995, 1997, 1998, 1999 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_PREREQ(2.13)
23 AC_INIT(libF77/Version.c)
24
25 if test "${srcdir}" = "."  ; then
26   if test "${with_target_subdir}" != "." ; then
27     topsrcdir=${with_multisrctop}../..
28   else
29     topsrcdir=${with_multisrctop}..
30   fi
31 else
32   topsrcdir=${srcdir}/..
33 fi
34 dnl This is needed for a multilibbed build in the source tree so
35 dnl that install-sh and config.sub get found.
36 AC_CONFIG_AUX_DIR($topsrcdir)
37
38 # If the language specific compiler does not exist, but the "gcc" directory 
39 # does, we do not build anything. Note, $r is set by the top-level Makefile.
40 # Note that when we look for the compiler, we search both with and without
41 # extension to handle cross and canadian cross builds. 
42 compiler_name=f771
43 rm -f skip-this-dir
44 AC_MSG_CHECKING(if compiler $compiler_name has been built)
45 AC_CACHE_VAL(g77_cv_compiler_exists,
46 [g77_cv_compiler_exists=yes
47 if test -n "$r"; then
48   if test -d "$r"/gcc; then
49     if test -f "$r"/gcc/$compiler_name \
50        || test -f "$r"/gcc/$compiler_name.exe; then
51       true
52     else
53       g77_cv_compiler_exists=no
54       echo "rm -f config.cache config.log multilib.out" > skip-this-dir
55     fi
56   fi
57 fi
58 ])
59 AC_MSG_RESULT($g77_cv_compiler_exists)
60 if test x$g77_cv_compiler_exists = xno
61 then
62   rm -f Makefile conftest* confdefs* core
63   exit 0
64 fi
65
66 dnl Checks for programs.
67 # For g77 we'll set CC to point at the built gcc, but this will get it into
68 # the makefiles
69 AC_PROG_CC
70
71 dnl These should be inherited in the recursive make, but ensure they are
72 dnl defined:
73 test "$AR" || AR=ar
74 AC_SUBST(AR)
75 if test "$RANLIB"; then :
76   AC_SUBST(RANLIB)
77 else
78   AC_PROG_RANLIB
79 fi
80 AC_PROG_INSTALL
81 AC_PROG_MAKE_SET
82
83 dnl Checks for header files.
84 # Sanity check for the cross-compilation case:
85 AC_CHECK_HEADER(stdio.h,:,
86   [AC_MSG_ERROR([Can't find stdio.h.
87 You must have a usable C system for the target already installed, at least
88 including headers and, preferably, the library, before you can configure
89 the G77 runtime system.  If necessary, install gcc now with \`LANGUAGES=c',
90 then the target library, then build with \`LANGUAGES=f77'.])])
91
92 # We have to firkle with the info in hconfig.h to figure out suitable types
93 # (via com.h).  proj.h and com.h are in gcc/f/, config.h which they need
94 # is in gcc/ and the config files are in gcc/config/.
95 AC_MSG_CHECKING(f2c integer type)
96 # Set this back later below!
97 late_ac_cpp=$ac_cpp
98 late_cflags=$CFLAGS
99 extra_includes="-I$topsrcdir/gcc/f -I$topsrcdir/gcc -I$topsrcdir/include -I$topsrcdir/gcc/config -I$r/gcc"
100 ac_cpp="$late_ac_cpp -DIN_GCC -DHAVE_CONFIG_H $extra_includes"
101
102 # The AC_EGREP_CPPs below have been known to fail when the header
103 # path is wrong after things have been moved about; the cpp error status
104 # counts for nothing.  First check that there aren't any errors from
105 # the headers.
106 CFLAGS="$CFLAGS -DHAVE_CONFIG_H -DIN_GCC $extra_includes"
107 AC_TRY_COMPILE([#include "proj.h"
108 #define FFECOM_DETERMINE_TYPES 1
109 #include "com.h"],,,
110 AC_MSG_ERROR([Can't run check for integer sizes -- see config.log]))
111 CFLAGS=$late_cflags
112
113 AC_CACHE_VAL(g77_cv_sys_f2cinteger,
114 echo "configure:__oline__: using $ac_cpp" >&AC_FD_CC
115 AC_EGREP_CPP(F2C_INTEGER=long int,
116 [#include "proj.h"
117 #define FFECOM_DETERMINE_TYPES 1
118 #include "com.h"
119 #if FFECOM_f2cINTEGER == FFECOM_f2ccodeLONG
120 F2C_INTEGER=long int
121 #elif FFECOM_f2cINTEGER == FFECOM_f2ccodeINT
122 F2C_INTEGER=int
123 #else
124 #  error "Cannot find a suitable type for F2C_INTEGER"
125 #endif
126 ],
127  g77_cv_sys_f2cinteger="long int",)
128 if test "$g77_cv_sys_f2cinteger" = ""; then
129 echo "configure:__oline__: using $ac_cpp" >&AC_FD_CC
130   AC_EGREP_CPP(F2C_INTEGER=int,
131 [#include "proj.h"
132 #define FFECOM_DETERMINE_TYPES 1
133 #include "com.h"
134 #if FFECOM_f2cINTEGER == FFECOM_f2ccodeLONG
135 F2C_INTEGER=long int
136 #elif FFECOM_f2cINTEGER == FFECOM_f2ccodeINT
137 F2C_INTEGER=int
138 #else
139 #  error "Cannot find a suitable type for F2C_INTEGER"
140 #endif
141 ],
142    g77_cv_sys_f2cinteger=int,)
143 fi
144 if test "$g77_cv_sys_f2cinteger" = ""; then
145   AC_MSG_RESULT("")
146   AC_MSG_ERROR([Can't determine type for f2c integer; config.log may help.])
147 fi
148 )
149 AC_MSG_RESULT($g77_cv_sys_f2cinteger)
150 F2C_INTEGER=$g77_cv_sys_f2cinteger
151 AC_SUBST(F2C_INTEGER)
152
153 AC_MSG_CHECKING(f2c long int type)
154 AC_CACHE_VAL(g77_cv_sys_f2clongint,
155 echo "configure:__oline__: using $ac_cpp" >&AC_FD_CC
156 AC_EGREP_CPP(F2C_LONGINT=long int,
157 [#include "proj.h"
158 #define FFECOM_DETERMINE_TYPES 1
159 #include "com.h"
160 #if FFECOM_f2cLONGINT == FFECOM_f2ccodeLONG
161 F2C_LONGINT=long int
162 #elif FFECOM_f2cLONGINT == FFECOM_f2ccodeLONGLONG
163 F2C_LONGINT=long long int
164 #else
165 #  error "Cannot find a suitable type for F2C_LONGINT"
166 #endif
167 ],
168  g77_cv_sys_f2clongint="long int",)
169
170 if test "$g77_cv_sys_f2clongint" = ""; then
171 echo "configure:__oline__: using $ac_cpp" >&AC_FD_CC
172   AC_EGREP_CPP(F2C_LONGINT=long long int,
173 [#include "proj.h"
174 #define FFECOM_DETERMINE_TYPES 1
175 #include "com.h"
176 #if FFECOM_f2cLONGINT == FFECOM_f2ccodeLONG
177 F2C_LONGINT=long int
178 #elif FFECOM_f2cLONGINT == FFECOM_f2ccodeLONGLONG
179 F2C_LONGINT=long long int
180 #else
181 #  error "Cannot find a suitable type for F2C_LONGINT"
182 #endif
183 ],
184    g77_cv_sys_f2clongint="long long int",)
185 fi
186 if test "$g77_cv_sys_f2clongint" = ""; then
187   AC_MSG_RESULT("")
188   AC_MSG_ERROR([Can't determine type for f2c long int; config.log may help.])
189 fi
190 )
191 AC_MSG_RESULT($g77_cv_sys_f2clongint)
192 F2C_LONGINT=$g77_cv_sys_f2clongint
193 AC_SUBST(F2C_LONGINT)
194 ac_cpp=$late_ac_cpp
195
196 # avoid confusion in case the `makefile's from the f2c distribution have
197 # got put here
198 test -f libF77/makefile && mv libF77/makefile  libF77/makefile.ori
199 test -f libI77/makefile && mv libI77/makefile  libI77/makefile.ori
200 test -f libU77/makefile && mv libU77/makefile  libU77/makefile.ori
201
202 # Get the version trigger filename from the toplevel
203 if [[ "${with_gcc_version_trigger+set}" = set ]]; then
204         gcc_version_trigger=$with_gcc_version_trigger
205         gcc_version=`sed -e 's/.*\"\([[^ \"]]*\)[[ \"]].*/\1/' < ${gcc_version_trigger}`
206 else
207         gcc_version_trigger=
208         gcc_version=UNKNOWN
209 fi
210
211 AC_SUBST(gcc_version)
212 AC_SUBST(gcc_version_trigger)
213 AC_CANONICAL_SYSTEM
214 AC_SUBST(target_alias)
215 AC_CONFIG_SUBDIRS(libU77 libI77 libF77)
216 # Do Makefile first since g2c.h depends on it and shouldn't get an
217 # earlier timestamp.  Of course, it does when the multilib gunk below
218 # edits Makefile, sigh; see additional touch below.
219 AC_OUTPUT(Makefile g2c.h:g2c.hin,
220  [test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
221 if test -n "$CONFIG_FILES"; then
222   if test -n "${with_target_subdir}"; then
223     # FIXME: We shouldn't need to set ac_file
224     ac_file=Makefile
225     . ${topsrcdir}/config-ml.in
226     touch g2c.h   # to keep it more recent than Makefile
227   fi
228 fi],
229 srcdir=${srcdir}
230 host=${host}
231 target=${target}
232 with_target_subdir=${with_target_subdir}
233 with_multisubdir=${with_multisubdir}
234 ac_configure_args="--enable-multilib ${ac_configure_args}"
235 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
236 topsrcdir=${topsrcdir}
237 )
238
239
240 dnl Local Variables:
241 dnl comment-start: "dnl "
242 dnl comment-end: ""
243 dnl comment-start-skip: "\\bdnl\\b\\s *"
244 dnl End: