OSDN Git Service

* doc/install.texi (Prerequisites): Fix grammar.
[pf3gnuchains/gcc-fork.git] / libgo / configure.ac
1 # configure.ac -- Go library configure script.
2
3 # Copyright 2009 The Go Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style
5 # license that can be found in the LICENSE file.
6
7 # Process this file with autoreconf to produce configure.
8
9 AC_PREREQ(2.64)
10 AC_INIT(package-unused, version-unused,, libgo)
11 AC_CONFIG_SRCDIR(Makefile.am)
12 AC_CONFIG_HEADER(config.h)
13
14 libtool_VERSION=1:0:0
15 AC_SUBST(libtool_VERSION)
16
17 AM_ENABLE_MULTILIB(, ..)
18
19 AC_CANONICAL_SYSTEM
20 target_alias=${target_alias-$host_alias}
21
22 AM_INIT_AUTOMAKE([1.9.3 no-define foreign -Wall])
23 AH_TEMPLATE(PACKAGE, [Name of package])
24 AH_TEMPLATE(VERSION, [Version number of package])
25
26 m4_rename([_AC_ARG_VAR_PRECIOUS],[glibgo_PRECIOUS])
27 m4_define([_AC_ARG_VAR_PRECIOUS],[])
28 AC_PROG_CC
29 AC_PROG_GO
30 m4_rename_force([glibgo_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
31
32 AC_SUBST(CFLAGS)
33
34 AM_MAINTAINER_MODE
35
36 AC_INCLUDES_DEFAULT
37
38 AC_PROG_LD
39 AC_PROG_RANLIB
40 AC_CHECK_TOOL(OBJCOPY, objcopy, missing-objcopy)
41
42 AC_LIBTOOL_DLOPEN
43 AM_PROG_LIBTOOL
44 AC_SUBST(enable_shared)
45 AC_SUBST(enable_static)
46
47 CC_FOR_BUILD=${CC_FOR_BUILD:-gcc}
48 AC_SUBST(CC_FOR_BUILD)
49
50 AC_PROG_AWK
51
52 WARN_FLAGS='-Wall -Wextra -Wwrite-strings -Wcast-qual'
53 AC_SUBST(WARN_FLAGS)
54
55 dnl FIXME: This should be controlled by --enable-maintainer-mode.
56 WERROR="-Werror"
57 AC_SUBST(WERROR)
58
59 glibgo_toolexecdir=no
60 glibgo_toolexeclibdir=no
61
62 AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
63 AC_ARG_ENABLE([version-specific-runtime-libs],
64   AC_HELP_STRING([--enable-version-specific-runtime-libs],
65                  [Specify that runtime libraries should be installed in a compiler-specific directory]),
66   [case "$enableval" in
67     yes) version_specific_libs=yes ;;
68     no)  version_specific_libs=no ;;
69     *)   AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
70    esac],
71   [version_specific_libs=no])
72 AC_MSG_RESULT($version_specific_libs)
73
74 # Version-specific runtime libs processing.
75 if test $version_specific_libs = yes; then
76   glibgo_toolexecdir='${libdir}/gcc/${host_alias}'
77   glibgo_toolexeclibdir='${toolexecdir}/${gcc_version}$(MULTISUBDIR)'
78 fi
79
80 # Calculate glibgo_toolexecdir, glibgo_toolexeclibdir
81 # Install a library built with a cross compiler in tooldir, not libdir.
82 if test -n "$with_cross_host" &&
83    test x"$with_cross_host" != x"no"; then
84   nover_glibgo_toolexecdir='${exec_prefix}/${host_alias}'
85   nover_glibgo_toolexeclibdir='${toolexecdir}/lib'
86 else
87   nover_glibgo_toolexecdir='${libdir}/gcc/${host_alias}'
88   nover_glibgo_toolexeclibdir='${libdir}'
89 fi
90 multi_os_directory=`$CC -print-multi-os-directory`
91 case $multi_os_directory in
92   .) ;; # Avoid trailing /.
93   *) nover_glibgo_toolexeclibdir=${nover_glibgo_toolexeclibdir}/${multi_os_directory} ;;
94 esac
95
96 if test x"$glibgo_toolexecdir" = x"no"; then
97   glibgo_toolexecdir="${nover_glibgo_toolexecdir}"
98   glibgo_toolexeclibdir="${nover_glibgo_toolexeclibdir}"
99 fi
100
101 AC_SUBST(glibgo_toolexecdir)
102 AC_SUBST(glibgo_toolexeclibdir)
103 AC_SUBST(nover_glibgo_toolexeclibdir)
104
105 # See if the user wants to configure without libffi.  Some
106 # architectures don't support it.  FIXME: We should set a default
107 # based on the host.
108 AC_ARG_WITH(libffi,
109   AS_HELP_STRING([--without-libffi],
110                  [don't use libffi]),
111   [:],
112   [with_libffi=${with_libffi_default-yes}])
113
114 LIBFFI=
115 LIBFFIINCS=
116 if test "$with_libffi" != no; then
117    AC_DEFINE(USE_LIBFFI, 1, [Define if we're to use libffi.])
118    LIBFFI=../libffi/libffi_convenience.la
119    LIBFFIINCS='-I$(top_srcdir)/../libffi/include -I../libffi/include'
120 fi
121 AC_SUBST(LIBFFI)
122 AC_SUBST(LIBFFIINCS)
123
124 # Used to tell GNU make to include a file without telling automake to
125 # include it.
126 go_include="-include"
127 AC_SUBST(go_include)
128
129 is_darwin=no
130 is_freebsd=no
131 is_irix=no
132 is_linux=no
133 is_netbsd=no
134 is_rtems=no
135 is_solaris=no
136 GOOS=unknown
137 case ${host} in
138   *-*-darwin*)   is_darwin=yes;  GOOS=darwin ;;
139   *-*-freebsd*)  is_freebsd=yes; GOOS=freebsd ;;
140   *-*-irix6*)    is_irix=yes;    GOOS=irix ;;
141   *-*-linux*)    is_linux=yes;   GOOS=linux ;;
142   *-*-netbsd*)   is_netbsd=yes;  GOOS=netbsd ;;
143   *-*-rtems*)    is_rtems=yes;   GOOS=rtems ;;
144   *-*-solaris2*) is_solaris=yes; GOOS=solaris ;;
145 esac
146 AM_CONDITIONAL(LIBGO_IS_DARWIN, test $is_darwin = yes)
147 AM_CONDITIONAL(LIBGO_IS_FREEBSD, test $is_freebsd = yes)
148 AM_CONDITIONAL(LIBGO_IS_IRIX, test $is_irix = yes)
149 AM_CONDITIONAL(LIBGO_IS_LINUX, test $is_linux = yes)
150 AM_CONDITIONAL(LIBGO_IS_NETBSD, test $is_netbsd = yes)
151 AM_CONDITIONAL(LIBGO_IS_RTEMS, test $is_rtems = yes)
152 AM_CONDITIONAL(LIBGO_IS_SOLARIS, test $is_solaris = yes)
153 AC_SUBST(GOOS)
154
155 dnl N.B. Keep in sync with gcc/testsuite/go.test/go-test.exp (go-set-goarch).
156 is_386=no
157 is_alpha=no
158 is_arm=no
159 is_m68k=no
160 mips_abi=unknown
161 is_ppc=no
162 is_ppc64=no
163 is_sparc=no
164 is_sparc64=no
165 is_x86_64=no
166 GOARCH=unknown
167 case ${host} in
168   alpha*-*-*)
169     is_alpha=yes
170     GOARCH=alpha
171     ;;
172   arm*-*-* | strongarm*-*-* | ep9312*-*-* | xscale-*-*)
173     is_arm=yes
174     GOARCH=arm
175     ;;
176 changequote(,)dnl
177   i[34567]86-*-* | x86_64-*-*)
178 changequote([,])dnl
179     AC_COMPILE_IFELSE([
180 #ifdef __x86_64__
181 #error 64-bit
182 #endif],
183 [is_386=yes], [is_x86_64=yes])
184     if test "$is_386" = "yes"; then
185       GOARCH=386
186     else
187       GOARCH=amd64
188     fi
189     ;;
190   m68k*-*-*)
191     is_m68k=yes
192     GOARCH=m68k
193     ;;
194   mips*-*-*)
195     AC_COMPILE_IFELSE([
196 #if _MIPS_SIM != _ABIO32
197 #error not o32
198 #endif],
199 [mips_abi="o32"],
200         [AC_COMPILE_IFELSE([
201 #if _MIPS_SIM != _ABIN32
202 #error not n32
203 #endif],
204 [mips_abi="n32"],
205         [AC_COMPILE_IFELSE([
206 #if _MIPS_SIM != _ABI64
207 #error not n64
208 #endif],
209 [mips_abi="n64"],
210         [AC_COMPILE_IFELSE([
211 #if _MIPS_SIM != _ABIO64
212 #error not o64
213 #endif],
214 [mips_abi="o64"],
215         [AC_MSG_ERROR([unknown MIPS ABI])
216 [mips_abi="n32"]])])])])
217     case "$mips_abi" in
218     "o32") GOARCH=mipso32 ;;
219     "n32") GOARCH=mipsn32 ;;
220     "n64") GOARCH=mipsn64 ;;
221     "o64") GOARCH=mipso64 ;;
222     esac
223     ;;
224   rs6000*-*-* | powerpc*-*-*)
225     AC_COMPILE_IFELSE([
226 #ifdef _ARCH_PPC64
227 #error 64-bit
228 #endif],
229 [is_ppc=yes], [is_ppc64=yes])
230     if test "$is_ppc" = "yes"; then
231       GOARCH=ppc
232     else
233       GOARCH=ppc64
234     fi
235     ;;
236   sparc*-*-*)
237     AC_COMPILE_IFELSE([
238 #if defined(__sparcv9) || defined(__arch64__)
239 #error 64-bit
240 #endif],
241 [is_sparc=yes], [is_sparc64=yes])
242     if test "$is_sparc" = "yes"; then
243       GOARCH=sparc
244     else
245       GOARCH=sparc64
246     fi
247     ;;
248 esac
249 AM_CONDITIONAL(LIBGO_IS_386, test $is_386 = yes)
250 AM_CONDITIONAL(LIBGO_IS_ALPHA, test $is_alpha = yes)
251 AM_CONDITIONAL(LIBGO_IS_ARM, test $is_arm = yes)
252 AM_CONDITIONAL(LIBGO_IS_M68K, test $is_m68k = yes)
253 AM_CONDITIONAL(LIBGO_IS_MIPS, test $mips_abi != unknown)
254 AM_CONDITIONAL(LIBGO_IS_MIPSO32, test $mips_abi = o32)
255 AM_CONDITIONAL(LIBGO_IS_MIPSN32, test $mips_abi = n32)
256 AM_CONDITIONAL(LIBGO_IS_MIPSN64, test $mips_abi = n64)
257 AM_CONDITIONAL(LIBGO_IS_MIPSO64, test $mips_abi = o64)
258 AM_CONDITIONAL(LIBGO_IS_PPC, test $is_ppc = yes)
259 AM_CONDITIONAL(LIBGO_IS_PPC64, test $is_ppc64 = yes)
260 AM_CONDITIONAL(LIBGO_IS_SPARC, test $is_sparc = yes)
261 AM_CONDITIONAL(LIBGO_IS_SPARC64, test $is_sparc64 = yes)
262 AM_CONDITIONAL(LIBGO_IS_X86_64, test $is_x86_64 = yes)
263 AC_SUBST(GOARCH)
264
265 dnl Some files are only present when needed for specific architectures.
266 GO_LIBCALL_OS_FILE=
267 GO_LIBCALL_OS_ARCH_FILE=
268 GO_SYSCALL_OS_FILE=
269 GO_SYSCALL_OS_ARCH_FILE=
270 if test -f ${srcdir}/go/syscall/libcall_${GOOS}.go; then
271   GO_LIBCALL_OS_FILE=go/syscall/libcall_${GOOS}.go
272 fi
273 if test -f ${srcdir}/go/syscall/libcall_${GOOS}_${GOARCH}.go; then
274   GO_LIBCALL_OS_ARCH_FILE=go/syscall/libcall_${GOOS}_${GOARCH}.go
275 fi
276 if test -f ${srcdir}/go/syscall/syscall_${GOOS}.go; then
277   GO_SYSCALL_OS_FILE=go/syscall/syscall_${GOOS}.go
278 fi
279 if test -f ${srcdir}/go/syscall/syscall_${GOOS}_${GOARCH}.go; then
280   GO_SYSCALL_OS_ARCH_FILE=go/syscall/syscall_${GOOS}_${GOARCH}.go
281 fi
282 AC_SUBST(GO_LIBCALL_OS_FILE)
283 AC_SUBST(GO_LIBCALL_OS_ARCH_FILE)
284 AC_SUBST(GO_SYSCALL_OS_FILE)
285 AC_SUBST(GO_SYSCALL_OS_ARCH_FILE)
286
287 dnl Special flags used to generate sysinfo.go.
288 OSCFLAGS="-D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
289 case "$target" in
290     mips-sgi-irix6.5*)
291         # IRIX 6 needs _XOPEN_SOURCE=500 for the XPG5 version of struct
292         # msghdr in <sys/socket.h>.
293         OSCFLAGS="$OSCFLAGS -D_XOPEN_SOURCE=500"
294         ;;
295     *-*-solaris2.[[89]])
296         # Solaris 8/9 need this so struct msghdr gets the msg_control
297         # etc. fields in <sys/socket.h> (_XPG4_2).
298         OSCFLAGS="$OSCFLAGS -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D__EXTENSIONS__"
299         ;;
300     *-*-solaris2.1[[01]])
301         # Solaris 10+ needs this so struct msghdr gets the msg_control
302         # etc. fields in <sys/socket.h> (_XPG4_2).  _XOPEN_SOURCE=600 as
303         # above doesn't work with C99.
304         OSCFLAGS="$OSCFLAGS -std=gnu99 -D_XOPEN_SOURCE=600 -D__EXTENSIONS__"
305         ;;
306 esac
307 AC_SUBST(OSCFLAGS)
308
309 dnl Use -fsplit-stack when compiling C code if available.
310 AC_CACHE_CHECK([whether -fsplit-stack is supported],
311 [libgo_cv_c_split_stack_supported],
312 [CFLAGS_hold=$CFLAGS
313 CFLAGS="$CFLAGS -fsplit-stack"
314 AC_COMPILE_IFELSE([[int i;]],
315 [libgo_cv_c_split_stack_supported=yes],
316 [libgo_cv_c_split_stack_supported=no])
317 CFLAGS=$CFLAGS_hold])
318 if test "$libgo_cv_c_split_stack_supported" = yes; then
319   SPLIT_STACK=-fsplit-stack
320   AC_DEFINE(USING_SPLIT_STACK, 1,
321                 [Define if the compiler supports -fsplit-stack])
322 else
323   SPLIT_STACK=
324 fi
325 AC_SUBST(SPLIT_STACK)
326 AM_CONDITIONAL(USING_SPLIT_STACK,
327         test "$libgo_cv_c_split_stack_supported" = yes)
328
329 dnl Check whether the linker does stack munging when calling from
330 dnl split-stack into non-split-stack code.  We check this by looking
331 dnl at the --help output.  FIXME: This is only half right: it's
332 dnl possible for the linker to support this for some targets but not
333 dnl others.
334 AC_CACHE_CHECK([whether linker supports split stack],
335 [libgo_cv_c_linker_supports_split_stack],
336 libgo_cv_c_linker_supports_split_stack=no
337 if $LD --help 2>/dev/null | grep split-stack-adjust-size >/dev/null 2>&1; then
338   libgo_cv_c_linker_supports_split_stack=yes
339 fi)
340 if test "$libgo_cv_c_linker_supports_split_stack" = yes; then
341   AC_DEFINE(LINKER_SUPPORTS_SPLIT_STACK, 1,
342             [Define if the linker support split stack adjustments])
343 fi
344
345 dnl Test for the -lm library.
346 MATH_LIBS=
347 AC_CHECK_LIB([m], [sqrt], MATH_LIBS=-lm)
348 AC_SUBST(MATH_LIBS)
349
350 dnl Test for -lsocket and -lnsl.  Copied from libjava/configure.ac.
351 AC_CACHE_CHECK([for socket libraries], libgo_cv_lib_sockets,
352   [libgo_cv_lib_sockets=
353    libgo_check_both=no
354    AC_CHECK_FUNC(connect, libgo_check_socket=no, libgo_check_socket=yes)
355    if test "$libgo_check_socket" = "yes"; then
356      unset ac_cv_func_connect
357      AC_CHECK_LIB(socket, main, libgo_cv_lib_sockets="-lsocket",
358                   libgo_check_both=yes)
359    fi
360    if test "$libgo_check_both" = "yes"; then
361      libgo_old_libs=$LIBS
362      LIBS="$LIBS -lsocket -lnsl"
363      unset ac_cv_func_accept
364      AC_CHECK_FUNC(accept,
365                    [libgo_check_nsl=no
366                     libgo_cv_lib_sockets="-lsocket -lnsl"])
367      unset ac_cv_func_accept
368      LIBS=$libgo_old_libs
369    fi
370    unset ac_cv_func_gethostbyname
371    libgo_old_libs="$LIBS"
372    AC_CHECK_FUNC(gethostbyname, ,
373                  [AC_CHECK_LIB(nsl, main,
374                         [libgo_cv_lib_sockets="$libgo_cv_lib_sockets -lnsl"])])
375    unset ac_cv_func_gethostbyname
376    LIBS=$libgo_old_libs
377 ])
378 NET_LIBS="$libgo_cv_lib_sockets"
379 AC_SUBST(NET_LIBS)
380
381 dnl Test whether the compiler supports the -pthread option.
382 AC_CACHE_CHECK([whether -pthread is supported],
383 [libgo_cv_lib_pthread],
384 [CFLAGS_hold=$CFLAGS
385 CFLAGS="$CFLAGS -pthread"
386 AC_COMPILE_IFELSE([[int i;]],
387 [libgo_cv_lib_pthread=yes],
388 [libgo_cv_lib_pthread=no])
389 CFLAGS=$CFLAGS_hold])
390 PTHREAD_CFLAGS=
391 if test "$libgo_cv_lib_pthread" = yes; then
392   PTHREAD_CFLAGS=-pthread
393 fi
394 AC_SUBST(PTHREAD_CFLAGS)
395
396 dnl Test for the -lpthread library.
397 PTHREAD_LIBS=
398 AC_CHECK_LIB([pthread], [pthread_create], PTHREAD_LIBS=-lpthread)
399 AC_SUBST(PTHREAD_LIBS)
400
401 dnl Test if -lrt is required for sched_yield.
402 AC_SEARCH_LIBS([sched_yield], [rt])
403
404 AC_C_BIGENDIAN
405
406 GCC_CHECK_UNWIND_GETIPINFO
407
408 AC_ARG_ENABLE(sjlj-exceptions,
409   AC_HELP_STRING([--enable-sjlj-exceptions],
410                  [force use of builtin_setjmp for exceptions]),
411   [case "$enableval" in
412    yes|no|auto) ;;
413    *) AC_MSG_ERROR([unknown argument to --enable-sjlj-exceptions]) ;;
414    esac],
415   [enable_sjlj_exceptions=auto])
416
417 AC_CACHE_CHECK([whether to use setjmp/longjmp exceptions],
418 [libgo_cv_lib_sjlj_exceptions],
419 [AC_LANG_CONFTEST(
420   [AC_LANG_SOURCE([
421 void bar ();
422 void clean (int *);
423 void foo ()
424 {
425   int i __attribute__ ((cleanup (clean)));
426   bar();
427 }
428 ])])
429 CFLAGS_hold=$CFLAGS
430 CFLAGS="--save-temps -fexceptions"
431 libgo_cv_lib_sjlj_exceptions=unknown
432 AS_IF([ac_fn_c_try_compile],
433   [if grep _Unwind_SjLj_Resume conftest.s >/dev/null 2>&1; then
434     libgo_cv_lib_sjlj_exceptions=yes
435   elif grep _Unwind_Resume conftest.s >/dev/null 2>&1; then
436     libgo_cv_lib_sjlj_exceptions=no
437   fi])
438 CFLAGS=$CFLAGS_hold
439 rm -f conftest*
440 ])
441
442 if test "$enable_sjlj_exceptions" = "auto"; then
443   enable_sjlj_exceptions=$libgo_cv_lib_sjlj_exceptions
444 fi
445
446 case $enable_sjlj_exceptions in
447 yes)
448   AC_DEFINE(LIBGO_SJLJ_EXCEPTIONS, 1,
449         [Define if the C++ compiler is configured for setjmp/longjmp exceptions.])
450   ;;
451 no)
452   ;;
453 *)
454   AC_MSG_ERROR([unable to detect exception model])
455   ;;
456 esac
457
458 AC_CHECK_HEADERS(sys/mman.h syscall.h sys/epoll.h sys/ptrace.h sys/syscall.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/if.h sys/prctl.h)
459
460 AC_CHECK_HEADERS([linux/filter.h linux/netlink.h linux/rtnetlink.h], [], [],
461 [#ifdef HAVE_SYS_SOCKET_H
462 #include <sys/socket.h>
463 #endif
464 ])
465
466 AM_CONDITIONAL(HAVE_SYS_MMAN_H, test "$ac_cv_header_sys_mman_h" = yes)
467
468 AC_CHECK_FUNCS(strerror_r strsignal wait4 mincore setenv)
469 AM_CONDITIONAL(HAVE_STRERROR_R, test "$ac_cv_func_strerror_r" = yes)
470 AM_CONDITIONAL(HAVE_WAIT4, test "$ac_cv_func_wait4" = yes)
471
472 AC_CHECK_FUNCS(epoll_create1 faccessat fchmodat fchownat futimesat inotify_add_watch inotify_init inotify_rm_watch mkdirat mknodat openat renameat splice tee unlinkat unshare)
473 AC_CHECK_TYPES([loff_t])
474
475 CFLAGS_hold="$CFLAGS"
476 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
477 LIBS_hold="$LIBS"
478 LIBS="$LIBS $PTHREAD_LIBS"
479 AC_CHECK_FUNCS(sem_timedwait)
480 CFLAGS="$CFLAGS_hold"
481 LIBS="$LIBS_hold"
482
483 LIBS_hold="$LIBS"
484 LIBS="$LIBS $MATH_LIBS"
485 AC_CHECK_FUNCS(matherr)
486 LIBS="$LIBS_hold"
487
488 AC_CACHE_CHECK([for __sync_bool_compare_and_swap_4],
489 [libgo_cv_func___sync_bool_compare_and_swap_4],
490 [AC_LINK_IFELSE([
491 typedef unsigned int uint32  __attribute__ ((mode (SI)));
492 uint32 i;
493 int main() { return __sync_bool_compare_and_swap (&i, 0, 1); }
494 ],
495 [libgo_cv_func___sync_bool_compare_and_swap_4=yes],
496 [libgo_cv_func___sync_bool_compare_and_swap_4=no])])
497 if test "$libgo_cv_func___sync_bool_compare_and_swap_4" = "yes"; then
498   AC_DEFINE(HAVE_SYNC_BOOL_COMPARE_AND_SWAP_4, 1,
499     [Define to 1 if the compiler provides the __sync_bool_compare_and_swap function for uint32])
500 fi
501
502 AC_CACHE_CHECK([for __sync_bool_compare_and_swap_8],
503 [libgo_cv_func___sync_bool_compare_and_swap_8],
504 [AC_LINK_IFELSE([
505 typedef unsigned int uint64  __attribute__ ((mode (DI)));
506 uint64 i;
507 int main() { return __sync_bool_compare_and_swap (&i, 0, 1); }
508 ],
509 [libgo_cv_func___sync_bool_compare_and_swap_8=yes],
510 [libgo_cv_func___sync_bool_compare_and_swap_8=no])])
511 if test "$libgo_cv_func___sync_bool_compare_and_swap_8" = "yes"; then
512   AC_DEFINE(HAVE_SYNC_BOOL_COMPARE_AND_SWAP_8, 1,
513     [Define to 1 if the compiler provides the __sync_bool_compare_and_swap function for uint64])
514 fi
515
516 AC_CACHE_CHECK([for __sync_fetch_and_add_4],
517 [libgo_cv_func___sync_fetch_and_add_4],
518 [AC_LINK_IFELSE([
519 typedef unsigned int uint32  __attribute__ ((mode (SI)));
520 uint32 i;
521 int main() { return __sync_fetch_and_add (&i, 1); }
522 ],
523 [libgo_cv_func___sync_fetch_and_add_4=yes],
524 [libgo_cv_func___sync_fetch_and_add_4=no])])
525 if test "$libgo_cv_func___sync_fetch_and_add_4" = "yes"; then
526   AC_DEFINE(HAVE_SYNC_FETCH_AND_ADD_4, 1,
527     [Define to 1 if the compiler provides the __sync_fetch_and_add function for uint32])
528 fi
529
530 AC_CACHE_CHECK([for __sync_add_and_fetch_8],
531 [libgo_cv_func___sync_add_and_fetch_8],
532 [AC_LINK_IFELSE([
533 typedef unsigned int uint64  __attribute__ ((mode (DI)));
534 uint64 i;
535 int main() { return __sync_add_and_fetch (&i, 1); }
536 ],
537 [libgo_cv_func___sync_add_and_fetch_8=yes],
538 [libgo_cv_func___sync_add_and_fetch_8=no])])
539 if test "$libgo_cv_func___sync_add_and_fetch_8" = "yes"; then
540   AC_DEFINE(HAVE_SYNC_ADD_AND_FETCH_8, 1,
541     [Define to 1 if the compiler provides the __sync_add_and_fetch function for uint64])
542 fi
543
544 dnl For x86 we want to use the -minline-all-stringops option to avoid
545 dnl forcing a stack split when calling memcpy and friends.
546 AC_CACHE_CHECK([whether compiler supports -minline-all-stringops],
547 [libgo_cv_c_stringops],
548 [CFLAGS_hold=$CFLAGS
549 CFLAGS="$CFLAGS -minline-all-stringops"
550 AC_COMPILE_IFELSE([int i;],
551 [libgo_cv_c_stringops=yes],
552 [libgo_cv_c_stringops=no])
553 CFLAGS=$CFLAGS_hold])
554 STRINGOPS_FLAG=
555 if test "$libgo_cv_c_stringops" = yes; then
556   STRINGOPS_FLAG=-minline-all-stringops
557 fi
558 AC_SUBST(STRINGOPS_FLAG)
559
560 dnl For x86 we want to compile the math library with -mfancy-math-387
561 dnl -funsafe-math-optimizations so that we can use the builtin
562 dnl instructions directly.
563 AC_CACHE_CHECK([whether compiler supports -mfancy-math-387],
564 [libgo_cv_c_fancymath],
565 [CFLAGS_hold=$CFLAGS
566 CFLAGS="$CFLAGS -mfancy-math-387"
567 AC_COMPILE_IFELSE([int i;],
568 [libgo_cv_c_fancymath=yes],
569 [libgo_cv_c_fancymath=no])
570 CFLAGS=$CFLAGS_hold])
571 MATH_FLAG=
572 if test "$libgo_cv_c_fancymath" = yes; then
573   MATH_FLAG="-mfancy-math-387 -funsafe-math-optimizations"
574 fi
575 AC_SUBST(MATH_FLAG)
576
577 CFLAGS_hold=$CFLAGS
578 CFLAGS="$CFLAGS -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE"
579 AC_CHECK_TYPES([off64_t])
580 CFLAGS=$CFLAGS_hold
581
582 dnl Work out the size of the epoll_events struct on GNU/Linux.
583 AC_CACHE_CHECK([epoll_event size],
584 [libgo_cv_c_epoll_event_size],
585 [AC_COMPUTE_INT(libgo_cv_c_epoll_event_size,
586 [sizeof (struct epoll_event)],
587 [#include <sys/epoll.h>],
588 [libgo_cv_c_epoll_event_size=0])])
589 SIZEOF_STRUCT_EPOLL_EVENT=${libgo_cv_c_epoll_event_size}
590 AC_SUBST(SIZEOF_STRUCT_EPOLL_EVENT)
591
592 dnl Work out the offset of the fd field in the epoll_events struct on
593 dnl GNU/Linux.
594 AC_CACHE_CHECK([epoll_event data.fd offset],
595 [libgo_cv_c_epoll_event_fd_offset],
596 [AC_COMPUTE_INT(libgo_cv_c_epoll_event_fd_offset,
597 [offsetof (struct epoll_event, data.fd)],
598 [#include <stddef.h>
599 #include <sys/epoll.h>],
600 [libgo_cv_c_epoll_event_fd_offset=0])])
601 STRUCT_EPOLL_EVENT_FD_OFFSET=${libgo_cv_c_epoll_event_fd_offset}
602 AC_SUBST(STRUCT_EPOLL_EVENT_FD_OFFSET)
603
604 dnl See if struct exception is defined in <math.h>.
605 AC_CHECK_TYPE([struct exception],
606 [libgo_has_struct_exception=yes],
607 [libgo_has_struct_exception=no],
608 [#include <math.h>])
609 if test "$libgo_has_struct_exception" = "yes"; then
610   AC_DEFINE(HAVE_STRUCT_EXCEPTION, 1,
611             [Define to 1 if <math.h> defines struct exception])
612 fi
613
614 dnl See whether setcontext changes the value of TLS variables.
615 AC_CACHE_CHECK([whether setcontext clobbers TLS variables],
616 [libgo_cv_lib_setcontext_clobbers_tls],
617 [CFLAGS_hold="$CFLAGS"
618 CFLAGS="$PTHREAD_CFLAGS"
619 LIBS_hold="$LIBS"
620 LIBS="$LIBS $PTHREAD_LIBS"
621 AC_CHECK_SIZEOF([void *])
622 AS_VAR_ARITH([ptr_type_size], [$ac_cv_sizeof_void_p \* 8])
623 AC_RUN_IFELSE(
624   [AC_LANG_SOURCE([
625 #include <pthread.h>
626 #include <stdlib.h>
627 #include <ucontext.h>
628 #include <unistd.h>
629
630 __thread int tls;
631
632 static char stack[[10 * 1024 * 1024]];
633 static ucontext_t c;
634
635 /* Called via makecontext/setcontext.  */
636
637 static void
638 cfn (void)
639 {
640   exit (tls);
641 }
642
643 /* Called via pthread_create.  */
644
645 static void *
646 tfn (void *dummy)
647 {
648   /* The thread should still see this value after calling
649      setcontext.  */
650   tls = 0;
651
652   setcontext (&c);
653
654   /* The call to setcontext should not return.  */
655   abort ();
656 }
657
658 int
659 main ()
660 {
661   pthread_t tid;
662
663   /* The thread should not see this value.  */
664   tls = 1;
665
666   if (getcontext (&c) < 0)
667     abort ();
668
669   c.uc_stack.ss_sp = stack;
670   c.uc_stack.ss_flags = 0;
671   c.uc_stack.ss_size = sizeof stack;
672   c.uc_link = NULL;
673   makecontext (&c, cfn, 0);
674
675   if (pthread_create (&tid, NULL, tfn, NULL) != 0)
676     abort ();
677
678   if (pthread_join (tid, NULL) != 0)
679     abort ();
680
681   /* The thread should have called exit.  */
682   abort ();
683 }
684 ])],
685 [libgo_cv_lib_setcontext_clobbers_tls=no],
686 [libgo_cv_lib_setcontext_clobbers_tls=yes],
687 [case "$target:$ptr_type_size" in
688   i?86-*-solaris2.1[[01]]:64 | x86_64*-*-solaris2.1[[01]]:64)
689     libgo_cv_lib_setcontext_clobbers_tls=yes ;;
690   *)
691     libgo_cv_lib_setcontext_clobbers_tls=no ;;
692  esac
693 ])
694 CFLAGS="$CFLAGS_hold"
695 LIBS="$LIBS_hold"
696 ])
697 if test "$libgo_cv_lib_setcontext_clobbers_tls" = "yes"; then
698   AC_DEFINE(SETCONTEXT_CLOBBERS_TLS, 1,
699             [Define if setcontext clobbers TLS variables])
700 fi
701
702 AC_CACHE_SAVE
703
704 if test ${multilib} = yes; then
705   multilib_arg="--enable-multilib"
706 else
707   multilib_arg=
708 fi
709
710 AC_CONFIG_FILES(Makefile testsuite/Makefile)
711
712 AC_CONFIG_COMMANDS([default],
713 [if test -n "$CONFIG_FILES"; then
714    # Multilibs need MULTISUBDIR defined correctly in certain makefiles so
715    # that multilib installs will end up installed in the correct place.
716    # The testsuite needs it for multilib-aware ABI baseline files.
717    # To work around this not being passed down from config-ml.in ->
718    # srcdir/Makefile.am -> srcdir/{src,libsupc++,...}/Makefile.am, manually
719    # append it here.  Only modify Makefiles that have just been created.
720    #
721    # Also, get rid of this simulated-VPATH thing that automake does.
722    cat > vpsed << \_EOF
723 s!`test -f '$<' || echo '$(srcdir)/'`!!
724 _EOF
725    for i in $SUBDIRS; do
726     case $CONFIG_FILES in
727      *${i}/Makefile*)
728        #echo "Adding MULTISUBDIR to $i/Makefile"
729        sed -f vpsed $i/Makefile > tmp
730        grep '^MULTISUBDIR =' Makefile >> tmp
731        mv tmp $i/Makefile
732        ;;
733     esac
734    done
735    rm vpsed
736  fi
737 ],
738 [
739 # Variables needed in config.status (file generation) which aren't already
740 # passed by autoconf.
741 SUBDIRS="$SUBDIRS"
742 ])
743
744 AC_OUTPUT