configure.ac 27 KB

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