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