1169691Skan# Process this file with autoreconf to produce a configure script.
2132720Skan
3169691SkanAC_PREREQ(2.59)
4132720SkanAC_INIT(package-unused, version-unused,, libstdc++)
5132720SkanAC_CONFIG_SRCDIR(src/ios.cc)
6132720SkanAC_CONFIG_HEADER(config.h)
7132720Skan
8132720Skan# This works around the fact that libtool configuration may change LD
9132720Skan# for this particular configuration, but some shells, instead of
10132720Skan# keeping the changes in LD private, export them just because LD is
11132720Skan# exported.  Only used at the end of this file.
12132720Skan### am handles this now?  ORIGINAL_LD_FOR_MULTILIBS=$LD
13132720Skan
14132720Skan# For libtool versioning info, format is CURRENT:REVISION:AGE
15169691Skanlibtool_VERSION=6:9:0
16132720SkanAC_SUBST(libtool_VERSION)
17132720Skan
18132720Skan# Find the rest of the source tree framework.
19169691SkanAM_ENABLE_MULTILIB(, ..)
20132720Skan
21132720Skan# Gets build, host, target, *_vendor, *_cpu, *_os, etc.
22132720Skan#
23132720Skan# You will slowly go insane if you do not grok the following fact:  when
24132720Skan# building v3 as part of the compiler, the top-level /target/ becomes the
25132720Skan# library's /host/.  configure then causes --target to default to --host,
26132720Skan# exactly like any other package using autoconf.  Therefore, 'target' and
27132720Skan# 'host' will always be the same.  This makes sense both for native and
28132720Skan# cross compilers, just think about it for a little while.  :-)
29132720Skan#
30132720Skan# Also, if v3 is being configured as part of a cross compiler, the top-level
31132720Skan# configure script will pass the "real" host as $with_cross_host.
32132720Skan#
33132720Skan# Do not delete or change the following two lines.  For why, see
34132720Skan# http://gcc.gnu.org/ml/libstdc++/2003-07/msg00451.html
35132720SkanAC_CANONICAL_SYSTEM
36132720Skantarget_alias=${target_alias-$host_alias}
37132720Skan
38132720Skan# Handy for debugging:
39132720Skan#AC_MSG_NOTICE($build / $host / $target / $host_alias / $target_alias); sleep 5
40132720Skan
41132720Skanif test "$build" != "$host"; then
42132720Skan  # We are being configured with some form of cross compiler.
43132720Skan  GLIBCXX_IS_NATIVE=false
44169691Skan  case "$host","$target" in
45169691Skan    # Darwin crosses can use the host system's libraries and headers,
46169691Skan    # because of the fat library support.  Of course, it must be the
47169691Skan    # same version of Darwin on both sides.  Allow the user to
48169691Skan    # just say --target=foo-darwin without a version number to mean
49169691Skan    # "the version on this system".
50169691Skan      *-*-darwin*,*-*-darwin*)
51169691Skan	hostos=`echo $host | sed 's/.*-darwin/darwin/'`
52169691Skan	targetos=`echo $target | sed 's/.*-darwin/darwin/'`
53169691Skan	if test $hostos = $targetos -o $targetos = darwin ; then
54169691Skan	  GLIBCXX_IS_NATIVE=true
55169691Skan	fi
56169691Skan	;;
57169691Skan
58169691Skan      *)
59169691Skan	GCC_NO_EXECUTABLES
60169691Skan	;;
61169691Skan  esac
62132720Skanelse
63132720Skan  GLIBCXX_IS_NATIVE=true
64132720Skanfi
65132720Skan
66132720Skan# Sets up automake.  Must come after AC_CANONICAL_SYSTEM.  Each of the
67132720Skan# following is magically included in AUTOMAKE_OPTIONS in each Makefile.am.
68132720Skan#  1.x:  minimum required version
69132720Skan#  no-define:  PACKAGE and VERSION will not be #define'd in config.h (a bunch
70132720Skan#              of other PACKAGE_* variables will, however, and there's nothing
71132720Skan#              we can do about that; they come from AC_INIT).
72132720Skan#  foreign:  we don't follow the normal rules for GNU packages (no COPYING
73132720Skan#            file in the top srcdir, etc, etc), so stop complaining.
74132720Skan#  no-dependencies:  turns off auto dependency generation (just for now)
75132720Skan#  -Wall:  turns on all automake warnings...
76132720Skan#  -Wno-portability:  ...except this one, since GNU make is now required.
77169691SkanAM_INIT_AUTOMAKE([1.9.3 no-define foreign no-dependencies -Wall -Wno-portability -Wno-override])
78169691SkanAH_TEMPLATE(PACKAGE, [Name of package])
79169691SkanAH_TEMPLATE(VERSION, [Version number of package])
80132720Skan
81132720Skan# Runs configure.host, finds CC, CXX, and assorted other critical bits.  Sets
82132720Skan# up critical shell variables.
83132720SkanGLIBCXX_CONFIGURE
84132720Skan
85132720SkanAC_LIBTOOL_DLOPEN
86132720SkanAM_PROG_LIBTOOL
87132720SkanAC_SUBST(enable_shared)
88132720SkanAC_SUBST(enable_static)
89132720Skan
90132720Skan# Possibly disable most of the library.
91169691Skan## TODO: Consider skipping unncessary tests altogether in this case, rather
92132720Skan## than just ignoring the results.  Faster /and/ more correct, win win.
93132720SkanGLIBCXX_ENABLE_HOSTED
94132720Skan
95169691Skan# Check for compiler support that doesn't require linking.
96132720SkanGLIBCXX_ENABLE_SJLJ_EXCEPTIONS
97132720SkanGLIBCXX_ENABLE_PCH($is_hosted)
98132720Skan
99132720Skan# Enable all the variable C++ runtime options.  
100132720SkanGLIBCXX_ENABLE_CSTDIO
101132720SkanGLIBCXX_ENABLE_CLOCALE
102132720SkanGLIBCXX_ENABLE_ALLOCATOR
103132720SkanGLIBCXX_ENABLE_CHEADERS($c_model)  dnl c_model from configure.host
104169691SkanGLIBCXX_ENABLE_LONG_LONG([yes])
105169691SkanGLIBCXX_ENABLE_WCHAR_T([yes])
106132720SkanGLIBCXX_ENABLE_C99([yes])
107132720SkanGLIBCXX_ENABLE_CONCEPT_CHECKS([no])
108132720SkanGLIBCXX_ENABLE_DEBUG_FLAGS(["-g3 -O0"])
109132720SkanGLIBCXX_ENABLE_DEBUG([no])
110132720SkanGLIBCXX_ENABLE_CXX_FLAGS
111146897SkanGLIBCXX_ENABLE_FULLY_DYNAMIC_STRING([no])
112132720Skan
113132720Skan# No surprises, no surprises...
114169691SkanGLIBCXX_ENABLE_THREADS
115169691SkanGLIBCXX_ENABLE_ATOMIC_BUILTINS
116169691Skanif test $atomicity_dir = cpu/generic/atomic_mutex ; then
117132720Skan  AC_MSG_WARN([No native atomic operations are provided for this platform.])
118132720Skan  if test $target_thread_file = single; then
119132720Skan    AC_MSG_WARN([They cannot be faked when thread support is disabled.])
120132720Skan    AC_MSG_WARN([Thread-safety of certain classes is not guaranteed.])
121132720Skan  else
122132720Skan    AC_MSG_WARN([They will be faked using a mutex.])
123132720Skan    AC_MSG_WARN([Performance of certain classes will degrade as a result.])
124132720Skan  fi
125132720Skanfi
126132720Skan
127169691SkanGLIBCXX_CHECK_COMPILER_FEATURES
128132720Skan
129132720Skanif $GLIBCXX_IS_NATIVE; then
130132720Skan
131132720Skan  # We can do more elaborate tests that assume a working linker.
132132720Skan  CANADIAN=no
133132720Skan
134132720Skan  # Check for available headers.
135132720Skan  AC_CHECK_HEADERS([nan.h ieeefp.h endian.h sys/isa_defs.h machine/endian.h \
136132720Skan  machine/param.h sys/machine.h fp.h locale.h float.h inttypes.h gconv.h \
137169691Skan  sys/types.h sys/ipc.h sys/sem.h])
138132720Skan
139132720Skan  GLIBCXX_CHECK_LINKER_FEATURES
140132720Skan  GLIBCXX_CHECK_MATH_SUPPORT
141132720Skan  GLIBCXX_CHECK_BUILTIN_MATH_SUPPORT
142132720Skan  GLIBCXX_CHECK_COMPLEX_MATH_SUPPORT
143169691Skan  GLIBCXX_CHECK_ICONV_SUPPORT
144132720Skan  GLIBCXX_CHECK_STDLIB_SUPPORT
145132720Skan
146132720Skan  # For showmanyc_helper().
147132720Skan  AC_CHECK_HEADERS(sys/ioctl.h sys/filio.h)
148132720Skan  GLIBCXX_CHECK_POLL
149132720Skan  GLIBCXX_CHECK_S_ISREG_OR_S_IFREG
150132720Skan
151132720Skan  # For xsputn_2().
152132720Skan  AC_CHECK_HEADERS(sys/uio.h)
153132720Skan  GLIBCXX_CHECK_WRITEV
154132720Skan
155132720Skan  # For the __streamoff_base_type typedef.
156132720Skan  GLIBCXX_CHECK_INT64_T
157132720Skan
158132720Skan  # For LFS support.
159132720Skan  GLIBCXX_CHECK_LFS
160132720Skan
161169691Skan  # For C99 support to TR1.
162169691Skan  GLIBCXX_CHECK_C99_TR1
163169691Skan
164169691Skan  # For dev/random and dev/urandom for TR1.
165169691Skan  GLIBCXX_CHECK_RANDOM_TR1
166169691Skan
167169691Skan  # For TLS support.
168169691Skan  GCC_CHECK_TLS
169169691Skan
170169691Skan  # For _Unwind_GetIPInfo.
171169691Skan  GCC_CHECK_UNWIND_GETIPINFO
172169691Skan
173132720Skan  AC_LC_MESSAGES
174132720Skan
175132720Skan  AC_TRY_COMPILE(
176132720Skan    [#include <setjmp.h>],
177132720Skan    [sigjmp_buf env;
178132720Skan     while (! sigsetjmp (env, 1))
179132720Skan       siglongjmp (env, 1);
180132720Skan    ],
181132720Skan    [AC_DEFINE(HAVE_SIGSETJMP, 1, [Define if sigsetjmp is available.])])
182132720Skan
183132720Skan  AC_FUNC_MMAP
184132720Skan
185132720Skanelse
186132720Skan
187132720Skan  # This lets us hard-code the functionality we know we'll have in the cross
188132720Skan  # target environment.  "Let" is a sugar-coated word placed on an especially
189132720Skan  # dull and tedious hack, actually.
190132720Skan  #
191132720Skan  # Here's why GLIBCXX_CHECK_MATH_SUPPORT, and other autoconf macros
192132720Skan  # that involve linking, can't be used:
193132720Skan  #    "cannot open sim-crt0.o"
194132720Skan  #    "cannot open crt0.o"
195132720Skan  # etc.  All this is because there currently exists no unified, consistent
196132720Skan  # way for top level CC information to be passed down to target directories:
197132720Skan  # newlib includes, newlib linking info, libgloss versus newlib crt0.o, etc.
198132720Skan  # When all of that is done, all of this hokey, excessive AC_DEFINE junk for
199132720Skan  # crosses can be removed.
200132720Skan
201132720Skan  # If Canadian cross, then don't pick up tools from the build directory.
202132720Skan  # Used only in GLIBCXX_EXPORT_INCLUDES.
203132720Skan  if test -n "$with_cross_host" &&
204132720Skan     test x"$build_alias" != x"$with_cross_host" &&
205132720Skan     test x"$build" != x"$target";
206132720Skan  then
207132720Skan    CANADIAN=yes
208132720Skan  else
209132720Skan    CANADIAN=no
210132720Skan  fi
211132720Skan
212132720Skan  # Construct crosses by hand, eliminating bits that need ld...
213132720Skan  # GLIBCXX_CHECK_BUILTIN_MATH_SUPPORT
214132720Skan  # GLIBCXX_CHECK_MATH_SUPPORT
215132720Skan
216132720Skan  # First, test for "known" system libraries.  We may be using newlib even
217132720Skan  # on a hosted environment.
218132720Skan  if test "x${with_newlib}" = "xyes"; then
219132720Skan    os_include_dir="os/newlib"
220132720Skan    AC_DEFINE(HAVE_HYPOT)
221132720Skan
222132720Skan    # GLIBCXX_CHECK_STDLIB_SUPPORT
223132720Skan    AC_DEFINE(HAVE_STRTOF)        
224132720Skan    # AC_FUNC_MMAP
225132720Skan    AC_DEFINE(HAVE_MMAP)
226132720Skan
227132720Skan    AC_DEFINE(HAVE_ACOSF)
228132720Skan    AC_DEFINE(HAVE_ASINF)
229132720Skan    AC_DEFINE(HAVE_ATAN2F)
230132720Skan    AC_DEFINE(HAVE_ATANF)
231132720Skan    AC_DEFINE(HAVE_CEILF)
232132720Skan    AC_DEFINE(HAVE_COPYSIGN)
233132720Skan    AC_DEFINE(HAVE_COPYSIGNF)
234132720Skan    AC_DEFINE(HAVE_COSF)
235132720Skan    AC_DEFINE(HAVE_COSHF)
236132720Skan    AC_DEFINE(HAVE_EXPF)
237132720Skan    AC_DEFINE(HAVE_FABSF)
238132720Skan    AC_DEFINE(HAVE_FLOORF)
239132720Skan    AC_DEFINE(HAVE_FMODF)
240132720Skan    AC_DEFINE(HAVE_FREXPF)
241132720Skan    AC_DEFINE(HAVE_LDEXPF)
242132720Skan    AC_DEFINE(HAVE_LOG10F)
243132720Skan    AC_DEFINE(HAVE_LOGF)
244132720Skan    AC_DEFINE(HAVE_MODFF)
245132720Skan    AC_DEFINE(HAVE_POWF)
246132720Skan    AC_DEFINE(HAVE_SINF)
247132720Skan    AC_DEFINE(HAVE_SINHF)
248132720Skan    AC_DEFINE(HAVE_SQRTF)
249132720Skan    AC_DEFINE(HAVE_TANF)
250132720Skan    AC_DEFINE(HAVE_TANHF)
251132720Skan
252132720Skan    AC_DEFINE(HAVE_S_ISREG)
253132720Skan    AC_DEFINE(HAVE_S_IFREG)
254132720Skan  else
255169691Skan    GLIBCXX_CROSSCONFIG
256132720Skan  fi
257132720Skan
258132720Skan  # At some point, we should differentiate between architectures
259132720Skan  # like x86, which have long double versions, and alpha/powerpc/etc.,
260132720Skan  # which don't. For the time being, punt.
261132720Skan  if test x"long_double_math_on_this_cpu" = x"yes"; then
262132720Skan    AC_DEFINE(HAVE_ACOSL)
263132720Skan    AC_DEFINE(HAVE_ASINL)
264132720Skan    AC_DEFINE(HAVE_ATAN2L)
265132720Skan    AC_DEFINE(HAVE_ATANL)
266132720Skan    AC_DEFINE(HAVE_CEILL)
267132720Skan    AC_DEFINE(HAVE_COPYSIGNL)
268132720Skan    AC_DEFINE(HAVE_COSL)
269132720Skan    AC_DEFINE(HAVE_COSHL)
270132720Skan    AC_DEFINE(HAVE_EXPL)
271132720Skan    AC_DEFINE(HAVE_FABSL)
272132720Skan    AC_DEFINE(HAVE_FLOORL)
273132720Skan    AC_DEFINE(HAVE_FMODL)
274132720Skan    AC_DEFINE(HAVE_FREXPL)
275132720Skan    AC_DEFINE(HAVE_LDEXPL)
276132720Skan    AC_DEFINE(HAVE_LOG10L)
277132720Skan    AC_DEFINE(HAVE_LOGL)
278132720Skan    AC_DEFINE(HAVE_MODFL)
279132720Skan    AC_DEFINE(HAVE_POWL)
280132720Skan    AC_DEFINE(HAVE_SINCOSL)
281132720Skan    AC_DEFINE(HAVE_SINL)
282132720Skan    AC_DEFINE(HAVE_SINHL)
283132720Skan    AC_DEFINE(HAVE_SQRTL)
284132720Skan    AC_DEFINE(HAVE_TANL)
285132720Skan    AC_DEFINE(HAVE_TANHL)
286132720Skan  fi
287132720Skan
288169691Skan  # Assume we have _Unwind_GetIPInfo for cross-compiles.
289169691Skan  AC_DEFINE(HAVE_GETIPINFO)
290169691Skan
291132720Skanfi
292132720Skan
293132720Skan# This depends on GLIBCXX CHECK_LINKER_FEATURES, but without it assumes no.
294132720SkanGLIBCXX_ENABLE_SYMVERS([yes])
295169691SkanGLIBCXX_ENABLE_VISIBILITY([yes])
296132720Skan
297169691Skanac_ldbl_compat=no
298169691Skancase "$target" in
299169691Skan  powerpc*-*-*gnu* | \
300169691Skan  sparc*-*-linux* | \
301169691Skan  s390*-*-linux* | \
302169691Skan  alpha*-*-linux*)
303169691Skan  AC_TRY_COMPILE(, [
304169691Skan#if !defined __LONG_DOUBLE_128__ || (defined(__sparc__) && defined(__arch64__))
305169691Skan#error no need for long double compatibility
306169691Skan#endif
307169691Skan  ], [ac_ldbl_compat=yes], [ac_ldbl_compat=no])
308169691Skan  if test "$ac_ldbl_compat" = yes; then
309169691Skan    AC_DEFINE([_GLIBCXX_LONG_DOUBLE_COMPAT],1,
310169691Skan	      [Define if compatibility should be provided for -mlong-double-64.])
311169691Skan    port_specific_symbol_files="\$(top_srcdir)/config/os/gnu-linux/ldbl-extra.ver"
312169691Skan  fi
313169691Skanesac
314169691SkanGLIBCXX_CONDITIONAL(GLIBCXX_LDBL_COMPAT, test $ac_ldbl_compat = yes)
315169691Skan
316132720Skan# This depends on GLIBCXX_ENABLE_SYMVERS and GLIBCXX_IS_NATIVE.
317132720SkanGLIBCXX_CONFIGURE_TESTSUITE
318132720Skan
319132720Skan# Propagate the target-specific source directories through the build chain.
320132720SkanATOMICITY_SRCDIR=config/${atomicity_dir}
321132720SkanATOMIC_WORD_SRCDIR=config/${atomic_word_dir}
322169691SkanCPU_DEFINES_SRCDIR=config/${cpu_defines_dir}
323132720SkanOS_INC_SRCDIR=config/${os_include_dir}
324169691SkanABI_TWEAKS_SRCDIR=config/${abi_tweaks_dir}
325132720SkanAC_SUBST(ATOMICITY_SRCDIR)
326132720SkanAC_SUBST(ATOMIC_WORD_SRCDIR)
327169691SkanAC_SUBST(CPU_DEFINES_SRCDIR)
328169691SkanAC_SUBST(ABI_TWEAKS_SRCDIR)
329132720SkanAC_SUBST(OS_INC_SRCDIR)
330132720Skan
331169691Skan
332132720Skan# Determine cross-compile flags and AM_CONDITIONALs.
333132720Skan#AC_SUBST(GLIBCXX_IS_NATIVE)
334132720Skan#AM_CONDITIONAL(CANADIAN, test $CANADIAN = yes)
335132720Skan# from GLIBCXX_CHECK_COMPLEX_MATH_SUPPORT:
336132720Skan#AM_CONDITIONAL(GLIBCXX_BUILD_LIBMATH,  test $need_libmath = yes)
337132720SkanGLIBCXX_EVALUATE_CONDITIONALS
338132720Skan 
339132720SkanAC_CACHE_SAVE
340132720Skan
341132720Skanif test ${multilib} = yes; then
342132720Skan  multilib_arg="--enable-multilib"
343132720Skanelse
344132720Skan  multilib_arg=
345132720Skanfi
346132720Skan
347132720Skan# Export all the install information.
348132720SkanGLIBCXX_EXPORT_INSTALL_INFO
349132720Skan
350132720Skan# Export all the include and flag information to Makefiles.
351132720SkanGLIBCXX_EXPORT_INCLUDES
352132720SkanGLIBCXX_EXPORT_FLAGS
353132720Skan
354132720Skanif ${CONFIG_SHELL-/bin/sh} ./libtool --tag CXX --features |
355132720Skan   grep "enable shared" > /dev/null;
356132720Skanthen
357132720Skan  LIBSUPCXX_PICFLAGS=-prefer-pic
358132720Skanelse
359132720Skan  LIBSUPCXX_PICFLAGS=
360132720Skanfi
361132720SkanAC_SUBST(LIBSUPCXX_PICFLAGS)
362132720Skan
363132720Skandnl In autoconf 2.5x, AC_OUTPUT is replaced by four AC_CONFIG_* macros,
364132720Skandnl which can all be called multiple times as needed, plus one (different)
365132720Skandnl AC_OUTPUT macro.  This one lists the files to be created:
366132720SkanAC_CONFIG_FILES( \
367132720Skan  Makefile \
368132720Skan  AC_FOREACH([DIR], glibcxx_SUBDIRS, [DIR/Makefile ])
369132720Skan  )
370132720SkanAC_CONFIG_FILES([scripts/testsuite_flags],[chmod +x scripts/testsuite_flags])
371132720Skan
372132720Skandnl These commands are run at the end of config.status:
373132720SkanAC_CONFIG_COMMANDS([default],
374132720Skan[if test -n "$CONFIG_FILES"; then
375132720Skan   # Multilibs need MULTISUBDIR defined correctly in certain makefiles so
376132720Skan   # that multilib installs will end up installed in the correct place.
377132720Skan   # The testsuite needs it for multilib-aware ABI baseline files.
378132720Skan   # To work around this not being passed down from config-ml.in ->
379132720Skan   # srcdir/Makefile.am -> srcdir/{src,libsupc++,...}/Makefile.am, manually
380132720Skan   # append it here.  Only modify Makefiles that have just been created.
381132720Skan   #
382132720Skan   # Also, get rid of this simulated-VPATH thing that automake does.
383132720Skan   cat > vpsed << \_EOF
384132720Skans!`test -f '$<' || echo '$(srcdir)/'`!!
385132720Skan_EOF
386132720Skan   for i in $SUBDIRS; do
387132720Skan    case $CONFIG_FILES in
388132720Skan     *${i}/Makefile*)
389132720Skan       #echo "Adding MULTISUBDIR to $i/Makefile"
390132720Skan       sed -f vpsed $i/Makefile > tmp
391132720Skan       grep '^MULTISUBDIR =' Makefile >> tmp
392132720Skan       mv tmp $i/Makefile
393132720Skan       ;;
394132720Skan    esac
395132720Skan   done
396132720Skan   rm vpsed
397132720Skan fi
398132720Skan (cd include && ${MAKE-make})
399132720Skan],
400132720Skan[
401132720Skan# Variables needed in config.status (file generation) which aren't already
402132720Skan# passed by autoconf.
403132720SkanSUBDIRS="$SUBDIRS"
404132720Skan])
405132720Skan
406132720Skandnl And this actually makes things happen:
407132720SkanAC_OUTPUT
408