configure.ac 9.9 KB

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