revert: re PR libstdc++/42261 (infinite recursion from string(string::size_type(6...
[gcc.git] / libstdc++-v3 / configure.ac
1 # Process this file with autoreconf to produce a configure script.
2
3 AC_PREREQ(2.64)
4 AC_INIT(package-unused, version-unused,, libstdc++)
5 AC_CONFIG_SRCDIR(src/ios.cc)
6 AC_CONFIG_HEADER(config.h)
7
8 # This works around the fact that libtool configuration may change LD
9 # for this particular configuration, but some shells, instead of
10 # keeping the changes in LD private, export them just because LD is
11 # exported. Only used at the end of this file.
12 ### am handles this now? ORIGINAL_LD_FOR_MULTILIBS=$LD
13
14 # For libtool versioning info, format is CURRENT:REVISION:AGE
15 libtool_VERSION=6:14:0
16 AC_SUBST(libtool_VERSION)
17
18 # Find the rest of the source tree framework.
19 AM_ENABLE_MULTILIB(, ..)
20
21 # Gets build, host, target, *_vendor, *_cpu, *_os, etc.
22 #
23 # You will slowly go insane if you do not grok the following fact: when
24 # building v3 as part of the compiler, the top-level /target/ becomes the
25 # library's /host/. configure then causes --target to default to --host,
26 # exactly like any other package using autoconf. Therefore, 'target' and
27 # 'host' will always be the same. This makes sense both for native and
28 # cross compilers, just think about it for a little while. :-)
29 #
30 # Also, if v3 is being configured as part of a cross compiler, the top-level
31 # configure script will pass the "real" host as $with_cross_host.
32 #
33 # Do not delete or change the following two lines. For why, see
34 # http://gcc.gnu.org/ml/libstdc++/2003-07/msg00451.html
35 AC_CANONICAL_SYSTEM
36 target_alias=${target_alias-$host_alias}
37
38 # Handy for debugging:
39 #AC_MSG_NOTICE($build / $host / $target / $host_alias / $target_alias); sleep 5
40
41 if test "$build" != "$host"; then
42 # We are being configured with some form of cross compiler.
43 GLIBCXX_IS_NATIVE=false
44 case "$host","$target" in
45 # Darwin crosses can use the host system's libraries and headers,
46 # because of the fat library support. Of course, it must be the
47 # same version of Darwin on both sides. Allow the user to
48 # just say --target=foo-darwin without a version number to mean
49 # "the version on this system".
50 *-*-darwin*,*-*-darwin*)
51 hostos=`echo $host | sed 's/.*-darwin/darwin/'`
52 targetos=`echo $target | sed 's/.*-darwin/darwin/'`
53 if test $hostos = $targetos -o $targetos = darwin ; then
54 GLIBCXX_IS_NATIVE=true
55 fi
56 ;;
57
58 *)
59 GCC_NO_EXECUTABLES
60 ;;
61 esac
62 else
63 GLIBCXX_IS_NATIVE=true
64 fi
65
66 # Sets up automake. Must come after AC_CANONICAL_SYSTEM. Each of the
67 # following is magically included in AUTOMAKE_OPTIONS in each Makefile.am.
68 # 1.x: minimum required version
69 # no-define: PACKAGE and VERSION will not be #define'd in config.h (a bunch
70 # of other PACKAGE_* variables will, however, and there's nothing
71 # we can do about that; they come from AC_INIT).
72 # foreign: we don't follow the normal rules for GNU packages (no COPYING
73 # file in the top srcdir, etc, etc), so stop complaining.
74 # no-dependencies: turns off auto dependency generation (just for now)
75 # -Wall: turns on all automake warnings...
76 # -Wno-portability: ...except this one, since GNU make is now required.
77 AM_INIT_AUTOMAKE([1.9.3 no-define foreign no-dependencies -Wall -Wno-portability -Wno-override])
78 AH_TEMPLATE(PACKAGE, [Name of package])
79 AH_TEMPLATE(VERSION, [Version number of package])
80
81 # We're almost certainly being configured before anything else which uses
82 # C++, so all of our AC_PROG_* discoveries will be cached. It's vital that
83 # we not cache the value of CXX that we "discover" here, because it's set
84 # to something unique for us and libjava. Other target libraries need to
85 # find CXX for themselves. We yank the rug out from under the normal AC_*
86 # process by sneakily renaming the cache variable. This also lets us debug
87 # the value of "our" CXX in postmortems.
88 #
89 # We must also force CXX to /not/ be a precious variable, otherwise the
90 # wrong (non-multilib-adjusted) value will be used in multilibs. This
91 # little trick also affects CPPFLAGS, CXXFLAGS, and LDFLAGS. And as a side
92 # effect, CXXFLAGS is no longer automagically subst'd, so we have to do
93 # that ourselves. Un-preciousing AC_PROG_CC also affects CC and CFLAGS.
94 #
95 # -fno-builtin must be present here so that a non-conflicting form of
96 # std::exit can be guessed by AC_PROG_CXX, and used in later tests.
97
98 m4_define([ac_cv_prog_CXX],[glibcxx_cv_prog_CXX])
99 m4_rename([_AC_ARG_VAR_PRECIOUS],[glibcxx_PRECIOUS])
100 m4_define([_AC_ARG_VAR_PRECIOUS],[])
101 save_CXXFLAGS="$CXXFLAGS"
102 CXXFLAGS="$CXXFLAGS -fno-builtin"
103 AC_PROG_CC
104 AC_PROG_CXX
105 CXXFLAGS="$save_CXXFLAGS"
106 m4_rename_force([glibcxx_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
107 AC_SUBST(CFLAGS)
108 AC_SUBST(CXXFLAGS)
109
110 # Runs configure.host, and assorted other critical bits. Sets
111 # up critical shell variables.
112 GLIBCXX_CONFIGURE
113
114 if test "x${with_newlib}" != "xyes"; then
115 AC_LIBTOOL_DLOPEN
116 fi
117 AM_PROG_LIBTOOL
118 AC_SUBST(enable_shared)
119 AC_SUBST(enable_static)
120
121 # Possibly disable most of the library.
122 ## TODO: Consider skipping unncessary tests altogether in this case, rather
123 ## than just ignoring the results. Faster /and/ more correct, win win.
124 GLIBCXX_ENABLE_HOSTED
125
126 # Enable compiler support that doesn't require linking.
127 GLIBCXX_ENABLE_SJLJ_EXCEPTIONS
128 GLIBCXX_ENABLE_PCH($is_hosted)
129 GLIBCXX_ENABLE_THREADS
130 GLIBCXX_ENABLE_ATOMIC_BUILTINS
131 GLIBCXX_ENABLE_DECIMAL_FLOAT
132
133 # Checks for compiler support that doesn't require linking.
134 GLIBCXX_CHECK_COMPILER_FEATURES
135
136 # Enable all the variable C++ runtime options that don't require linking.
137 GLIBCXX_ENABLE_CSTDIO
138 GLIBCXX_ENABLE_CLOCALE
139 GLIBCXX_ENABLE_ALLOCATOR
140 GLIBCXX_ENABLE_CHEADERS($c_model) dnl c_model from configure.host
141 GLIBCXX_ENABLE_LONG_LONG([yes])
142 GLIBCXX_ENABLE_WCHAR_T([yes])
143 GLIBCXX_ENABLE_C99([yes])
144 GLIBCXX_ENABLE_CONCEPT_CHECKS([no])
145 GLIBCXX_ENABLE_DEBUG_FLAGS(["-g3 -O0"])
146 GLIBCXX_ENABLE_DEBUG([no])
147 GLIBCXX_ENABLE_PARALLEL([yes])
148 GLIBCXX_ENABLE_CXX_FLAGS
149 GLIBCXX_ENABLE_FULLY_DYNAMIC_STRING([no])
150
151 # Checks for operating systems support that doesn't require linking.
152 GLIBCXX_CHECK_SYSTEM_ERROR
153
154 # For the streamoff typedef.
155 GLIBCXX_CHECK_INT64_T
156
157 # For LFS support.
158 GLIBCXX_CHECK_LFS
159
160 # For showmanyc_helper().
161 AC_CHECK_HEADERS(sys/ioctl.h sys/filio.h)
162 GLIBCXX_CHECK_POLL
163 GLIBCXX_CHECK_S_ISREG_OR_S_IFREG
164
165 # For xsputn_2().
166 AC_CHECK_HEADERS(sys/uio.h)
167 GLIBCXX_CHECK_WRITEV
168
169 # For C99 support to TR1.
170 GLIBCXX_CHECK_C99_TR1
171
172 # For common values of EOF, SEEK_CUR, SEEK_END.
173 GLIBCXX_CHECK_STDIO_MACROS
174
175 # For gettimeofday support.
176 GLIBCXX_CHECK_GETTIMEOFDAY
177
178 # For clock_gettime, nanosleep and sched_yield support.
179 # NB: The default is [no], because otherwise it requires linking.
180 GLIBCXX_ENABLE_LIBSTDCXX_TIME([no])
181
182 # For gthread support
183 GLIBCXX_CHECK_GTHREADS
184
185 AC_LC_MESSAGES
186
187 # Check for available headers.
188 AC_CHECK_HEADERS([endian.h float.h fp.h ieeefp.h inttypes.h locale.h \
189 machine/endian.h machine/param.h nan.h stdint.h stdlib.h string.h \
190 strings.h sys/ipc.h sys/isa_defs.h sys/machine.h sys/param.h \
191 sys/resource.h sys/sem.h sys/stat.h sys/time.h sys/types.h unistd.h \
192 wchar.h wctype.h])
193
194 # Only do link tests if native. Else, hardcode.
195 if $GLIBCXX_IS_NATIVE; then
196
197 # We can do more elaborate tests that assume a working linker.
198 CANADIAN=no
199
200 GLIBCXX_CHECK_LINKER_FEATURES
201 GLIBCXX_CHECK_MATH_SUPPORT
202 GLIBCXX_CHECK_STDLIB_SUPPORT
203
204 # For /dev/random and /dev/urandom for TR1.
205 GLIBCXX_CHECK_RANDOM_TR1
206
207 # For TLS support.
208 GCC_CHECK_TLS
209
210 # For iconv support.
211 AM_ICONV
212
213 else
214
215 # This lets us hard-code the functionality we know we'll have in the cross
216 # target environment. "Let" is a sugar-coated word placed on an especially
217 # dull and tedious hack, actually.
218 #
219 # Here's why GLIBCXX_CHECK_MATH_SUPPORT, and other autoconf macros
220 # that involve linking, can't be used:
221 # "cannot open sim-crt0.o"
222 # "cannot open crt0.o"
223 # etc. All this is because there currently exists no unified, consistent
224 # way for top level CC information to be passed down to target directories:
225 # newlib includes, newlib linking info, libgloss versus newlib crt0.o, etc.
226 # When all of that is done, all of this hokey, excessive AC_DEFINE junk for
227 # crosses can be removed.
228
229 # If Canadian cross, then don't pick up tools from the build directory.
230 # Used only in GLIBCXX_EXPORT_INCLUDES.
231 if test -n "$with_cross_host" &&
232 test x"$build_alias" != x"$with_cross_host" &&
233 test x"$build" != x"$target";
234 then
235 CANADIAN=yes
236 else
237 CANADIAN=no
238 fi
239
240 # Construct crosses by hand, eliminating bits that need ld...
241 # GLIBCXX_CHECK_MATH_SUPPORT
242
243 # First, test for "known" system libraries. We may be using newlib even
244 # on a hosted environment.
245 if test "x${with_newlib}" = "xyes"; then
246 os_include_dir="os/newlib"
247 AC_DEFINE(HAVE_HYPOT)
248
249 # GLIBCXX_CHECK_STDLIB_SUPPORT
250 AC_DEFINE(HAVE_STRTOF)
251
252 AC_DEFINE(HAVE_ACOSF)
253 AC_DEFINE(HAVE_ASINF)
254 AC_DEFINE(HAVE_ATAN2F)
255 AC_DEFINE(HAVE_ATANF)
256 AC_DEFINE(HAVE_CEILF)
257 AC_DEFINE(HAVE_COSF)
258 AC_DEFINE(HAVE_COSHF)
259 AC_DEFINE(HAVE_EXPF)
260 AC_DEFINE(HAVE_FABSF)
261 AC_DEFINE(HAVE_FLOORF)
262 AC_DEFINE(HAVE_FMODF)
263 AC_DEFINE(HAVE_FREXPF)
264 AC_DEFINE(HAVE_LDEXPF)
265 AC_DEFINE(HAVE_LOG10F)
266 AC_DEFINE(HAVE_LOGF)
267 AC_DEFINE(HAVE_MODFF)
268 AC_DEFINE(HAVE_POWF)
269 AC_DEFINE(HAVE_SINF)
270 AC_DEFINE(HAVE_SINHF)
271 AC_DEFINE(HAVE_SQRTF)
272 AC_DEFINE(HAVE_TANF)
273 AC_DEFINE(HAVE_TANHF)
274
275 AC_DEFINE(HAVE_ICONV)
276 else
277 GLIBCXX_CROSSCONFIG
278 fi
279
280 # At some point, we should differentiate between architectures
281 # like x86, which have long double versions, and alpha/powerpc/etc.,
282 # which don't. For the time being, punt.
283 if test x"long_double_math_on_this_cpu" = x"yes"; then
284 AC_DEFINE(HAVE_ACOSL)
285 AC_DEFINE(HAVE_ASINL)
286 AC_DEFINE(HAVE_ATAN2L)
287 AC_DEFINE(HAVE_ATANL)
288 AC_DEFINE(HAVE_CEILL)
289 AC_DEFINE(HAVE_COSL)
290 AC_DEFINE(HAVE_COSHL)
291 AC_DEFINE(HAVE_EXPL)
292 AC_DEFINE(HAVE_FABSL)
293 AC_DEFINE(HAVE_FLOORL)
294 AC_DEFINE(HAVE_FMODL)
295 AC_DEFINE(HAVE_FREXPL)
296 AC_DEFINE(HAVE_LDEXPL)
297 AC_DEFINE(HAVE_LOG10L)
298 AC_DEFINE(HAVE_LOGL)
299 AC_DEFINE(HAVE_MODFL)
300 AC_DEFINE(HAVE_POWL)
301 AC_DEFINE(HAVE_SINCOSL)
302 AC_DEFINE(HAVE_SINL)
303 AC_DEFINE(HAVE_SINHL)
304 AC_DEFINE(HAVE_SQRTL)
305 AC_DEFINE(HAVE_TANL)
306 AC_DEFINE(HAVE_TANHL)
307 fi
308 fi
309
310 # Check for _Unwind_GetIPInfo.
311 GCC_CHECK_UNWIND_GETIPINFO
312
313
314 GCC_LINUX_FUTEX([AC_DEFINE(HAVE_LINUX_FUTEX, 1, [Define if futex syscall is available.])])
315
316 GCC_HEADER_STDINT(include/gstdint.h)
317
318 # This depends on GLIBCXX CHECK_LINKER_FEATURES, but without it assumes no.
319 GLIBCXX_ENABLE_SYMVERS([yes])
320 GLIBCXX_ENABLE_VISIBILITY([yes])
321
322 ac_ldbl_compat=no
323 case "$target" in
324 powerpc*-*-linux* | \
325 powerpc*-*-gnu* | \
326 sparc*-*-linux* | \
327 s390*-*-linux* | \
328 alpha*-*-linux*)
329 AC_TRY_COMPILE(, [
330 #if !defined __LONG_DOUBLE_128__ || (defined(__sparc__) && defined(__arch64__))
331 #error no need for long double compatibility
332 #endif
333 ], [ac_ldbl_compat=yes], [ac_ldbl_compat=no])
334 if test "$ac_ldbl_compat" = yes; then
335 AC_DEFINE([_GLIBCXX_LONG_DOUBLE_COMPAT],1,
336 [Define if compatibility should be provided for -mlong-double-64.])
337 port_specific_symbol_files="\$(top_srcdir)/config/os/gnu-linux/ldbl-extra.ver"
338 fi
339 esac
340 GLIBCXX_CONDITIONAL(GLIBCXX_LDBL_COMPAT, test $ac_ldbl_compat = yes)
341
342 # This depends on GLIBCXX_ENABLE_SYMVERS and GLIBCXX_IS_NATIVE.
343 GLIBCXX_CONFIGURE_TESTSUITE
344
345 # Propagate the target-specific source directories through the build chain.
346 ATOMICITY_SRCDIR=config/${atomicity_dir}
347 ATOMIC_WORD_SRCDIR=config/${atomic_word_dir}
348 ATOMIC_FLAGS=${atomic_flags}
349 CPU_DEFINES_SRCDIR=config/${cpu_defines_dir}
350 OS_INC_SRCDIR=config/${os_include_dir}
351 ERROR_CONSTANTS_SRCDIR=config/${error_constants_dir}
352 ABI_TWEAKS_SRCDIR=config/${abi_tweaks_dir}
353 AC_SUBST(ATOMICITY_SRCDIR)
354 AC_SUBST(ATOMIC_WORD_SRCDIR)
355 AC_SUBST(ATOMIC_FLAGS)
356 AC_SUBST(CPU_DEFINES_SRCDIR)
357 AC_SUBST(ABI_TWEAKS_SRCDIR)
358 AC_SUBST(OS_INC_SRCDIR)
359 AC_SUBST(ERROR_CONSTANTS_SRCDIR)
360
361
362 # Determine cross-compile flags and AM_CONDITIONALs.
363 #AC_SUBST(GLIBCXX_IS_NATIVE)
364 #AM_CONDITIONAL(CANADIAN, test $CANADIAN = yes)
365 GLIBCXX_EVALUATE_CONDITIONALS
366
367 AC_CACHE_SAVE
368
369 if test ${multilib} = yes; then
370 multilib_arg="--enable-multilib"
371 else
372 multilib_arg=
373 fi
374
375 # Export all the install information.
376 GLIBCXX_EXPORT_INSTALL_INFO
377
378 # Export all the include and flag information to Makefiles.
379 GLIBCXX_EXPORT_INCLUDES
380 GLIBCXX_EXPORT_FLAGS
381
382 if test "$enable_shared" = yes; then
383 LIBSUPCXX_PICFLAGS="-prefer-pic"
384 else
385 LIBSUPCXX_PICFLAGS=
386 fi
387 AC_SUBST(LIBSUPCXX_PICFLAGS)
388
389 dnl In autoconf 2.5x, AC_OUTPUT is replaced by four AC_CONFIG_* macros,
390 dnl which can all be called multiple times as needed, plus one (different)
391 dnl AC_OUTPUT macro. This one lists the files to be created:
392 AC_CONFIG_FILES(Makefile)
393 AC_CONFIG_FILES([scripts/testsuite_flags],[chmod +x scripts/testsuite_flags])
394
395 # Multilibs need MULTISUBDIR defined correctly in certain makefiles so
396 # that multilib installs will end up installed in the correct place.
397 # The testsuite needs it for multilib-aware ABI baseline files.
398 # To work around this not being passed down from config-ml.in ->
399 # srcdir/Makefile.am -> srcdir/{src,libsupc++,...}/Makefile.am, manually
400 # append it here. Only modify Makefiles that have just been created.
401 #
402 # Also, get rid of this simulated-VPATH thing that automake does.
403 AC_CONFIG_FILES(AC_FOREACH([DIR], glibcxx_SUBDIRS, [DIR/Makefile ]),
404 [cat > vpsed$$ << \_EOF
405 s!`test -f '$<' || echo '$(srcdir)/'`!!
406 _EOF
407 sed -f vpsed$$ $ac_file > tmp$$
408 mv tmp$$ $ac_file
409 rm vpsed$$
410 echo 'MULTISUBDIR =' >> $ac_file
411 ml_norecursion=yes
412 . ${multi_basedir}/config-ml.in
413 AS_UNSET([ml_norecursion])
414 ])
415
416 AC_CONFIG_COMMANDS([generate-headers],
417 [(cd include && ${MAKE-make} pch_build= )])
418
419 dnl And this actually makes things happen:
420 AC_OUTPUT