1dnl Process this file with autoconf to produce a configure script.
2
3sinclude(../config/enable.m4)
4sinclude(../config/tls.m4)
5sinclude(../config/acx.m4)
6sinclude(../config/no-executables.m4)
7sinclude(../config/lib-ld.m4)
8sinclude(../config/override.m4)
9sinclude(../config/picflag.m4)
10sinclude(../config/dfp.m4)
11sinclude(../config/unwind_ipinfo.m4)
12sinclude(../config/gthr.m4)
13
14AC_PREREQ(2.64)
15AC_INIT([GNU C Runtime Library], 1.0,,[libgcc])
16AC_CONFIG_SRCDIR([static-object.mk])
17
18# The libgcc should not depend on any header files
19AC_DEFUN([_AC_INCLUDES_DEFAULT_REQUIREMENTS],
20  [m4_divert_text([DEFAULTS],
21    [ac_includes_default='/* none */'])])
22
23AC_ARG_WITH(target-subdir,
24[  --with-target-subdir=SUBDIR      Configuring in a subdirectory for target])
25AC_ARG_WITH(cross-host,
26[  --with-cross-host=HOST           Configuring with a cross compiler])
27AC_ARG_WITH(ld,
28[  --with-ld               arrange to use the specified ld (full pathname)])
29
30if test "${srcdir}" = "."; then
31  if test -n "${with_build_subdir}"; then
32    libgcc_topdir="${srcdir}/../.."
33    with_target_subdir=
34  elif test -z "${with_target_subdir}"; then
35    libgcc_topdir="${srcdir}/.."
36  else
37    if test "${with_target_subdir}" != "."; then
38      libgcc_topdir="${srcdir}/${with_multisrctop}../.."
39    else
40      libgcc_topdir="${srcdir}/${with_multisrctop}.."
41    fi
42  fi
43else
44  libgcc_topdir="${srcdir}/.."
45fi
46AC_SUBST(libgcc_topdir)
47AC_CONFIG_AUX_DIR($libgcc_topdir)
48AC_CONFIG_HEADER(auto-target.h:config.in)
49
50AC_ARG_ENABLE(shared,
51[  --disable-shared        don't provide a shared libgcc],
52[
53  case $enable_shared in
54  yes | no) ;;
55  *)
56    enable_shared=no
57    IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
58    for pkg in $enableval; do
59      if test "X$pkg" = "Xgcc" || test "X$pkg" = "Xlibgcc"; then
60	enable_shared=yes
61      fi
62    done
63    IFS="$ac_save_ifs"
64    ;;
65  esac
66], [enable_shared=yes])
67AC_SUBST(enable_shared)
68
69AC_ARG_ENABLE(vtable-verify,
70[  --enable-vtable-verify    Enable vtable verification feature ],
71[case "$enableval" in
72 yes) enable_vtable_verify=yes ;;
73 no)  enable_vtable_verify=no ;;
74 *)   enable_vtable_verify=no;;
75 esac],
76[enable_vtable_verify=no])
77AC_SUBST(enable_vtable_verify)
78
79AC_ARG_WITH(aix-soname,
80[AS_HELP_STRING([--with-aix-soname=aix|svr4|both],
81    [shared library versioning (aka "SONAME") variant to provide on AIX])],
82[case "${host}:${enable_shared}" in
83 power*-*-aix[[5-9]]*:yes)
84   AC_MSG_CHECKING([which variant of shared library versioning to provide for shared libgcc])
85   case ${withval} in
86     aix|svr4|both) ;;
87     *) AC_MSG_ERROR([Unknown argument to --with-aix-soname]);;
88   esac
89   AC_MSG_RESULT($withval)
90   ;;
91 *) with_aix_soname=aix ;;
92 esac
93], [with_aix_soname=aix])
94AC_SUBST(with_aix_soname)
95
96GCC_PICFLAG
97AC_SUBST(PICFLAG)
98
99AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
100AC_ARG_ENABLE(version-specific-runtime-libs,
101[  --enable-version-specific-runtime-libs    Specify that runtime libraries should be installed in a compiler-specific directory ],
102[case "$enableval" in
103 yes) version_specific_libs=yes ;;
104 no)  version_specific_libs=no ;;
105 *)   AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
106 esac],
107[version_specific_libs=no])
108AC_MSG_RESULT($version_specific_libs)
109
110AC_ARG_WITH(slibdir,
111[  --with-slibdir=DIR      shared libraries in DIR [LIBDIR]],
112slibdir="$with_slibdir",
113if test "${version_specific_libs}" = yes; then
114  slibdir='$(libsubdir)'
115elif test -n "$with_cross_host" && test x"$with_cross_host" != x"no"; then
116  slibdir='$(exec_prefix)/$(host_noncanonical)/lib'
117else
118  slibdir='$(libdir)'
119fi)
120AC_SUBST(slibdir)
121
122# Command-line options.
123# Very limited version of AC_MAINTAINER_MODE.
124AC_ARG_ENABLE([maintainer-mode],
125  [AC_HELP_STRING([--enable-maintainer-mode],
126                 [enable make rules and dependencies not useful (and
127                  sometimes confusing) to the casual installer])],
128  [case ${enable_maintainer_mode} in
129     yes) MAINT='' ;;
130     no) MAINT='#' ;;
131     *) AC_MSG_ERROR([--enable-maintainer-mode must be yes or no]) ;;
132   esac
133   maintainer_mode=${enableval}],
134  [MAINT='#'])
135AC_SUBST([MAINT])dnl
136
137AC_PROG_INSTALL
138
139AC_PROG_AWK
140# We need awk; bail out if it's missing.
141case ${AWK} in
142  "") AC_MSG_ERROR([can't build without awk, bailing out]) ;;
143esac
144
145AC_CANONICAL_HOST
146ACX_NONCANONICAL_HOST
147ACX_NONCANONICAL_TARGET
148GCC_TOPLEV_SUBDIRS
149
150# Calculate toolexeclibdir
151# Also toolexecdir, though it's only used in toolexeclibdir
152case ${version_specific_libs} in
153  yes)
154    # Need the gcc compiler version to know where to install libraries
155    # and header files if --enable-version-specific-runtime-libs option
156    # is selected.
157    toolexecdir='$(libdir)/gcc/$(target_noncanonical)'
158    toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)'
159    ;;
160  no)
161    if test -n "$with_cross_host" &&
162       test x"$with_cross_host" != x"no"; then
163      # Install a library built with a cross compiler in tooldir, not libdir.
164      toolexecdir='$(exec_prefix)/$(target_noncanonical)'
165      toolexeclibdir='$(toolexecdir)/lib'
166    else
167      toolexecdir='$(libdir)/gcc-lib/$(target_noncanonical)'
168      toolexeclibdir='$(libdir)'
169    fi
170    multi_os_directory=`$CC -print-multi-os-directory`
171    case $multi_os_directory in
172      .) ;; # Avoid trailing /.
173      *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
174    esac
175    ;;
176esac
177AC_SUBST(toolexecdir)
178AC_SUBST(toolexeclibdir)
179
180dnl These must be called before AM_PROG_LIBTOOL, because it may want
181dnl to call AC_CHECK_PROG.
182AC_CHECK_TOOL(AR, ar)
183AC_CHECK_TOOL(LIPO, lipo, :)
184AC_CHECK_TOOL(NM, nm)
185AC_CHECK_TOOL(RANLIB, ranlib, :)
186AC_CHECK_TOOL(STRIP, strip, :)
187AC_PROG_LN_S
188
189GCC_NO_EXECUTABLES
190AC_PROG_CC
191AC_PROG_CPP_WERROR
192
193AC_CHECK_SIZEOF([double])
194AC_CHECK_SIZEOF([long double])
195AS_VAR_ARITH([double_type_size], [$ac_cv_sizeof_double \* 8])
196AS_VAR_ARITH([long_double_type_size], [$ac_cv_sizeof_long_double \* 8])
197AC_SUBST(double_type_size)
198AC_SUBST(long_double_type_size)
199
200AC_CHECK_HEADERS(inttypes.h stdint.h stdlib.h ftw.h \
201	unistd.h sys/stat.h sys/types.h \
202	string.h strings.h memory.h)
203AC_HEADER_STDC
204
205# Check for decimal float support.
206AC_CACHE_CHECK([whether decimal floating point is supported], [libgcc_cv_dfp],
207	       [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
208#include <fenv.h>
209]], [[
210_Decimal32 x;
211int fe_except =
212  FE_INVALID|FE_DIVBYZERO|FE_OVERFLOW|FE_UNDERFLOW|FE_INEXACT;
213]])],
214				  [libgcc_cv_dfp=yes],
215				  [libgcc_cv_dfp=no])])
216decimal_float=$libgcc_cv_dfp
217AC_SUBST(decimal_float)
218
219GCC_AC_ENABLE_DECIMAL_FLOAT([$host])
220
221# Check for fixed-point support.
222AC_CACHE_CHECK([whether fixed-point is supported], [libgcc_cv_fixed_point],
223	       [AC_COMPILE_IFELSE([_Sat _Fract x;], [libgcc_cv_fixed_point=yes],
224				  [libgcc_cv_fixed_point=no])])
225fixed_point=$libgcc_cv_fixed_point
226AC_SUBST(fixed_point)
227
228# For platforms with the unwind ABI which includes an unwind library,
229# libunwind, we can choose to use the system libunwind.
230# config.gcc also contains tests of with_system_libunwind.
231GCC_CHECK_UNWIND_GETIPINFO
232
233# The sjlj test is almost duplicated here and in libgo/configure.ac (for C),
234# libstdc++-v3/acinclude.m4 and libjava/configure.ac (for C++), and
235# libobjc/configure.ac (for Objective-C).
236# FIXME: This should be centralized in config/sjlj.m4.
237AC_ARG_ENABLE(sjlj-exceptions,
238  AC_HELP_STRING([--enable-sjlj-exceptions],
239		 [force use of builtin_setjmp for exceptions]),
240  [case "$enableval" in
241   yes|no|auto) ;;
242   *) AC_MSG_ERROR([unknown argument to --enable-sjlj-exceptions]) ;;
243   esac],
244  [enable_sjlj_exceptions=auto])
245
246AC_CACHE_CHECK([whether to use setjmp/longjmp exceptions],
247[libgcc_cv_lib_sjlj_exceptions],
248[AC_LANG_CONFTEST(
249  [AC_LANG_SOURCE([
250void bar ();
251void clean (int *);
252void foo ()
253{
254  int i __attribute__ ((cleanup (clean)));
255  bar();
256}
257])])
258CFLAGS_hold=$CFLAGS
259CFLAGS="--save-temps -fexceptions"
260libgcc_cv_lib_sjlj_exceptions=unknown
261AS_IF([ac_fn_c_try_compile],
262  [if grep _Unwind_SjLj_Resume conftest.s >/dev/null 2>&1; then
263    libgcc_cv_lib_sjlj_exceptions=yes
264  elif grep _Unwind_Resume conftest.s >/dev/null 2>&1; then
265    libgcc_cv_lib_sjlj_exceptions=no
266  fi])
267CFLAGS=$CFLAGS_hold
268rm -f conftest*
269])
270
271if test "$enable_sjlj_exceptions" = "auto"; then
272  enable_sjlj_exceptions=$libgcc_cv_lib_sjlj_exceptions
273fi
274
275case $enable_sjlj_exceptions in
276yes)
277  AC_DEFINE(LIBGCC_SJLJ_EXCEPTIONS, 1,
278	[Define if the C compiler is configured for setjmp/longjmp exceptions.])
279  ;;
280no)
281  ;;
282*)
283  AC_MSG_ERROR([unable to detect exception model])
284  ;;
285esac
286
287AC_ARG_ENABLE([explicit-exception-frame-registration],
288  [AC_HELP_STRING([--enable-explicit-exception-frame-registration],
289     [register exception tables explicitly at module start, for use
290      e.g. for compatibility with installations without PT_GNU_EH_FRAME support])],
291[
292force_explicit_eh_registry=
293if test "$enable_explicit_exception_frame_registration" = yes; then
294  if test "$enable_sjlj_exceptions" = yes; then
295    AC_MSG_ERROR([Can't enable both of --enable-sjlj-exceptions
296                  and --enable-explicit-exception-frame-registration])
297  fi
298  force_explicit_eh_registry=-DUSE_EH_FRAME_REGISTRY_ALWAYS
299fi
300])
301AC_SUBST([force_explicit_eh_registry])
302
303AC_LIB_PROG_LD_GNU
304
305AC_MSG_CHECKING([for thread model used by GCC])
306target_thread_file=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
307AC_MSG_RESULT([$target_thread_file]) 
308
309# Check for assembler CFI support.
310AC_CACHE_CHECK([whether assembler supports CFI directives], [libgcc_cv_cfi],
311	       [AC_COMPILE_IFELSE(
312[asm("\n\
313	.text\n\
314	.cfi_startproc\n\
315	.cfi_personality 0, symbol\n\
316	.cfi_endproc");],
317  [libgcc_cv_cfi=yes],
318  [libgcc_cv_cfi=no])])
319
320# Check 32bit or 64bit.  In the case of MIPS, this really determines the
321# word size rather than the address size.
322cat > conftest.c <<EOF
323#if defined(__x86_64__) || (!defined(__i386__) && defined(__LP64__)) \
324    || defined(__mips64)
325host_address=64
326#else
327host_address=32
328#endif
329EOF
330eval `${CC-cc} -E conftest.c | grep host_address=`
331rm -f conftest.c
332
333case ${host} in
334mips*-*-*)
335  AC_CACHE_CHECK([whether the target is hard-float],
336		 [libgcc_cv_mips_hard_float],
337		 [AC_COMPILE_IFELSE(
338    [#ifndef __mips_hard_float
339     #error FOO
340     #endif],
341    [libgcc_cv_mips_hard_float=yes],
342    [libgcc_cv_mips_hard_float=no])])
343esac
344
345case ${host} in
346*-*-solaris2*)
347  # Check for system-provided CRTs on Solaris 11.x and Solaris 12.
348  AC_CACHE_CHECK([system-provided CRTs on Solaris],
349    		 [libgcc_cv_solaris_crts],
350    [libgcc_cv_solaris_crts=no
351     libgcc_sysroot="`${CC} -print-sysroot`"
352     libgcc_libdir="$libgcc_sysroot/usr/lib"
353     # At the time they were added, gcrt1.o became a symlink for backwards
354     # compatibility on x86, while crt1.o was added on sparc, so check for that.
355     case ${host} in
356       i?86-*-solaris2* | x86_64-*-solaris2*)
357         if test -h "$libgcc_libdir/gcrt1.o"; then libgcc_cv_solaris_crts=yes; fi
358	 ;;
359       sparc*-*-solaris2*)
360         if test -f "$libgcc_libdir/crt1.o"; then libgcc_cv_solaris_crts=yes; fi
361	 ;;
362     esac])
363  if test $libgcc_cv_solaris_crts = yes; then
364    AC_DEFINE(HAVE_SOLARIS_CRTS, 1,
365      [Define if the system-provided CRTs are present on Solaris.])
366  fi
367  ;;
368esac
369
370# Determine the version of glibc, if any, used on the target.
371AC_MSG_CHECKING([for target glibc version])
372AC_ARG_WITH([glibc-version],
373  [AS_HELP_STRING([--with-glibc-version=M.N],
374    [assume GCC used with glibc version M.N or later])], [
375if [echo "$with_glibc_version" | grep '^[0-9][0-9]*\.[0-9][0-9]*$']; then
376  glibc_version_major=`echo "$with_glibc_version" | sed -e 's/\..*//'`
377  glibc_version_minor=`echo "$with_glibc_version" | sed -e 's/.*\.//'`
378else
379  AC_MSG_ERROR([option --with-glibc-version requires a version number M.N])
380fi], [
381AC_COMPUTE_INT([glibc_version_major], [__GLIBC__],
382				      [#include <features.h>],
383				      [glibc_version_major=0])
384AC_COMPUTE_INT([glibc_version_minor], [__GLIBC_MINOR__],
385				      [#include <features.h>],
386				      [glibc_version_minor=0])])
387AC_MSG_RESULT([$glibc_version_major.$glibc_version_minor])
388
389# Determine floating-point type for powerpc*-*-linux*.
390# Single-precision-only FPRs are not a supported configuration for
391# this target, so are not allowed for in this test.
392case ${host} in
393powerpc*-*-linux*)
394  cat > conftest.c <<EOF
395#ifdef __powerpc64__
396ppc_fp_type=64
397#elif defined _SOFT_FLOAT
398ppc_fp_type=soft
399#elif defined _SOFT_DOUBLE
400ppc_fp_type=e500v1
401#elif defined __NO_FPRS__
402ppc_fp_type=e500v2
403#else
404ppc_fp_type=hard
405#endif
406EOF
407eval `${CC-cc} -E conftest.c | grep ppc_fp_type=`
408rm -f conftest.c
409# glibc 2.19 and later provide all the soft-fp functions, with proper
410# interactions with <fenv.h> exception and rounding mode handling, so
411# make libgcc's versions into compat symbols if a recent enough glibc
412# version is being used.
413ppc_fp_compat=
414case ${ppc_fp_type} in
415soft|e500v1|e500v2)
416  if test $glibc_version_major -gt 2 \
417    || ( test $glibc_version_major -eq 2 \
418        && test $glibc_version_minor -ge 19 ); then
419    ppc_fp_compat="t-softfp-compat"
420  fi
421  ;;
422esac
423;;
424esac
425
426# Collect host-machine-specific information.
427. ${srcdir}/config.host
428
429# Used for constructing correct paths for offload compilers.
430accel_dir_suffix=
431if test x"$enable_as_accelerator_for" != x; then
432  accel_dir_suffix=/accel/${target_noncanonical}
433  case "${target_noncanonical}" in
434    *-intelmicemul-*)
435      # In this case we expect offload compiler to be built as native, so we
436      # need to change install directory for driver to be able to find libgcc.
437      host_noncanonical=${enable_as_accelerator_for} ;;
438  esac
439fi
440AC_SUBST(accel_dir_suffix)
441
442if test x"$enable_offload_targets" != x; then
443  extra_parts="${extra_parts} crtoffloadbegin.o crtoffloadend.o"
444fi
445
446# Check if Solaris/x86 linker supports ZERO terminator unwind entries.
447# This is after config.host so we can augment tmake_file.
448# Link with -nostartfiles -nodefaultlibs since neither are present while
449# building libgcc.
450case ${host} in
451i?86-*-solaris2* | x86_64-*-solaris2.1[[0-9]]*)
452  cat > conftest.s <<EOF
453	.section	.eh_frame,"a",@unwind
454	.zero	4
455	.section	.jcr,"aw",@progbits
456	.zero	8
457EOF
458  if AC_TRY_COMMAND(${CC-cc} -shared -nostartfiles -nodefaultlibs -o conftest.so conftest.s 1>&AS_MESSAGE_LOG_FD); then
459      tmake_file="${tmake_file} i386/t-crtstuff"
460  fi
461  ;;
462esac
463
464# Check if xtensa target is configured for windowed ABI and thus needs to use
465# custom unwind code.
466# This is after config.host so we can augment tmake_file.
467case ${host} in
468xtensa*-*)
469  cat > conftest.c <<EOF
470	#ifdef __XTENSA_CALL0_ABI__
471	#error
472	#endif
473EOF
474  if AC_TRY_COMMAND(${CC-cc} -E -o conftest.i conftest.c 1>&AS_MESSAGE_LOG_FD); then
475      tmake_file="${tmake_file} xtensa/t-windowed"
476  fi
477  ;;
478esac
479
480# Check for visibility support.  This is after config.host so that
481# we can check for asm_hidden_op.
482AC_CACHE_CHECK([for __attribute__((visibility("hidden")))],
483    libgcc_cv_hidden_visibility_attribute, [
484	echo 'int __attribute__ ((visibility ("hidden"))) foo (void) { return 1; }' > conftest.c
485	libgcc_cv_hidden_visibility_attribute=no
486	if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then
487	    if grep "\\$asm_hidden_op.*foo" conftest.s >/dev/null; then
488		libgcc_cv_hidden_visibility_attribute=yes
489	    fi
490	fi
491	rm -f conftest.*
492    ])
493
494if test $libgcc_cv_hidden_visibility_attribute = yes; then
495    vis_hide='-fvisibility=hidden -DHIDE_EXPORTS'
496else
497    vis_hide=
498fi
499AC_SUBST(vis_hide)
500
501# See if we have thread-local storage.  We can only test assembler
502# since link-time and run-time tests require the newly built
503# gcc, which can't be used to build executable due to that libgcc
504# is yet to be built here.
505GCC_CHECK_CC_TLS
506set_have_cc_tls=
507if test "$enable_tls $gcc_cv_have_cc_tls" = "yes yes"; then
508  set_have_cc_tls="-DHAVE_CC_TLS"
509fi
510AC_SUBST(set_have_cc_tls)
511
512# See if we have emulated thread-local storage.
513GCC_CHECK_EMUTLS
514set_use_emutls=
515if test "$enable_tls $gcc_cv_use_emutls" = "yes yes"; then
516  set_use_emutls="-DUSE_EMUTLS"
517fi
518AC_SUBST(set_use_emutls)
519
520AC_CACHE_CHECK(for init priority support, libgcc_cv_init_priority, [
521AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,
522  [[void ip (void) __attribute__ ((constructor (1)));]])],
523  [libgcc_cv_init_priority=yes],[libgcc_cv_init_priority=no])])
524if test $libgcc_cv_init_priority = yes; then
525  AC_DEFINE(HAVE_INIT_PRIORITY, 1,
526  [Define if the compiler supports init priority.])
527fi
528
529# Conditionalize the sfp-machine.h header for this target machine.
530if test -z "${sfp_machine_header}"; then
531	sfp_machine_header=$cpu_type/sfp-machine.h
532	if test -f ${srcdir}/config/${sfp_machine_header}; then
533		:
534	else
535		sfp_machine_header=no-sfp-machine.h
536	fi
537fi
538AC_SUBST(sfp_machine_header)
539
540# Conditionalize the makefile for this target machine.
541tmake_file_=
542for f in ${tmake_file}
543do
544	if test -f ${srcdir}/config/$f
545	then
546		tmake_file_="${tmake_file_} \$(srcdir)/config/$f"
547	fi
548done
549tmake_file="${tmake_file_}"
550AC_SUBST(tmake_file)
551
552# Likewise export definitions for libgcc_tm.h
553tm_file_=
554for f in ${tm_file}
555do
556	tm_file_="${tm_file_} \$(srcdir)/config/$f"
557done
558tm_file="${tm_file_}"
559AC_SUBST(tm_file)
560AC_SUBST(tm_defines)
561
562# Map from thread model to thread header.
563GCC_AC_THREAD_HEADER([$target_thread_file])
564
565# Substitute configuration variables
566AC_SUBST(cpu_type)
567AC_SUBST(extra_parts)
568AC_SUBST(asm_hidden_op)
569AC_CONFIG_LINKS([enable-execute-stack.c:$enable_execute_stack])
570AC_CONFIG_LINKS([unwind.h:$unwind_header])
571AC_CONFIG_LINKS([md-unwind-support.h:config/$md_unwind_header])
572AC_CONFIG_LINKS([sfp-machine.h:config/$sfp_machine_header])
573AC_CONFIG_LINKS([gthr-default.h:$thread_header])
574
575# We need multilib support.
576AC_CONFIG_FILES([Makefile])
577AC_CONFIG_COMMANDS([default],
578  [[test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
579if test -n "$CONFIG_FILES"; then
580  # FIXME: We shouldn't need to set ac_file
581  ac_file=Makefile
582  . ${libgcc_topdir}/config-ml.in
583fi]],
584[[srcdir=${srcdir}
585host=${host}
586with_target_subdir=${with_target_subdir}
587with_multisubdir=${with_multisubdir}
588ac_configure_args="--enable-multilib ${ac_configure_args}"
589CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
590libgcc_topdir=${libgcc_topdir}
591CC="${CC}"
592]])
593AC_OUTPUT
594