2010-12-06 Tobias Burnus <burnus@net-b.de>
[official-gcc.git] / libquadmath / configure.ac
blob82ee93f7e56fb49a042f1cc0517508223ea98f08
1 # Process this file with autoconf to produce a configure script, like so:
2 # aclocal && autoconf && autoheader && automake
4 AC_PREREQ(2.64)
5 AC_INIT([GCC Quad-precision Math Library], 0.1,,[libquadmath])
6 AC_CONFIG_HEADER(config.h)
8 # Gets build, host, target, *_vendor, *_cpu, *_os, etc.
10 # You will slowly go insane if you do not grok the following fact:  when
11 # building this library, the top-level /target/ becomes the library's /host/.
13 # configure then causes --target to default to --host, exactly like any
14 # other package using autoconf.  Therefore, 'target' and 'host' will
15 # always be the same.  This makes sense both for native and cross compilers
16 # just think about it for a little while.  :-)
18 # Also, if this library is being configured as part of a cross compiler, the
19 # top-level configure script will pass the "real" host as $with_cross_host.
21 # Do not delete or change the following two lines.  For why, see
22 # http://gcc.gnu.org/ml/libstdc++/2003-07/msg00451.html
23 AC_CANONICAL_SYSTEM
24 ACX_NONCANONICAL_TARGET
26 target_alias=${target_alias-$host_alias}
27 AC_SUBST(target_alias)
29 AM_INIT_AUTOMAKE([1.9.0 foreign subdir-objects no-dist -Wall -Werror])
31 AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
32 AC_ARG_ENABLE(version-specific-runtime-libs,
33 [  --enable-version-specific-runtime-libs    Specify that runtime libraries should be installed in a compiler-specific directory ],
34 [case "$enableval" in
35  yes) version_specific_libs=yes ;;
36  no)  version_specific_libs=no ;;
37  *)   AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
38  esac],
39 [version_specific_libs=no])
40 AC_MSG_RESULT($version_specific_libs)
42 GCC_NO_EXECUTABLES
44 # Configure libtool
45 AM_PROG_LIBTOOL
46 ACX_LT_HOST_FLAGS
47 AC_SUBST(enable_shared)
48 AC_SUBST(enable_static)
50 AM_MAINTAINER_MODE
51 AM_ENABLE_MULTILIB(, ..)
53 AC_LANG_C
54 # The same as in boehm-gc and libstdc++. Have to borrow it from there.
55 # We must force CC to /not/ be precious variables; otherwise
56 # the wrong, non-multilib-adjusted value will be used in multilibs.
57 # As a side effect, we have to subst CFLAGS ourselves.
59 m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
60 m4_define([_AC_ARG_VAR_PRECIOUS],[])
61 AC_PROG_CC
62 m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
64 AC_SUBST(CFLAGS)
66 AM_PROG_CC_C_O
68 if test "x$GCC" != "xyes"; then
69   AC_MSG_ERROR([libquadmath must be built with GCC])
71 AC_PROG_CPP
73 # Calculate toolexeclibdir
74 # Also toolexecdir, though it's only used in toolexeclibdir
75 case ${version_specific_libs} in
76   yes)
77     # Need the gcc compiler version to know where to install libraries
78     # and header files if --enable-version-specific-runtime-libs option
79     # is selected.
80     toolexecdir='$(libdir)/gcc/$(target_alias)'
81     toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)'
82     ;;
83   no)
84     if test -n "$with_cross_host" &&
85        test x"$with_cross_host" != x"no"; then
86       # Install a library built with a cross compiler in tooldir, not libdir.
87       toolexecdir='$(exec_prefix)/$(target_alias)'
88       toolexeclibdir='$(toolexecdir)/lib'
89     else
90       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
91       toolexeclibdir='$(libdir)'
92     fi
93     multi_os_directory=`$CC -print-multi-os-directory`
94     case $multi_os_directory in
95       .) ;; # Avoid trailing /.
96       *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
97     esac
98     ;;
99 esac
100 AC_SUBST(toolexecdir)
101 AC_SUBST(toolexeclibdir)
103 AC_CHECK_LIB([m],[sqrtl],[AC_DEFINE([HAVE_SQRTL],[1],[libm includes sqrtl])])
104 AC_CHECK_LIB([m],[cbrtl],[AC_DEFINE([HAVE_CBRTL],[1],[libm includes cbrtl])])
106 # Check for symbol versioning (copied from libssp).
107 AC_MSG_CHECKING([whether symbol versioning is supported])
108 if test x$gcc_no_link = xyes; then
109   # If we cannot link, we cannot build shared libraries, so do not use
110   # symbol versioning.
111   quadmath_use_symver=no
112 else
113   save_LDFLAGS="$LDFLAGS"
114   LDFLAGS="$LDFLAGS -fPIC -shared -Wl,--version-script,./conftest.map"
115   cat > conftest.map <<EOF
116 FOO_1.0 {
117   global: *foo*; bar; local: *;
120   AC_TRY_LINK([int foo;],[],[quadmath_use_symver=gnu],[quadmath_use_symver=no])
121   if test x$quadmath_use_symver = xno; then
122     case "$target_os" in
123       solaris2*)
124         LDFLAGS="$save_LDFLAGS"
125         LDFLAGS="$LDFLAGS -fPIC -shared -Wl,-M,./conftest.map"
126         # Sun ld cannot handle wildcards and treats all entries as undefined.
127         cat > conftest.map <<EOF
128 FOO_1.0 {
129   global: foo; local: *;
132         AC_TRY_LINK([int foo;],[],[quadmath_use_symver=sun],[quadmath_use_symver=no])
133         ;;
134     esac
135   fi
136   LDFLAGS="$save_LDFLAGS"
138 AC_MSG_RESULT($quadmath_use_symver)
139 AM_CONDITIONAL(LIBQUAD_USE_SYMVER, [test "x$quadmath_use_symver" != xno])
140 AM_CONDITIONAL(LIBQUAD_USE_SYMVER_GNU, [test "x$quadmath_use_symver" = xgnu])
141 AM_CONDITIONAL(LIBQUAD_USE_SYMVER_SUN, [test "x$quadmath_use_symver" = xsun])
143 AC_MSG_CHECKING([whether __float128 is supported])
144   AC_TRY_LINK([
145     typedef _Complex float __attribute__((mode(TC))) __complex128;
147     __float128 foo (__float128 x)
148     {
150      __complex128 z1, z2;
152      z1 = x;
153      z2 = x / 7.Q;
154      z2 /= z1;
156      return (__float128) z2;
157     }
159     __float128 bar (__float128 x)
160     {
161       return x * __builtin_huge_valq ();
162     }
163   ],[
164     foo (1.2Q);
165     bar (1.2Q);
166   ],[
167     libquad_have_float128=yes
168   ],[
169     libquad_have_float128=no
171 AC_MSG_RESULT([$libquad_have_float128])
174 dnl Enable the following for a stand-alone library:
176 dnl if test $libquad_have_float128 = no; then
177 dnl   AC_MSG_ERROR([__float128 support is required to build this library.])
178 dnl fi
180 AM_CONDITIONAL(BUILD_LIBQUADMATH, [test "x$libquad_have_float128" = xyes])
182 AC_CACHE_SAVE
184 if test ${multilib} = yes; then
185   multilib_arg="--enable-multilib"
186 else
187   multilib_arg=
190 AC_CONFIG_FILES(Makefile)
191 AC_OUTPUT