configure.ac 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. # Process this file with autoreconf to produce a configure script.
  2. # Copyright (C) 2012-2015 Free Software Foundation, Inc.
  3. #
  4. # This file is part of the GNU Atomic Library (libatomic).
  5. #
  6. # Libatomic is free software; you can redistribute it and/or modify it
  7. # under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
  12. # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  13. # FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  14. # more details.
  15. #
  16. # Under Section 7 of GPL version 3, you are granted additional
  17. # permissions described in the GCC Runtime Library Exception, version
  18. # 3.1, as published by the Free Software Foundation.
  19. #
  20. # You should have received a copy of the GNU General Public License and
  21. # a copy of the GCC Runtime Library Exception along with this program;
  22. # see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  23. # <http://www.gnu.org/licenses/>.
  24. AC_PREREQ(2.59)
  25. AC_INIT([GNU Atomic Library], 1.0,,[libatomic])
  26. AC_CONFIG_HEADER(auto-config.h)
  27. # -------
  28. # Options
  29. # -------
  30. AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
  31. LIBAT_ENABLE(version-specific-runtime-libs, no, ,
  32. [Specify that runtime libraries should be installed in a compiler-specific directory],
  33. permit yes|no)
  34. AC_MSG_RESULT($enable_version_specific_runtime_libs)
  35. # We would like our source tree to be readonly. However when releases or
  36. # pre-releases are generated, the flex/bison generated files as well as the
  37. # various formats of manuals need to be included along with the rest of the
  38. # sources. Therefore we have --enable-generated-files-in-srcdir to do
  39. # just that.
  40. AC_MSG_CHECKING([for --enable-generated-files-in-srcdir])
  41. LIBAT_ENABLE(generated-files-in-srcdir, no, ,
  42. [put copies of generated files in source dir intended for creating source
  43. tarballs for users without texinfo bison or flex.],
  44. permit yes|no)
  45. AC_MSG_RESULT($enable_generated_files_in_srcdir)
  46. AM_CONDITIONAL(GENINSRC, test "$enable_generated_files_in_srcdir" = yes)
  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. # Sets up automake. Must come after AC_CANONICAL_SYSTEM. Each of the
  66. # following is magically included in AUTOMAKE_OPTIONS in each Makefile.am.
  67. # 1.9.0: minimum required version
  68. # no-define: PACKAGE and VERSION will not be #define'd in config.h (a bunch
  69. # of other PACKAGE_* variables will, however, and there's nothing
  70. # we can do about that; they come from AC_INIT).
  71. # no-dist: we don't want 'dist' and related rules.
  72. # foreign: we don't follow the normal rules for GNU packages (no COPYING
  73. # file in the top srcdir, etc, etc), so stop complaining.
  74. # -Wall: turns on all automake warnings...
  75. # -Wno-portability: ...except this one, since GNU make is required.
  76. # -Wno-override: ... and this one, since we do want this in testsuite.
  77. AM_INIT_AUTOMAKE([1.9.0 foreign no-dist -Wall -Wno-portability -Wno-override])
  78. AM_ENABLE_MULTILIB(, ..)
  79. # Calculate toolexeclibdir
  80. # Also toolexecdir, though it's only used in toolexeclibdir
  81. case ${enable_version_specific_runtime_libs} in
  82. yes)
  83. # Need the gcc compiler version to know where to install libraries
  84. # and header files if --enable-version-specific-runtime-libs option
  85. # is selected.
  86. toolexecdir='$(libdir)/gcc/$(target_alias)'
  87. toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)'
  88. ;;
  89. no)
  90. if test -n "$with_cross_host" &&
  91. test x"$with_cross_host" != x"no"; then
  92. # Install a library built with a cross compiler in tooldir, not libdir.
  93. toolexecdir='$(exec_prefix)/$(target_alias)'
  94. toolexeclibdir='$(toolexecdir)/lib'
  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. AM_PROG_AS
  117. m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
  118. AC_SUBST(CFLAGS)
  119. # In order to override CFLAGS_FOR_TARGET, all of our special flags go
  120. # in XCFLAGS. But we need them in CFLAGS during configury. So put them
  121. # in both places for now and restore CFLAGS at the end of config.
  122. save_CFLAGS="$CFLAGS"
  123. # Find other programs we need.
  124. AC_CHECK_TOOL(AR, ar)
  125. AC_CHECK_TOOL(NM, nm)
  126. AC_CHECK_TOOL(RANLIB, ranlib, ranlib-not-found-in-path-error)
  127. AC_PATH_PROG(PERL, perl, perl-not-found-in-path-error)
  128. AC_PROG_INSTALL
  129. # Configure libtool
  130. AM_PROG_LIBTOOL
  131. ACX_LT_HOST_FLAGS
  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=2:0:1
  137. AC_SUBST(libtool_VERSION)
  138. # Check for used threading-model
  139. AC_MSG_CHECKING([for thread model used by GCC])
  140. target_thread_file=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
  141. AC_MSG_RESULT([$target_thread_file])
  142. # Get target configury.
  143. . ${srcdir}/configure.tgt
  144. if test -n "$UNSUPPORTED"; then
  145. AC_MSG_ERROR([Configuration ${target} is unsupported.])
  146. fi
  147. # Disable fallbacks to __sync routines from libgcc. Otherwise we'll
  148. # make silly decisions about what the cpu can do.
  149. CFLAGS="$save_CFLAGS -fno-sync-libcalls $XCFLAGS"
  150. # Check header files.
  151. AC_STDC_HEADERS
  152. ACX_HEADER_STRING
  153. GCC_HEADER_STDINT(gstdint.h)
  154. AC_CHECK_HEADERS([fenv.h])
  155. # Check for common type sizes
  156. LIBAT_FORALL_MODES([LIBAT_HAVE_INT_MODE])
  157. # Check for compiler builtins of atomic operations.
  158. LIBAT_TEST_ATOMIC_INIT
  159. LIBAT_FORALL_MODES([LIBAT_HAVE_ATOMIC_LOADSTORE])
  160. LIBAT_FORALL_MODES([LIBAT_HAVE_ATOMIC_TAS])
  161. LIBAT_FORALL_MODES([LIBAT_HAVE_ATOMIC_EXCHANGE])
  162. LIBAT_FORALL_MODES([LIBAT_HAVE_ATOMIC_CAS])
  163. LIBAT_FORALL_MODES([LIBAT_HAVE_ATOMIC_FETCH_ADD])
  164. LIBAT_FORALL_MODES([LIBAT_HAVE_ATOMIC_FETCH_OP])
  165. AC_C_BIGENDIAN
  166. # I don't like the default behaviour of WORDS_BIGENDIAN undefined for LE.
  167. AH_BOTTOM(
  168. [#ifndef WORDS_BIGENDIAN
  169. #define WORDS_BIGENDIAN 0
  170. #endif])
  171. LIBAT_WORDSIZE
  172. # Check to see if -pthread or -lpthread is needed. Prefer the former.
  173. # In case the pthread.h system header is not found, this test will fail.
  174. case " $config_path " in
  175. *" posix "*)
  176. XPCFLAGS=""
  177. CFLAGS="$CFLAGS -pthread"
  178. AC_LINK_IFELSE(
  179. [AC_LANG_PROGRAM(
  180. [#include <pthread.h>
  181. void *g(void *d) { return NULL; }],
  182. [pthread_t t; pthread_create(&t,NULL,g,NULL);])],
  183. [XPCFLAGS=" -pthread"],
  184. [CFLAGS="$save_CFLAGS $XCFLAGS" LIBS="-lpthread $LIBS"
  185. AC_LINK_IFELSE(
  186. [AC_LANG_PROGRAM(
  187. [#include <pthread.h>
  188. void *g(void *d) { return NULL; }],
  189. [pthread_t t; pthread_create(&t,NULL,g,NULL);])],
  190. [],
  191. [AC_MSG_ERROR([Pthreads are required to build libatomic])])])
  192. CFLAGS="$save_CFLAGS $XPCFLAGS"
  193. ;;
  194. esac
  195. # See what sort of export controls are available.
  196. LIBAT_CHECK_ATTRIBUTE_VISIBILITY
  197. LIBAT_CHECK_ATTRIBUTE_DLLEXPORT
  198. LIBAT_CHECK_ATTRIBUTE_ALIAS
  199. if test x$try_ifunc = xyes; then
  200. LIBAT_CHECK_IFUNC
  201. fi
  202. # Check linker support.
  203. LIBAT_ENABLE_SYMVERS
  204. # Cleanup and exit.
  205. CFLAGS="$save_CFLAGS"
  206. AC_CACHE_SAVE
  207. # Add -Wall -Werror if we are using GCC.
  208. if test "x$GCC" = "xyes"; then
  209. XCFLAGS="$XCFLAGS -Wall -Werror"
  210. fi
  211. XCFLAGS="$XCFLAGS $XPCFLAGS"
  212. AC_SUBST(config_path)
  213. AC_SUBST(XCFLAGS)
  214. AC_SUBST(XLDFLAGS)
  215. AC_SUBST(LIBS)
  216. AC_SUBST(SIZES)
  217. AM_CONDITIONAL(HAVE_IFUNC, test x$libat_cv_have_ifunc = xyes)
  218. AM_CONDITIONAL(ARCH_ARM_LINUX,
  219. [expr "$config_path" : ".* linux/arm .*" > /dev/null])
  220. AM_CONDITIONAL(ARCH_I386,
  221. [test "$ARCH" = x86 && test x$libat_cv_wordsize = x4])
  222. AM_CONDITIONAL(ARCH_X86_64,
  223. [test "$ARCH" = x86 && test x$libat_cv_wordsize = x8])
  224. if test ${multilib} = yes; then
  225. multilib_arg="--enable-multilib"
  226. else
  227. multilib_arg=
  228. fi
  229. AC_CONFIG_FILES(Makefile testsuite/Makefile)
  230. AC_OUTPUT