blob: 249918b15d0c367065c4d683d03beca9e3cd07bc [file] [log] [blame]
Ian Lance Taylor7a938932010-12-03 04:34:57 +00001# 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
9AC_PREREQ(2.64)
10AC_INIT(package-unused, version-unused,, libgo)
11AC_CONFIG_SRCDIR(Makefile.am)
12AC_CONFIG_HEADER(config.h)
13
14libtool_VERSION=1:0:0
15AC_SUBST(libtool_VERSION)
16
17AM_ENABLE_MULTILIB(, ..)
18
19AC_CANONICAL_SYSTEM
20target_alias=${target_alias-$host_alias}
21
22AM_INIT_AUTOMAKE([1.9.3 no-define foreign -Wall])
23AH_TEMPLATE(PACKAGE, [Name of package])
24AH_TEMPLATE(VERSION, [Version number of package])
25
26m4_rename([_AC_ARG_VAR_PRECIOUS],[glibgo_PRECIOUS])
27m4_define([_AC_ARG_VAR_PRECIOUS],[])
28AC_PROG_CC
29AC_PROG_GO
30m4_rename_force([glibgo_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
31
32AC_SUBST(CFLAGS)
33
34AM_MAINTAINER_MODE
35
Ian Lance Taylore02ed812012-01-26 20:24:01 +000036AC_INCLUDES_DEFAULT
37
Ian Lance Taylor7a938932010-12-03 04:34:57 +000038AC_PROG_LD
39AC_PROG_RANLIB
40AC_CHECK_TOOL(OBJCOPY, objcopy, missing-objcopy)
41
42AC_LIBTOOL_DLOPEN
43AM_PROG_LIBTOOL
44AC_SUBST(enable_shared)
45AC_SUBST(enable_static)
46
Ian Lance Taylord983a802011-07-11 20:27:50 +000047CC_FOR_BUILD=${CC_FOR_BUILD:-gcc}
48AC_SUBST(CC_FOR_BUILD)
49
Ian Lance Taylorde27caa2011-10-23 19:04:37 +000050AC_PROG_AWK
51
Ian Lance Taylor7a938932010-12-03 04:34:57 +000052WARN_FLAGS='-Wall -Wextra -Wwrite-strings -Wcast-qual'
53AC_SUBST(WARN_FLAGS)
54
55dnl FIXME: This should be controlled by --enable-maintainer-mode.
56WERROR="-Werror"
57AC_SUBST(WERROR)
58
59glibgo_toolexecdir=no
60glibgo_toolexeclibdir=no
Ian Lance Taylor7a938932010-12-03 04:34:57 +000061
62AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
63AC_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])
72AC_MSG_RESULT($version_specific_libs)
73
74# Version-specific runtime libs processing.
75if test $version_specific_libs = yes; then
76 glibgo_toolexecdir='${libdir}/gcc/${host_alias}'
77 glibgo_toolexeclibdir='${toolexecdir}/${gcc_version}$(MULTISUBDIR)'
78fi
79
80# Calculate glibgo_toolexecdir, glibgo_toolexeclibdir
81# Install a library built with a cross compiler in tooldir, not libdir.
Ian Lance Taylor317ea7c2012-02-14 19:40:09 +000082if 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'
86else
87 nover_glibgo_toolexecdir='${libdir}/gcc/${host_alias}'
88 nover_glibgo_toolexeclibdir='${libdir}'
89fi
90multi_os_directory=`$CC -print-multi-os-directory`
91case $multi_os_directory in
92 .) ;; # Avoid trailing /.
93 *) nover_glibgo_toolexeclibdir=${nover_glibgo_toolexeclibdir}/${multi_os_directory} ;;
94esac
95
Ian Lance Taylor7a938932010-12-03 04:34:57 +000096if test x"$glibgo_toolexecdir" = x"no"; then
Ian Lance Taylor317ea7c2012-02-14 19:40:09 +000097 glibgo_toolexecdir="${nover_glibgo_toolexecdir}"
98 glibgo_toolexeclibdir="${nover_glibgo_toolexeclibdir}"
Ian Lance Taylor7a938932010-12-03 04:34:57 +000099fi
100
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000101AC_SUBST(glibgo_toolexecdir)
102AC_SUBST(glibgo_toolexeclibdir)
Ian Lance Taylor317ea7c2012-02-14 19:40:09 +0000103AC_SUBST(nover_glibgo_toolexeclibdir)
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000104
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.
108AC_ARG_WITH(libffi,
109 AS_HELP_STRING([--without-libffi],
110 [don't use libffi]),
111 [:],
112 [with_libffi=${with_libffi_default-yes}])
113
114LIBFFI=
115LIBFFIINCS=
116if 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'
120fi
121AC_SUBST(LIBFFI)
122AC_SUBST(LIBFFIINCS)
123
Ian Lance Taylor18c70072011-12-03 00:16:12 +0000124# Used to tell GNU make to include a file without telling automake to
125# include it.
126go_include="-include"
127AC_SUBST(go_include)
128
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000129is_darwin=no
130is_freebsd=no
Ian Lance Taylor654d2ec2011-03-31 23:55:21 +0000131is_irix=no
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000132is_linux=no
Ian Lance Taylor1efa38d2012-01-17 14:18:39 +0000133is_netbsd=no
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000134is_rtems=no
Ian Lance Taylorf2ee78b2011-01-12 06:34:08 +0000135is_solaris=no
Ian Lance Taylorc3b5b972011-01-12 02:03:46 +0000136GOOS=unknown
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000137case ${host} in
Ian Lance Taylorf2ee78b2011-01-12 06:34:08 +0000138 *-*-darwin*) is_darwin=yes; GOOS=darwin ;;
139 *-*-freebsd*) is_freebsd=yes; GOOS=freebsd ;;
Ian Lance Taylor654d2ec2011-03-31 23:55:21 +0000140 *-*-irix6*) is_irix=yes; GOOS=irix ;;
Ian Lance Taylorf2ee78b2011-01-12 06:34:08 +0000141 *-*-linux*) is_linux=yes; GOOS=linux ;;
Ian Lance Taylordf4aa892012-01-13 05:11:45 +0000142 *-*-netbsd*) is_netbsd=yes; GOOS=netbsd ;;
Ian Lance Taylorf2ee78b2011-01-12 06:34:08 +0000143 *-*-rtems*) is_rtems=yes; GOOS=rtems ;;
144 *-*-solaris2*) is_solaris=yes; GOOS=solaris ;;
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000145esac
146AM_CONDITIONAL(LIBGO_IS_DARWIN, test $is_darwin = yes)
147AM_CONDITIONAL(LIBGO_IS_FREEBSD, test $is_freebsd = yes)
Ian Lance Taylor654d2ec2011-03-31 23:55:21 +0000148AM_CONDITIONAL(LIBGO_IS_IRIX, test $is_irix = yes)
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000149AM_CONDITIONAL(LIBGO_IS_LINUX, test $is_linux = yes)
Ian Lance Taylordf4aa892012-01-13 05:11:45 +0000150AM_CONDITIONAL(LIBGO_IS_NETBSD, test $is_netbsd = yes)
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000151AM_CONDITIONAL(LIBGO_IS_RTEMS, test $is_rtems = yes)
Ian Lance Taylorf2ee78b2011-01-12 06:34:08 +0000152AM_CONDITIONAL(LIBGO_IS_SOLARIS, test $is_solaris = yes)
Ian Lance Taylorc3b5b972011-01-12 02:03:46 +0000153AC_SUBST(GOOS)
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000154
Ian Lance Taylorf2ee78b2011-01-12 06:34:08 +0000155dnl N.B. Keep in sync with gcc/testsuite/go.test/go-test.exp (go-set-goarch).
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000156is_386=no
Ian Lance Taylore59b9172011-04-01 23:02:16 +0000157is_alpha=no
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000158is_arm=no
Ian Lance Taylorca11cc92011-01-24 23:42:22 +0000159is_m68k=no
Ian Lance Taylor9f3b1e62011-04-25 19:36:12 +0000160mips_abi=unknown
Ian Lance Taylorca11cc92011-01-24 23:42:22 +0000161is_ppc=no
162is_ppc64=no
Ian Lance Taylorf2ee78b2011-01-12 06:34:08 +0000163is_sparc=no
Ian Lance Taylor545d1aa2011-01-13 06:18:45 +0000164is_sparc64=no
Ian Lance Taylorf2ee78b2011-01-12 06:34:08 +0000165is_x86_64=no
Ian Lance Taylorc3b5b972011-01-12 02:03:46 +0000166GOARCH=unknown
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000167case ${host} in
Ian Lance Taylore59b9172011-04-01 23:02:16 +0000168 alpha*-*-*)
169 is_alpha=yes
170 GOARCH=alpha
171 ;;
Ian Lance Taylorca11cc92011-01-24 23:42:22 +0000172 arm*-*-* | strongarm*-*-* | ep9312*-*-* | xscale-*-*)
173 is_arm=yes
174 GOARCH=arm
175 ;;
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000176changequote(,)dnl
Ian Lance Taylorc3b5b972011-01-12 02:03:46 +0000177 i[34567]86-*-* | x86_64-*-*)
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000178changequote([,])dnl
Ian Lance Taylor4a299bf2011-02-10 23:43:42 +0000179 AC_COMPILE_IFELSE([
Ian Lance Taylorc3b5b972011-01-12 02:03:46 +0000180#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
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000186 else
Ian Lance Taylorc3b5b972011-01-12 02:03:46 +0000187 GOARCH=amd64
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000188 fi
189 ;;
Ian Lance Taylorca11cc92011-01-24 23:42:22 +0000190 m68k*-*-*)
191 is_m68k=yes
192 GOARCH=m68k
193 ;;
194 mips*-*-*)
Ian Lance Taylor4a299bf2011-02-10 23:43:42 +0000195 AC_COMPILE_IFELSE([
Ian Lance Taylor85a09212011-04-01 00:17:10 +0000196#if _MIPS_SIM != _ABIO32
197#error not o32
Ian Lance Taylorca11cc92011-01-24 23:42:22 +0000198#endif],
Ian Lance Taylor85a09212011-04-01 00:17:10 +0000199[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
Ian Lance Taylorca11cc92011-01-24 23:42:22 +0000223 ;;
224 rs6000*-*-* | powerpc*-*-*)
Ian Lance Taylor4a299bf2011-02-10 23:43:42 +0000225 AC_COMPILE_IFELSE([
Ian Lance Taylorca11cc92011-01-24 23:42:22 +0000226#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
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000235 ;;
Ian Lance Taylorf2ee78b2011-01-12 06:34:08 +0000236 sparc*-*-*)
Ian Lance Taylor4a299bf2011-02-10 23:43:42 +0000237 AC_COMPILE_IFELSE([
Ian Lance Taylorf2ee78b2011-01-12 06:34:08 +0000238#if defined(__sparcv9) || defined(__arch64__)
239#error 64-bit
240#endif],
Ian Lance Taylor545d1aa2011-01-13 06:18:45 +0000241[is_sparc=yes], [is_sparc64=yes])
Ian Lance Taylorf2ee78b2011-01-12 06:34:08 +0000242 if test "$is_sparc" = "yes"; then
Ian Lance Taylorf2ee78b2011-01-12 06:34:08 +0000243 GOARCH=sparc
244 else
Ian Lance Taylor545d1aa2011-01-13 06:18:45 +0000245 GOARCH=sparc64
Ian Lance Taylorf2ee78b2011-01-12 06:34:08 +0000246 fi
247 ;;
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000248esac
249AM_CONDITIONAL(LIBGO_IS_386, test $is_386 = yes)
Ian Lance Taylore59b9172011-04-01 23:02:16 +0000250AM_CONDITIONAL(LIBGO_IS_ALPHA, test $is_alpha = yes)
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000251AM_CONDITIONAL(LIBGO_IS_ARM, test $is_arm = yes)
Ian Lance Taylorca11cc92011-01-24 23:42:22 +0000252AM_CONDITIONAL(LIBGO_IS_M68K, test $is_m68k = yes)
Ian Lance Taylor9f3b1e62011-04-25 19:36:12 +0000253AM_CONDITIONAL(LIBGO_IS_MIPS, test $mips_abi != unknown)
Ian Lance Taylor85a09212011-04-01 00:17:10 +0000254AM_CONDITIONAL(LIBGO_IS_MIPSO32, test $mips_abi = o32)
255AM_CONDITIONAL(LIBGO_IS_MIPSN32, test $mips_abi = n32)
256AM_CONDITIONAL(LIBGO_IS_MIPSN64, test $mips_abi = n64)
257AM_CONDITIONAL(LIBGO_IS_MIPSO64, test $mips_abi = o64)
Ian Lance Taylorca11cc92011-01-24 23:42:22 +0000258AM_CONDITIONAL(LIBGO_IS_PPC, test $is_ppc = yes)
259AM_CONDITIONAL(LIBGO_IS_PPC64, test $is_ppc64 = yes)
Ian Lance Taylorf2ee78b2011-01-12 06:34:08 +0000260AM_CONDITIONAL(LIBGO_IS_SPARC, test $is_sparc = yes)
Ian Lance Taylor545d1aa2011-01-13 06:18:45 +0000261AM_CONDITIONAL(LIBGO_IS_SPARC64, test $is_sparc64 = yes)
Ian Lance Taylorf2ee78b2011-01-12 06:34:08 +0000262AM_CONDITIONAL(LIBGO_IS_X86_64, test $is_x86_64 = yes)
Ian Lance Taylorc3b5b972011-01-12 02:03:46 +0000263AC_SUBST(GOARCH)
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000264
Ian Lance Taylorca11cc92011-01-24 23:42:22 +0000265dnl Some files are only present when needed for specific architectures.
Ian Lance Taylorde27caa2011-10-23 19:04:37 +0000266GO_LIBCALL_OS_FILE=
267GO_LIBCALL_OS_ARCH_FILE=
268GO_SYSCALL_OS_FILE=
269GO_SYSCALL_OS_ARCH_FILE=
270if test -f ${srcdir}/go/syscall/libcall_${GOOS}.go; then
271 GO_LIBCALL_OS_FILE=go/syscall/libcall_${GOOS}.go
Ian Lance Taylorca11cc92011-01-24 23:42:22 +0000272fi
Ian Lance Taylorde27caa2011-10-23 19:04:37 +0000273if test -f ${srcdir}/go/syscall/libcall_${GOOS}_${GOARCH}.go; then
274 GO_LIBCALL_OS_ARCH_FILE=go/syscall/libcall_${GOOS}_${GOARCH}.go
275fi
276if test -f ${srcdir}/go/syscall/syscall_${GOOS}.go; then
277 GO_SYSCALL_OS_FILE=go/syscall/syscall_${GOOS}.go
278fi
279if test -f ${srcdir}/go/syscall/syscall_${GOOS}_${GOARCH}.go; then
280 GO_SYSCALL_OS_ARCH_FILE=go/syscall/syscall_${GOOS}_${GOARCH}.go
281fi
282AC_SUBST(GO_LIBCALL_OS_FILE)
283AC_SUBST(GO_LIBCALL_OS_ARCH_FILE)
284AC_SUBST(GO_SYSCALL_OS_FILE)
285AC_SUBST(GO_SYSCALL_OS_ARCH_FILE)
Ian Lance Taylorca11cc92011-01-24 23:42:22 +0000286
Ian Lance Taylord48be5d2011-12-20 18:14:30 +0000287dnl Special flags used to generate sysinfo.go.
288OSCFLAGS="-D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
Ian Lance Taylor90630d12011-04-01 05:11:23 +0000289case "$target" in
Ian Lance Taylor9f3b1e62011-04-25 19:36:12 +0000290 mips-sgi-irix6.5*)
291 # IRIX 6 needs _XOPEN_SOURCE=500 for the XPG5 version of struct
292 # msghdr in <sys/socket.h>.
Ian Lance Taylord48be5d2011-12-20 18:14:30 +0000293 OSCFLAGS="$OSCFLAGS -D_XOPEN_SOURCE=500"
Ian Lance Taylor9f3b1e62011-04-25 19:36:12 +0000294 ;;
Ian Lance Taylor90630d12011-04-01 05:11:23 +0000295 *-*-solaris2.[[89]])
296 # Solaris 8/9 need this so struct msghdr gets the msg_control
297 # etc. fields in <sys/socket.h> (_XPG4_2).
Ian Lance Taylord48be5d2011-12-20 18:14:30 +0000298 OSCFLAGS="$OSCFLAGS -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D__EXTENSIONS__"
Ian Lance Taylor90630d12011-04-01 05:11:23 +0000299 ;;
300 *-*-solaris2.1[[01]])
301 # Solaris 10+ needs this so struct msghdr gets the msg_control
Ian Lance Taylorbbe847a2011-12-22 20:39:29 +0000302 # etc. fields in <sys/socket.h> (_XPG4_2). _XOPEN_SOURCE=600 as
Ian Lance Taylor90630d12011-04-01 05:11:23 +0000303 # above doesn't work with C99.
Ian Lance Taylorbbe847a2011-12-22 20:39:29 +0000304 OSCFLAGS="$OSCFLAGS -std=gnu99 -D_XOPEN_SOURCE=600 -D__EXTENSIONS__"
Ian Lance Taylor90630d12011-04-01 05:11:23 +0000305 ;;
306esac
307AC_SUBST(OSCFLAGS)
308
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000309dnl Use -fsplit-stack when compiling C code if available.
310AC_CACHE_CHECK([whether -fsplit-stack is supported],
Ian Lance Taylorf2ee78b2011-01-12 06:34:08 +0000311[libgo_cv_c_split_stack_supported],
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000312[CFLAGS_hold=$CFLAGS
313CFLAGS="$CFLAGS -fsplit-stack"
314AC_COMPILE_IFELSE([[int i;]],
Ian Lance Taylorf2ee78b2011-01-12 06:34:08 +0000315[libgo_cv_c_split_stack_supported=yes],
316[libgo_cv_c_split_stack_supported=no])
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000317CFLAGS=$CFLAGS_hold])
Ian Lance Taylorf2ee78b2011-01-12 06:34:08 +0000318if test "$libgo_cv_c_split_stack_supported" = yes; then
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000319 SPLIT_STACK=-fsplit-stack
320 AC_DEFINE(USING_SPLIT_STACK, 1,
321 [Define if the compiler supports -fsplit-stack])
322else
323 SPLIT_STACK=
324fi
325AC_SUBST(SPLIT_STACK)
326AM_CONDITIONAL(USING_SPLIT_STACK,
Ian Lance Taylorf2ee78b2011-01-12 06:34:08 +0000327 test "$libgo_cv_c_split_stack_supported" = yes)
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000328
329dnl Check whether the linker does stack munging when calling from
330dnl split-stack into non-split-stack code. We check this by looking
331dnl at the --help output. FIXME: This is only half right: it's
332dnl possible for the linker to support this for some targets but not
333dnl others.
334AC_CACHE_CHECK([whether linker supports split stack],
Ian Lance Taylorf2ee78b2011-01-12 06:34:08 +0000335[libgo_cv_c_linker_supports_split_stack],
336libgo_cv_c_linker_supports_split_stack=no
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000337if $LD --help 2>/dev/null | grep split-stack-adjust-size >/dev/null 2>&1; then
Ian Lance Taylorf2ee78b2011-01-12 06:34:08 +0000338 libgo_cv_c_linker_supports_split_stack=yes
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000339fi)
Ian Lance Taylorf2ee78b2011-01-12 06:34:08 +0000340if test "$libgo_cv_c_linker_supports_split_stack" = yes; then
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000341 AC_DEFINE(LINKER_SUPPORTS_SPLIT_STACK, 1,
342 [Define if the linker support split stack adjustments])
343fi
344
Ian Lance Taylor505b4392010-12-08 02:08:59 +0000345dnl Test for the -lm library.
346MATH_LIBS=
347AC_CHECK_LIB([m], [sqrt], MATH_LIBS=-lm)
348AC_SUBST(MATH_LIBS)
349
Ian Lance Taylorf2ee78b2011-01-12 06:34:08 +0000350dnl Test for -lsocket and -lnsl. Copied from libjava/configure.ac.
351AC_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])
378NET_LIBS="$libgo_cv_lib_sockets"
379AC_SUBST(NET_LIBS)
380
Ian Lance Taylor6c94a9f2010-12-03 21:27:06 +0000381dnl Test whether the compiler supports the -pthread option.
382AC_CACHE_CHECK([whether -pthread is supported],
Ian Lance Taylorf2ee78b2011-01-12 06:34:08 +0000383[libgo_cv_lib_pthread],
Ian Lance Taylor6c94a9f2010-12-03 21:27:06 +0000384[CFLAGS_hold=$CFLAGS
385CFLAGS="$CFLAGS -pthread"
386AC_COMPILE_IFELSE([[int i;]],
Ian Lance Taylorf2ee78b2011-01-12 06:34:08 +0000387[libgo_cv_lib_pthread=yes],
388[libgo_cv_lib_pthread=no])
Ian Lance Taylor6c94a9f2010-12-03 21:27:06 +0000389CFLAGS=$CFLAGS_hold])
390PTHREAD_CFLAGS=
Ian Lance Taylorf2ee78b2011-01-12 06:34:08 +0000391if test "$libgo_cv_lib_pthread" = yes; then
Ian Lance Taylor6c94a9f2010-12-03 21:27:06 +0000392 PTHREAD_CFLAGS=-pthread
393fi
394AC_SUBST(PTHREAD_CFLAGS)
395
396dnl Test for the -lpthread library.
397PTHREAD_LIBS=
398AC_CHECK_LIB([pthread], [pthread_create], PTHREAD_LIBS=-lpthread)
399AC_SUBST(PTHREAD_LIBS)
400
Ian Lance Taylored4ebab2011-01-14 19:18:38 +0000401dnl Test if -lrt is required for sched_yield.
402AC_SEARCH_LIBS([sched_yield], [rt])
403
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000404AC_C_BIGENDIAN
405
406GCC_CHECK_UNWIND_GETIPINFO
407
Ian Lance Taylor0c521d12011-02-03 01:53:36 +0000408AC_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
417AC_CACHE_CHECK([whether to use setjmp/longjmp exceptions],
418[libgo_cv_lib_sjlj_exceptions],
419[AC_LANG_CONFTEST(
420 [AC_LANG_SOURCE([
421void bar ();
422void clean (int *);
423void foo ()
424{
425 int i __attribute__ ((cleanup (clean)));
426 bar();
427}
428])])
429CFLAGS_hold=$CFLAGS
430CFLAGS="--save-temps -fexceptions"
431libgo_cv_lib_sjlj_exceptions=unknown
432AS_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])
438CFLAGS=$CFLAGS_hold
439rm -f conftest*
440])
441
442if test "$enable_sjlj_exceptions" = "auto"; then
443 enable_sjlj_exceptions=$libgo_cv_lib_sjlj_exceptions
444fi
445
446case $enable_sjlj_exceptions in
447yes)
448 AC_DEFINE(LIBGO_SJLJ_EXCEPTIONS, 1,
449 [Define if the C++ compiler is configured for setjmp/longjmp exceptions.])
450 ;;
451no)
452 ;;
453*)
454 AC_MSG_ERROR([unable to detect exception model])
455 ;;
456esac
457
Ian Lance Taylordf1304e2012-01-25 20:56:26 +0000458AC_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)
Ian Lance Tayloradb04012011-09-16 15:47:21 +0000459
460AC_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
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000466AM_CONDITIONAL(HAVE_SYS_MMAN_H, test "$ac_cv_header_sys_mman_h" = yes)
Ian Lance Taylor8955c802011-03-30 22:34:55 +0000467
Ian Lance Taylor506cf9a2011-12-02 19:34:41 +0000468AC_CHECK_FUNCS(strerror_r strsignal wait4 mincore setenv)
Ian Lance Taylor8955c802011-03-30 22:34:55 +0000469AM_CONDITIONAL(HAVE_STRERROR_R, test "$ac_cv_func_strerror_r" = yes)
Ian Lance Taylor0b3189e2011-03-30 23:05:04 +0000470AM_CONDITIONAL(HAVE_WAIT4, test "$ac_cv_func_wait4" = yes)
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000471
Ian Lance Taylore02ed812012-01-26 20:24:01 +0000472AC_CHECK_FUNCS(epoll_create1 faccessat fchmodat fchownat futimesat inotify_add_watch inotify_init inotify_rm_watch mkdirat mknodat openat renameat splice tee unlinkat unshare)
473AC_CHECK_TYPES([loff_t])
474
Ian Lance Taylor08ee9452011-11-29 21:58:48 +0000475CFLAGS_hold="$CFLAGS"
476CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
477LIBS_hold="$LIBS"
478LIBS="$LIBS $PTHREAD_LIBS"
479AC_CHECK_FUNCS(sem_timedwait)
480CFLAGS="$CFLAGS_hold"
481LIBS="$LIBS_hold"
482
Ian Lance Taylord2b480b2012-02-08 22:35:30 +0000483LIBS_hold="$LIBS"
484LIBS="$LIBS $MATH_LIBS"
485AC_CHECK_FUNCS(matherr)
486LIBS="$LIBS_hold"
487
Ian Lance Taylora7c48c82011-02-01 21:23:07 +0000488AC_CACHE_CHECK([for __sync_bool_compare_and_swap_4],
489[libgo_cv_func___sync_bool_compare_and_swap_4],
490[AC_LINK_IFELSE([
491typedef unsigned int uint32 __attribute__ ((mode (SI)));
492uint32 i;
493int 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])])
497if 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])
500fi
501
Ian Lance Taylor12e3c392012-02-12 06:23:08 +0000502AC_CACHE_CHECK([for __sync_bool_compare_and_swap_8],
503[libgo_cv_func___sync_bool_compare_and_swap_8],
504[AC_LINK_IFELSE([
505typedef unsigned int uint64 __attribute__ ((mode (DI)));
506uint64 i;
507int 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])])
511if 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])
514fi
515
Ian Lance Taylor084996f2011-02-04 00:49:47 +0000516AC_CACHE_CHECK([for __sync_fetch_and_add_4],
517[libgo_cv_func___sync_fetch_and_add_4],
518[AC_LINK_IFELSE([
519typedef unsigned int uint32 __attribute__ ((mode (SI)));
520uint32 i;
521int 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])])
525if 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])
528fi
529
Ian Lance Taylor12e3c392012-02-12 06:23:08 +0000530AC_CACHE_CHECK([for __sync_add_and_fetch_8],
531[libgo_cv_func___sync_add_and_fetch_8],
532[AC_LINK_IFELSE([
533typedef unsigned int uint64 __attribute__ ((mode (DI)));
534uint64 i;
535int 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])])
539if 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])
542fi
543
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000544dnl For x86 we want to use the -minline-all-stringops option to avoid
545dnl forcing a stack split when calling memcpy and friends.
546AC_CACHE_CHECK([whether compiler supports -minline-all-stringops],
Ian Lance Taylorf2ee78b2011-01-12 06:34:08 +0000547[libgo_cv_c_stringops],
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000548[CFLAGS_hold=$CFLAGS
549CFLAGS="$CFLAGS -minline-all-stringops"
550AC_COMPILE_IFELSE([int i;],
Ian Lance Taylorf2ee78b2011-01-12 06:34:08 +0000551[libgo_cv_c_stringops=yes],
552[libgo_cv_c_stringops=no])
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000553CFLAGS=$CFLAGS_hold])
554STRINGOPS_FLAG=
Ian Lance Taylorf2ee78b2011-01-12 06:34:08 +0000555if test "$libgo_cv_c_stringops" = yes; then
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000556 STRINGOPS_FLAG=-minline-all-stringops
557fi
558AC_SUBST(STRINGOPS_FLAG)
559
Ian Lance Taylor9d465fa2012-02-08 19:38:17 +0000560dnl For x86 we want to compile the math library with -mfancy-math-387
561dnl -funsafe-math-optimizations so that we can use the builtin
562dnl instructions directly.
563AC_CACHE_CHECK([whether compiler supports -mfancy-math-387],
564[libgo_cv_c_fancymath],
565[CFLAGS_hold=$CFLAGS
566CFLAGS="$CFLAGS -mfancy-math-387"
567AC_COMPILE_IFELSE([int i;],
568[libgo_cv_c_fancymath=yes],
569[libgo_cv_c_fancymath=no])
570CFLAGS=$CFLAGS_hold])
571MATH_FLAG=
572if test "$libgo_cv_c_fancymath" = yes; then
573 MATH_FLAG="-mfancy-math-387 -funsafe-math-optimizations"
574fi
575AC_SUBST(MATH_FLAG)
576
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000577CFLAGS_hold=$CFLAGS
578CFLAGS="$CFLAGS -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE"
Ian Lance Taylore02ed812012-01-26 20:24:01 +0000579AC_CHECK_TYPES([off64_t])
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000580CFLAGS=$CFLAGS_hold
581
Ian Lance Taylor207c35f2011-11-01 04:12:01 +0000582dnl Work out the size of the epoll_events struct on GNU/Linux.
583AC_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])])
589SIZEOF_STRUCT_EPOLL_EVENT=${libgo_cv_c_epoll_event_size}
590AC_SUBST(SIZEOF_STRUCT_EPOLL_EVENT)
591
592dnl Work out the offset of the fd field in the epoll_events struct on
593dnl GNU/Linux.
594AC_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])])
601STRUCT_EPOLL_EVENT_FD_OFFSET=${libgo_cv_c_epoll_event_fd_offset}
602AC_SUBST(STRUCT_EPOLL_EVENT_FD_OFFSET)
603
Ian Lance Taylord2b480b2012-02-08 22:35:30 +0000604dnl See if struct exception is defined in <math.h>.
605AC_CHECK_TYPE([struct exception],
606[libgo_has_struct_exception=yes],
607[libgo_has_struct_exception=no],
608[#include <math.h>])
609if test "$libgo_has_struct_exception" = "yes"; then
610 AC_DEFINE(HAVE_STRUCT_EXCEPTION, 1,
611 [Define to 1 if <math.h> defines struct exception])
612fi
613
Ian Lance Taylor7f578432012-02-08 05:30:12 +0000614dnl See whether setcontext changes the value of TLS variables.
615AC_CACHE_CHECK([whether setcontext clobbers TLS variables],
616[libgo_cv_lib_setcontext_clobbers_tls],
Ian Lance Taylore6c58172012-02-10 14:07:44 +0000617[CFLAGS_hold="$CFLAGS"
618CFLAGS="$PTHREAD_CFLAGS"
619LIBS_hold="$LIBS"
Ian Lance Taylor7f578432012-02-08 05:30:12 +0000620LIBS="$LIBS $PTHREAD_LIBS"
Ian Lance Taylore6c58172012-02-10 14:07:44 +0000621AC_CHECK_SIZEOF([void *])
622AS_VAR_ARITH([ptr_type_size], [$ac_cv_sizeof_void_p \* 8])
Ian Lance Taylor7f578432012-02-08 05:30:12 +0000623AC_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
632static char stack[[10 * 1024 * 1024]];
633static ucontext_t c;
634
635/* Called via makecontext/setcontext. */
636
637static void
638cfn (void)
639{
640 exit (tls);
641}
642
643/* Called via pthread_create. */
644
645static void *
646tfn (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
658int
659main ()
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],
Ian Lance Taylore6c58172012-02-10 14:07:44 +0000687[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 ;;
Ian Lance Taylor7f578432012-02-08 05:30:12 +0000692 esac
693])
Ian Lance Taylore6c58172012-02-10 14:07:44 +0000694CFLAGS="$CFLAGS_hold"
Ian Lance Taylor7f578432012-02-08 05:30:12 +0000695LIBS="$LIBS_hold"
696])
697if test "$libgo_cv_lib_setcontext_clobbers_tls" = "yes"; then
698 AC_DEFINE(SETCONTEXT_CLOBBERS_TLS, 1,
699 [Define if setcontext clobbers TLS variables])
700fi
701
Ian Lance Taylor7a938932010-12-03 04:34:57 +0000702AC_CACHE_SAVE
703
704if test ${multilib} = yes; then
705 multilib_arg="--enable-multilib"
706else
707 multilib_arg=
708fi
709
710AC_CONFIG_FILES(Makefile testsuite/Makefile)
711
712AC_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
723s!`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.
741SUBDIRS="$SUBDIRS"
742])
743
744AC_OUTPUT