configure.ac 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. # Process this file with autoreconf to produce a configure script.
  2. # Copyright (C) 2011-2015 Free Software Foundation, Inc.
  3. # This program is free software; you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation; either version 2 of the License, or
  6. # (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program; if not, write to the Free Software
  15. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  16. AC_PREREQ(2.59)
  17. AC_INIT([GNU TM Runtime Library], 1.0,,[libitm])
  18. AC_CONFIG_HEADER(config.h)
  19. # -------
  20. # Options
  21. # -------
  22. AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
  23. LIBITM_ENABLE(version-specific-runtime-libs, no, ,
  24. [Specify that runtime libraries should be installed in a compiler-specific directory],
  25. permit yes|no)
  26. AC_MSG_RESULT($enable_version_specific_runtime_libs)
  27. # We would like our source tree to be readonly. However when releases or
  28. # pre-releases are generated, the flex/bison generated files as well as the
  29. # various formats of manuals need to be included along with the rest of the
  30. # sources. Therefore we have --enable-generated-files-in-srcdir to do
  31. # just that.
  32. AC_MSG_CHECKING([for --enable-generated-files-in-srcdir])
  33. LIBITM_ENABLE(generated-files-in-srcdir, no, ,
  34. [put copies of generated files in source dir intended for creating source
  35. tarballs for users without texinfo bison or flex.],
  36. permit yes|no)
  37. AC_MSG_RESULT($enable_generated_files_in_srcdir)
  38. AM_CONDITIONAL(GENINSRC, test "$enable_generated_files_in_srcdir" = yes)
  39. # -------
  40. # -------
  41. # Gets build, host, target, *_vendor, *_cpu, *_os, etc.
  42. #
  43. # You will slowly go insane if you do not grok the following fact: when
  44. # building this library, the top-level /target/ becomes the library's /host/.
  45. #
  46. # configure then causes --target to default to --host, exactly like any
  47. # other package using autoconf. Therefore, 'target' and 'host' will
  48. # always be the same. This makes sense both for native and cross compilers
  49. # just think about it for a little while. :-)
  50. #
  51. # Also, if this library is being configured as part of a cross compiler, the
  52. # top-level configure script will pass the "real" host as $with_cross_host.
  53. #
  54. # Do not delete or change the following two lines. For why, see
  55. # http://gcc.gnu.org/ml/libstdc++/2003-07/msg00451.html
  56. AC_CANONICAL_SYSTEM
  57. target_alias=${target_alias-$host_alias}
  58. # Sets up automake. Must come after AC_CANONICAL_SYSTEM. Each of the
  59. # following is magically included in AUTOMAKE_OPTIONS in each Makefile.am.
  60. # 1.9.0: minimum required version
  61. # no-define: PACKAGE and VERSION will not be #define'd in config.h (a bunch
  62. # of other PACKAGE_* variables will, however, and there's nothing
  63. # we can do about that; they come from AC_INIT).
  64. # no-dist: we don't want 'dist' and related rules.
  65. # foreign: we don't follow the normal rules for GNU packages (no COPYING
  66. # file in the top srcdir, etc, etc), so stop complaining.
  67. # -Wall: turns on all automake warnings...
  68. # -Wno-portability: ...except this one, since GNU make is required.
  69. # -Wno-override: ... and this one, since we do want this in testsuite.
  70. AM_INIT_AUTOMAKE([1.9.0 foreign no-dist -Wall -Wno-portability -Wno-override])
  71. AM_ENABLE_MULTILIB(, ..)
  72. # Calculate toolexeclibdir
  73. # Also toolexecdir, though it's only used in toolexeclibdir
  74. case ${enable_version_specific_runtime_libs} in
  75. yes)
  76. # Need the gcc compiler version to know where to install libraries
  77. # and header files if --enable-version-specific-runtime-libs option
  78. # is selected.
  79. toolexecdir='$(libdir)/gcc/$(target_alias)'
  80. toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)'
  81. ;;
  82. no)
  83. if test -n "$with_cross_host" &&
  84. test x"$with_cross_host" != x"no"; then
  85. # Install a library built with a cross compiler in tooldir, not libdir.
  86. toolexecdir='$(exec_prefix)/$(target_alias)'
  87. toolexeclibdir='$(toolexecdir)/lib'
  88. else
  89. toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
  90. toolexeclibdir='$(libdir)'
  91. fi
  92. multi_os_directory=`$CC -print-multi-os-directory`
  93. case $multi_os_directory in
  94. .) ;; # Avoid trailing /.
  95. *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
  96. esac
  97. ;;
  98. esac
  99. AC_SUBST(toolexecdir)
  100. AC_SUBST(toolexeclibdir)
  101. # Check the compiler.
  102. # The same as in boehm-gc and libstdc++. Have to borrow it from there.
  103. # We must force CC to /not/ be precious variables; otherwise
  104. # the wrong, non-multilib-adjusted value will be used in multilibs.
  105. # As a side effect, we have to subst CFLAGS ourselves.
  106. m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
  107. m4_define([_AC_ARG_VAR_PRECIOUS],[])
  108. AC_PROG_CC
  109. AC_PROG_CXX
  110. AM_PROG_AS
  111. m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
  112. AC_SUBST(CFLAGS)
  113. # In order to override CFLAGS_FOR_TARGET, all of our special flags go
  114. # in XCFLAGS. But we need them in CFLAGS during configury. So put them
  115. # in both places for now and restore CFLAGS at the end of config.
  116. save_CFLAGS="$CFLAGS"
  117. # Find other programs we need.
  118. AC_CHECK_TOOL(AR, ar)
  119. AC_CHECK_TOOL(NM, nm)
  120. AC_CHECK_TOOL(RANLIB, ranlib, ranlib-not-found-in-path-error)
  121. AC_PATH_PROG(PERL, perl, perl-not-found-in-path-error)
  122. AC_PROG_MAKE_SET
  123. AC_PROG_INSTALL
  124. # See if makeinfo has been installed and is modern enough
  125. # that we can use it.
  126. ACX_CHECK_PROG_VER([MAKEINFO], [makeinfo], [--version],
  127. [GNU texinfo.* \([0-9][0-9.]*\)],
  128. [4.[4-9]*|4.[1-9][0-9]*|[5-9]*|[1-9][0-9]*])
  129. AM_CONDITIONAL(BUILD_INFO, test $gcc_cv_prog_makeinfo_modern = "yes")
  130. # Configure libtool
  131. AM_PROG_LIBTOOL
  132. AC_SUBST(enable_shared)
  133. AC_SUBST(enable_static)
  134. AM_MAINTAINER_MODE
  135. # For libtool versioning info, format is CURRENT:REVISION:AGE
  136. libtool_VERSION=1:0:0
  137. AC_SUBST(libtool_VERSION)
  138. # Check header files.
  139. AC_STDC_HEADERS
  140. AC_HEADER_TIME
  141. ACX_HEADER_STRING
  142. AC_CHECK_HEADERS(unistd.h semaphore.h sys/time.h sys/auxv.h malloc.h)
  143. GCC_HEADER_STDINT(gstdint.h)
  144. GCC_AC_FUNC_MMAP_BLACKLIST
  145. AC_C_BIGENDIAN
  146. # I don't like the default behaviour of WORDS_BIGENDIAN undefined for LE.
  147. AH_BOTTOM(
  148. [#ifndef WORDS_BIGENDIAN
  149. #define WORDS_BIGENDIAN 0
  150. #endif])
  151. # Check to see if -pthread or -lpthread is needed. Prefer the former.
  152. # In case the pthread.h system header is not found, this test will fail.
  153. XPCFLAGS=""
  154. CFLAGS="$CFLAGS -pthread"
  155. AC_LINK_IFELSE(
  156. [AC_LANG_PROGRAM(
  157. [#include <pthread.h>
  158. void *g(void *d) { return NULL; }],
  159. [pthread_t t; pthread_create(&t,NULL,g,NULL);])],
  160. [XPCFLAGS=" -Wc,-pthread"],
  161. [CFLAGS="$save_CFLAGS" LIBS="-lpthread $LIBS"
  162. AC_LINK_IFELSE(
  163. [AC_LANG_PROGRAM(
  164. [#include <pthread.h>
  165. void *g(void *d) { return NULL; }],
  166. [pthread_t t; pthread_create(&t,NULL,g,NULL);])],
  167. [],
  168. [AC_MSG_ERROR([Pthreads are required to build libitm])])])
  169. # Check for functions needed.
  170. AC_CHECK_FUNCS(strtoull memalign posix_memalign getauxval)
  171. # Check for broken semaphore implementation on darwin.
  172. # sem_init returns: sem_init error: Function not implemented.
  173. case "$host" in
  174. *-darwin*)
  175. AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
  176. Define if the POSIX Semaphores do not work on your system.)
  177. ;;
  178. esac
  179. GCC_LINUX_FUTEX(:)
  180. # See if we support thread-local storage.
  181. GCC_CHECK_TLS
  182. # See what sort of export controls are available.
  183. LIBITM_CHECK_ATTRIBUTE_VISIBILITY
  184. LIBITM_CHECK_ATTRIBUTE_DLLEXPORT
  185. LIBITM_CHECK_ATTRIBUTE_ALIAS
  186. # Check linker hardware capability support.
  187. LIBITM_CHECK_LINKER_HWCAP
  188. # If defaulting to -mavx, don't clear hwcaps.
  189. AC_CHECK_DECL([__AVX__], [HWCAP_LDFLAGS=''])
  190. LIBITM_ENABLE_SYMVERS
  191. if test $enable_symvers = gnu; then
  192. AC_DEFINE(LIBITM_GNU_SYMBOL_VERSIONING, 1,
  193. [Define to 1 if GNU symbol versioning is used for libitm.])
  194. fi
  195. # See if we can emit unwind info in the sjlj stub.
  196. GCC_AS_CFI_PSEUDO_OP
  197. # Determine the proper ABI type for size_t.
  198. LIBITM_CHECK_SIZE_T_MANGLING
  199. # Get target configury.
  200. . ${srcdir}/configure.tgt
  201. if test -n "$UNSUPPORTED"; then
  202. AC_MSG_ERROR([Configuration ${target} is unsupported.])
  203. fi
  204. CFLAGS="$save_CFLAGS $XCFLAGS"
  205. # Check for __sync_val_compare_and_swap, but only after the target has
  206. # had a chance to set XCFLAGS.
  207. LIBITM_CHECK_SYNC_BUILTINS
  208. LIBITM_CHECK_64BIT_SYNC_BUILTINS
  209. LIBITM_CHECK_AS_AVX
  210. LIBITM_CHECK_AS_RTM
  211. LIBITM_CHECK_AS_HTM
  212. GCC_CHECK_ELF_STYLE_WEAKREF
  213. # Cleanup and exit.
  214. CFLAGS="$save_CFLAGS"
  215. AC_CACHE_SAVE
  216. # Add -Wall -Werror if we are using GCC.
  217. if test "x$GCC" = "xyes"; then
  218. XCFLAGS="$XCFLAGS -Wall -Werror"
  219. fi
  220. XCFLAGS="$XCFLAGS $XPCFLAGS"
  221. AC_SUBST(config_path)
  222. AC_SUBST(XCFLAGS)
  223. AC_SUBST(XLDFLAGS)
  224. if test ${multilib} = yes; then
  225. multilib_arg="--enable-multilib"
  226. else
  227. multilib_arg=
  228. fi
  229. # Set up the set of libraries that we need to link against for libitm.
  230. # Note that the GTM_SELF_SPECS in gcc.c will force -pthread for -fgnu-tm,
  231. # which will force linkage against -lpthread (or equivalent for the system).
  232. # That's not 100% ideal, but about the best we can do easily.
  233. if test $enable_shared = yes; then
  234. link_itm="-litm %{static: $LIBS}"
  235. else
  236. link_itm="-litm $LIBS"
  237. fi
  238. AC_SUBST(link_itm)
  239. AM_CONDITIONAL([ARCH_ARM], [test "$ARCH" = arm])
  240. AM_CONDITIONAL([ARCH_X86], [test "$ARCH" = x86])
  241. AM_CONDITIONAL([ARCH_X86_AVX], [test "$libitm_cv_as_avx" = yes])
  242. AM_CONDITIONAL([ARCH_FUTEX], [test $enable_linux_futex = yes])
  243. AC_CONFIG_FILES(Makefile testsuite/Makefile libitm.spec)
  244. AC_OUTPUT