OSDN Git Service

2005-05-19 David Ayers <d.ayers@inode.at>
[pf3gnuchains/gcc-fork.git] / libgfortran / configure.ac
1 # Process this file with autoconf to produce a configure script, like so:
2 # aclocal && autoconf && autoheader && automake
3
4 AC_PREREQ(2.59)
5 AC_INIT([GNU Fortran Runtime Library], 0.2,,[libgfortran])
6 AC_CONFIG_HEADER(config.h)
7
8 # -------
9 # Options
10 # -------
11
12 AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
13 AC_ARG_ENABLE(version-specific-runtime-libs,
14 [  --enable-version-specific-runtime-libs    Specify that runtime libraries should be installed in a compiler-specific directory ],
15 [case "$enableval" in
16  yes) version_specific_libs=yes ;;
17  no)  version_specific_libs=no ;;
18  *)   AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
19  esac],
20 [version_specific_libs=no])
21 AC_MSG_RESULT($version_specific_libs)
22
23
24 # Gets build, host, target, *_vendor, *_cpu, *_os, etc.
25 #
26 # You will slowly go insane if you do not grok the following fact:  when
27 # building this library, the top-level /target/ becomes the library's /host/.
28 #
29 # configure then causes --target to default to --host, exactly like any
30 # other package using autoconf.  Therefore, 'target' and 'host' will
31 # always be the same.  This makes sense both for native and cross compilers
32 # just think about it for a little while.  :-)
33 #
34 # Also, if this library is being configured as part of a cross compiler, the
35 # top-level configure script will pass the "real" host as $with_cross_host.
36 #
37 # Do not delete or change the following two lines.  For why, see
38 # http://gcc.gnu.org/ml/libstdc++/2003-07/msg00451.html
39 AC_CANONICAL_SYSTEM
40 target_alias=${target_alias-$host_alias}
41
42 # Sets up automake.  Must come after AC_CANONICAL_SYSTEM.  Each of the
43 # following is magically included in AUTOMAKE_OPTIONS in each Makefile.am.
44 #  1.8.2:  minimum required version
45 #  no-define:  PACKAGE and VERSION will not be #define'd in config.h (a bunch
46 #              of other PACKAGE_* variables will, however, and there's nothing
47 #              we can do about that; they come from AC_INIT).
48 #  foreign:  we don't follow the normal rules for GNU packages (no COPYING
49 #            file in the top srcdir, etc, etc), so stop complaining.
50 #  no-dependencies:  turns off auto dependency generation (just for now)
51 #  -Wall:  turns on all automake warnings...
52 #  -Wno-portability:  ...except this one, since GNU make is required.
53 AM_INIT_AUTOMAKE([1.8.2 no-define foreign no-dependencies -Wall -Wno-portability])
54
55 AM_MAINTAINER_MODE
56 AM_ENABLE_MULTILIB(, ..)
57
58 # Handy for debugging:
59 #AC_MSG_NOTICE($build / $host / $target / $host_alias / $target_alias); sleep 5
60
61 # Are we being configured with some form of cross compiler?
62 # NB: We don't actually need to know this just now, but when, say, a test
63 #     suite is included, we'll have to know.
64 if test "$build" != "$host"; then
65   LIBGFOR_IS_NATIVE=false
66   GCC_NO_EXECUTABLES
67 else
68   LIBGFOR_IS_NATIVE=true
69 fi
70
71 # Calculate toolexeclibdir
72 # Also toolexecdir, though it's only used in toolexeclibdir
73 case ${version_specific_libs} in
74   yes)
75     # Need the gcc compiler version to know where to install libraries
76     # and header files if --enable-version-specific-runtime-libs option
77     # is selected.
78     toolexecdir='$(libdir)/gcc/$(target_alias)'
79     toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)'
80     ;;
81   no)
82     if test -n "$with_cross_host" &&
83        test x"$with_cross_host" != x"no"; then
84       # Install a library built with a cross compiler in tooldir, not libdir.
85       toolexecdir='$(exec_prefix)/$(target_alias)'
86       toolexeclibdir='$(toolexecdir)/lib'
87     else
88       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
89       toolexeclibdir='$(libdir)'
90     fi
91     multi_os_directory=`$CC -print-multi-os-directory`
92     case $multi_os_directory in
93       .) ;; # Avoid trailing /.
94       *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
95     esac
96     ;;
97 esac
98 AC_SUBST(toolexecdir)
99 AC_SUBST(toolexeclibdir)
100
101 # Check the compiler.
102 # The same as in boehm-gc and libstdc++. Have to borrow it from there.
103 # We must force CC to /not/ be precious variables; otherwise
104 # the wrong, non-multilib-adjusted value will be used in multilibs.
105 # As a side effect, we have to subst CFLAGS ourselves.
106
107 m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
108 m4_define([_AC_ARG_VAR_PRECIOUS],[])
109 AC_PROG_CC
110 m4_rename([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
111
112 # Add -Wall if we are using GCC.
113 if test "x$GCC" = "xyes"; then
114   AM_FCFLAGS="-Wall"
115   ## We like to use C99 routines when available.  This makes sure that
116   ## __STDC_VERSION__ is set such that libc includes make them available.
117   AM_CFLAGS="-std=gnu99 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wextra -Wwrite-strings"
118 fi
119 AC_SUBST(AM_FCFLAGS)
120 AC_SUBST(AM_CFLAGS)
121
122 # Find other programs we need.
123 AC_CHECK_TOOL(AS, as)
124 AC_CHECK_TOOL(AR, ar)
125 AC_CHECK_TOOL(RANLIB, ranlib, ranlib-not-found-in-path-error)
126 AC_PROG_MAKE_SET
127 AC_PROG_INSTALL
128
129 # Configure libtool
130 #AC_MSG_NOTICE([====== Starting libtool configuration])
131 AC_LIBTOOL_DLOPEN
132 AM_PROG_LIBTOOL
133 AC_SUBST(enable_shared)
134 AC_SUBST(enable_static)
135 #AC_MSG_NOTICE([====== Finished libtool configuration]) ; sleep 10
136
137 # We need gfortran to compile parts of the library
138 # We can't use AC_PROG_FC because it expects a fully working gfortran.
139 #AC_PROG_FC(gfortran)
140 FC="$GFORTRAN"
141 AC_PROG_FC(gfortran)
142 FCFLAGS="$FCFLAGS -Wall -fno-repack-arrays -fno-underscoring"
143
144 # extra LD Flags which are required for targets
145 case "${host}" in
146   *-darwin*)
147     # Darwin needs -single_module when linking libgfortran
148     extra_ldflags_libgfortran=-Wl,-single_module
149     ;;
150 esac
151 AC_SUBST(extra_ldflags_libgfortran)
152
153 AC_SYS_LARGEFILE
154 AC_FUNC_MMAP
155 AC_TYPE_OFF_T
156
157 # check header files
158 AC_STDC_HEADERS
159 AC_HAVE_HEADERS(stdlib.h stdio.h string.h stddef.h math.h unistd.h signal.h)
160 AC_CHECK_HEADERS(time.h sys/params.h sys/time.h sys/times.h sys/resource.h)
161 AC_CHECK_HEADERS(sys/mman.h sys/types.h sys/stat.h ieeefp.h)
162 AC_CHECK_HEADER([complex.h],[AC_DEFINE([HAVE_COMPLEX_H], [1], [complex.h exists])])
163
164 AC_CHECK_MEMBERS([struct stat.st_blksize])
165 AC_CHECK_MEMBERS([struct stat.st_blocks])
166 AC_CHECK_MEMBERS([struct stat.st_rdev])
167
168 # Check for complex math functions
169 AC_CHECK_LIB([m],[csin],[need_math="no"],[need_math="yes"])
170
171 # Check for library functions.
172 AC_CHECK_FUNCS(getrusage times mkstemp strtof snprintf ftruncate chsize)
173 AC_CHECK_FUNCS(chdir strerror getlogin gethostname kill link symlink perror)
174 AC_CHECK_FUNCS(sleep time)
175
176 # Check libc for getgid, getpid, getuid
177 AC_CHECK_LIB([c],[getgid],[AC_DEFINE([HAVE_GETGID],[1],[libc includes getgid])])
178 AC_CHECK_LIB([c],[getpid],[AC_DEFINE([HAVE_GETPID],[1],[libc includes getpid])])
179 AC_CHECK_LIB([c],[getuid],[AC_DEFINE([HAVE_GETUID],[1],[libc includes getuid])])
180
181 # Check for C99 (and other IEEE) math functions
182 # ??? This list seems awful long. Is there a better way to test for these?
183 AC_CHECK_LIB([m],[acosf],[AC_DEFINE([HAVE_ACOSF],[1],[libm includes acosf])])
184 AC_CHECK_LIB([m],[asinf],[AC_DEFINE([HAVE_ASINF],[1],[libm includes asinf])])
185 AC_CHECK_LIB([m],[atan2f],[AC_DEFINE([HAVE_ATAN2F],[1],[libm includes atan2f])])
186 AC_CHECK_LIB([m],[atanf],[AC_DEFINE([HAVE_ATANF],[1],[libm includes atanf])])
187 AC_CHECK_LIB([m],[ceilf],[AC_DEFINE([HAVE_CEILF],[1],[libm includes ceilf])])
188 AC_CHECK_LIB([m],[copysignf],[AC_DEFINE([HAVE_COPYSIGNF],[1],[libm includes copysignf])])
189 AC_CHECK_LIB([m],[cosf],[AC_DEFINE([HAVE_COSF],[1],[libm includes cosf])])
190 AC_CHECK_LIB([m],[coshf],[AC_DEFINE([HAVE_COSHF],[1],[libm includes coshf])])
191 AC_CHECK_LIB([m],[expf],[AC_DEFINE([HAVE_EXPF],[1],[libm includes expf])])
192 AC_CHECK_LIB([m],[fabsf],[AC_DEFINE([HAVE_FABSF],[1],[libm includes fabsf])])
193 AC_CHECK_LIB([m],[floorf],[AC_DEFINE([HAVE_FLOORF],[1],[libm includes floorf])])
194 AC_CHECK_LIB([m],[frexpf],[AC_DEFINE([HAVE_FREXPF],[1],[libm includes frexpf])])
195 AC_CHECK_LIB([m],[hypotf],[AC_DEFINE([HAVE_HYPOTF],[1],[libm includes hypotf])])
196 AC_CHECK_LIB([m],[logf],[AC_DEFINE([HAVE_LOGF],[1],[libm includes logf])])
197 AC_CHECK_LIB([m],[log10f],[AC_DEFINE([HAVE_LOG10F],[1],[libm includes log10f])])
198 AC_CHECK_LIB([m],[nextafter],[AC_DEFINE([HAVE_NEXTAFTER],[1],[libm includes nextafter])])
199 AC_CHECK_LIB([m],[nextafterf],[AC_DEFINE([HAVE_NEXTAFTERF],[1],[libm includes nextafterf])])
200 AC_CHECK_LIB([m],[powf],[AC_DEFINE([HAVE_POWF],[1],[libm includes powf])])
201 AC_CHECK_LIB([m],[round],[AC_DEFINE([HAVE_ROUND],[1],[libm includes round])])
202 AC_CHECK_LIB([m],[roundf],[AC_DEFINE([HAVE_ROUNDF],[1],[libm includes roundf])])
203 AC_CHECK_LIB([m],[scalbnf],[AC_DEFINE([HAVE_SCALBNF],[1],[libm includes scalbnf])])
204 AC_CHECK_LIB([m],[sinf],[AC_DEFINE([HAVE_SINF],[1],[libm includes sinf])])
205 AC_CHECK_LIB([m],[sinhf],[AC_DEFINE([HAVE_SINHF],[1],[libm includes sinhf])])
206 AC_CHECK_LIB([m],[sqrtf],[AC_DEFINE([HAVE_SQRTF],[1],[libm includes sqrtf])])
207 AC_CHECK_LIB([m],[tanf],[AC_DEFINE([HAVE_TANF],[1],[libm includes tanf])])
208 AC_CHECK_LIB([m],[tanhf],[AC_DEFINE([HAVE_TANHF],[1],[libm includes tanhf])])
209 AC_CHECK_LIB([m],[erf],[AC_DEFINE([HAVE_ERF],[1],[libm includes erf])])
210 AC_CHECK_LIB([m],[erfc],[AC_DEFINE([HAVE_ERFC],[1],[libm includes erfc])])
211 AC_CHECK_LIB([m],[erfcf],[AC_DEFINE([HAVE_ERFCF],[1],[libm includes erfcf])])
212 AC_CHECK_LIB([m],[erff],[AC_DEFINE([HAVE_ERFF],[1],[libm includes erff])])
213 AC_CHECK_LIB([m],[j0],[AC_DEFINE([HAVE_J0],[1],[libm includes j0])])
214 AC_CHECK_LIB([m],[j0f],[AC_DEFINE([HAVE_J0F],[1],[libm includes j0f])])
215 AC_CHECK_LIB([m],[j1],[AC_DEFINE([HAVE_J1],[1],[libm includes j1])])
216 AC_CHECK_LIB([m],[j1f],[AC_DEFINE([HAVE_J1F],[1],[libm includes j1f])])
217 AC_CHECK_LIB([m],[jn],[AC_DEFINE([HAVE_JN],[1],[libm includes jn])])
218 AC_CHECK_LIB([m],[jnf],[AC_DEFINE([HAVE_JNF],[1],[libm includes jnf])])
219 AC_CHECK_LIB([m],[y0],[AC_DEFINE([HAVE_Y0],[1],[libm includes y0])])
220 AC_CHECK_LIB([m],[y0f],[AC_DEFINE([HAVE_Y0F],[1],[libm includes y0f])])
221 AC_CHECK_LIB([m],[y1],[AC_DEFINE([HAVE_Y1],[1],[libm includes y1])])
222 AC_CHECK_LIB([m],[y1f],[AC_DEFINE([HAVE_Y1F],[1],[libm includes y1f])])
223 AC_CHECK_LIB([m],[yn],[AC_DEFINE([HAVE_YN],[1],[libm includes yn])])
224 AC_CHECK_LIB([m],[ynf],[AC_DEFINE([HAVE_YNF],[1],[libm includes ynf])])
225
226 # Fallback in case isfinite is not available.
227 AC_CHECK_LIB([m],[finite],[AC_DEFINE([HAVE_FINITE],[1],[libm includes finite])])
228
229 # Let the user override this
230 AC_ARG_ENABLE(cmath,
231         AC_HELP_STRING([--enable-cmath],[Include complex math functions]),
232         [need_math=$enableval])
233 if test "$need_math" = "yes"; then
234         AC_MSG_NOTICE([Including complex math functions in libgfor]);
235   extra_math_obj='$(gfor_cmath_obj)'
236 fi
237
238 AC_SUBST([MATH_OBJ],["$extra_math_obj"])
239
240 # The standard autoconf HAVE_STRUCT_TIMEZONE doesn't actually check
241 # for struct timezone, as you might think.  We also need to check how
242 # to call gettimeofday if we have it.
243 LIBGFOR_GETTIMEOFDAY
244
245 # Attempt to assert that the target is of common type in case we don't
246 # have C99 integer types at all.
247 LIBGFOR_TARGET_ILP32
248
249 # Check out attribute support.
250 LIBGFOR_CHECK_ATTRIBUTE_VISIBILITY
251 LIBGFOR_CHECK_ATTRIBUTE_DLLEXPORT
252 LIBGFOR_CHECK_ATTRIBUTE_ALIAS
253
254 AC_CACHE_SAVE
255
256 if test ${multilib} = yes; then
257   multilib_arg="--enable-multilib"
258 else
259   multilib_arg=
260 fi
261
262 # Write our Makefile.
263 AC_CONFIG_FILES(Makefile)
264 AC_OUTPUT