blob: 1b4f325d30c01e83050188e206d007b3cc276c43 [file] [log] [blame]
Richard Henderson48310492012-05-01 08:48:28 -07001# Process this file with autoreconf to produce a configure script.
2# Copyright (C) 2012 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
25AC_PREREQ(2.59)
26AC_INIT([GNU Atomic Library], 1.0,,[libatomic])
27AC_CONFIG_HEADER(auto-config.h)
28
29# -------
30# Options
31# -------
32
33AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
34LIBAT_ENABLE(version-specific-runtime-libs, no, ,
35 [Specify that runtime libraries should be installed in a compiler-specific directory],
36 permit yes|no)
37AC_MSG_RESULT($enable_version_specific_runtime_libs)
38
39# We would like our source tree to be readonly. However when releases or
40# pre-releases are generated, the flex/bison generated files as well as the
41# various formats of manuals need to be included along with the rest of the
42# sources. Therefore we have --enable-generated-files-in-srcdir to do
43# just that.
44AC_MSG_CHECKING([for --enable-generated-files-in-srcdir])
45LIBAT_ENABLE(generated-files-in-srcdir, no, ,
46 [put copies of generated files in source dir intended for creating source
47 tarballs for users without texinfo bison or flex.],
48 permit yes|no)
49AC_MSG_RESULT($enable_generated_files_in_srcdir)
50AM_CONDITIONAL(GENINSRC, test "$enable_generated_files_in_srcdir" = yes)
51
52
53# -------
54
55# Gets build, host, target, *_vendor, *_cpu, *_os, etc.
56#
57# You will slowly go insane if you do not grok the following fact: when
58# building this library, the top-level /target/ becomes the library's /host/.
59#
60# configure then causes --target to default to --host, exactly like any
61# other package using autoconf. Therefore, 'target' and 'host' will
62# always be the same. This makes sense both for native and cross compilers
63# just think about it for a little while. :-)
64#
65# Also, if this library is being configured as part of a cross compiler, the
66# top-level configure script will pass the "real" host as $with_cross_host.
67#
68# Do not delete or change the following two lines. For why, see
69# http://gcc.gnu.org/ml/libstdc++/2003-07/msg00451.html
70AC_CANONICAL_SYSTEM
71target_alias=${target_alias-$host_alias}
72
73# Sets up automake. Must come after AC_CANONICAL_SYSTEM. Each of the
74# following is magically included in AUTOMAKE_OPTIONS in each Makefile.am.
75# 1.9.0: minimum required version
76# no-define: PACKAGE and VERSION will not be #define'd in config.h (a bunch
77# of other PACKAGE_* variables will, however, and there's nothing
78# we can do about that; they come from AC_INIT).
79# foreign: we don't follow the normal rules for GNU packages (no COPYING
80# file in the top srcdir, etc, etc), so stop complaining.
81# -Wall: turns on all automake warnings...
82# -Wno-portability: ...except this one, since GNU make is required.
83# -Wno-override: ... and this one, since we do want this in testsuite.
84AM_INIT_AUTOMAKE([1.9.0 foreign -Wall -Wno-portability -Wno-override])
85AM_ENABLE_MULTILIB(, ..)
86
87# Calculate toolexeclibdir
88# Also toolexecdir, though it's only used in toolexeclibdir
89case ${enable_version_specific_runtime_libs} in
90 yes)
91 # Need the gcc compiler version to know where to install libraries
92 # and header files if --enable-version-specific-runtime-libs option
93 # is selected.
94 toolexecdir='$(libdir)/gcc/$(target_alias)'
95 toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)'
96 ;;
97 no)
98 if test -n "$with_cross_host" &&
99 test x"$with_cross_host" != x"no"; then
100 # Install a library built with a cross compiler in tooldir, not libdir.
101 toolexecdir='$(exec_prefix)/$(target_alias)'
102 toolexeclibdir='$(toolexecdir)/lib'
103 else
104 toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
105 toolexeclibdir='$(libdir)'
106 fi
107 multi_os_directory=`$CC -print-multi-os-directory`
108 case $multi_os_directory in
109 .) ;; # Avoid trailing /.
110 *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
111 esac
112 ;;
113esac
114AC_SUBST(toolexecdir)
115AC_SUBST(toolexeclibdir)
116
117# Check the compiler.
118# The same as in boehm-gc and libstdc++. Have to borrow it from there.
119# We must force CC to /not/ be precious variables; otherwise
120# the wrong, non-multilib-adjusted value will be used in multilibs.
121# As a side effect, we have to subst CFLAGS ourselves.
122
123m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
124m4_define([_AC_ARG_VAR_PRECIOUS],[])
125AC_PROG_CC
126AM_PROG_AS
127m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
128
129AC_SUBST(CFLAGS)
130
131# In order to override CFLAGS_FOR_TARGET, all of our special flags go
132# in XCFLAGS. But we need them in CFLAGS during configury. So put them
133# in both places for now and restore CFLAGS at the end of config.
134save_CFLAGS="$CFLAGS"
135
136# Find other programs we need.
137AC_CHECK_TOOL(AR, ar)
138AC_CHECK_TOOL(NM, nm)
139AC_CHECK_TOOL(RANLIB, ranlib, ranlib-not-found-in-path-error)
140AC_PATH_PROG(PERL, perl, perl-not-found-in-path-error)
141AC_PROG_INSTALL
142
143# Configure libtool
144AM_PROG_LIBTOOL
145AC_SUBST(enable_shared)
146AC_SUBST(enable_static)
Richard Hendersonfa3cd3c2012-05-03 09:30:11 -0700147AM_MAINTAINER_MODE
Richard Henderson48310492012-05-01 08:48:28 -0700148
149# For libtool versioning info, format is CURRENT:REVISION:AGE
150libtool_VERSION=1:0:0
151AC_SUBST(libtool_VERSION)
152
153# Get target configury.
154. ${srcdir}/configure.tgt
155if test -n "$UNSUPPORTED"; then
156 AC_MSG_ERROR([Configuration ${target} is unsupported.])
157fi
158
159# Disable fallbacks to __sync routines from libgcc. Otherwise we'll
160# make silly decisions about what the cpu can do.
161CFLAGS="$save_CFLAGS -fno-sync-libcalls $XCFLAGS"
162
163# Check header files.
164AC_STDC_HEADERS
165ACX_HEADER_STRING
166GCC_HEADER_STDINT(gstdint.h)
167
168# Check for common type sizes
169LIBAT_FORALL_MODES([LIBAT_HAVE_INT_MODE])
170
171# Check for compiler builtins of atomic operations.
172LIBAT_TEST_ATOMIC_INIT
173LIBAT_FORALL_MODES([LIBAT_HAVE_ATOMIC_LOADSTORE])
174LIBAT_FORALL_MODES([LIBAT_HAVE_ATOMIC_TAS])
175LIBAT_FORALL_MODES([LIBAT_HAVE_ATOMIC_EXCHANGE])
176LIBAT_FORALL_MODES([LIBAT_HAVE_ATOMIC_CAS])
177LIBAT_FORALL_MODES([LIBAT_HAVE_ATOMIC_FETCH_ADD])
178LIBAT_FORALL_MODES([LIBAT_HAVE_ATOMIC_FETCH_OP])
179
180AC_C_BIGENDIAN
181# I don't like the default behaviour of WORDS_BIGENDIAN undefined for LE.
182AH_BOTTOM(
183[#ifndef WORDS_BIGENDIAN
184#define WORDS_BIGENDIAN 0
185#endif])
186
187LIBAT_WORDSIZE
188
189# Check to see if -pthread or -lpthread is needed. Prefer the former.
190# In case the pthread.h system header is not found, this test will fail.
191case " $config_path " in
192 *" posix "*)
193 XPCFLAGS=""
194 CFLAGS="$CFLAGS -pthread"
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 [XPCFLAGS=" -pthread"],
201 [CFLAGS="$save_CFLAGS $XCFLAGS" LIBS="-lpthread $LIBS"
202 AC_LINK_IFELSE(
203 [AC_LANG_PROGRAM(
204 [#include <pthread.h>
205 void *g(void *d) { return NULL; }],
206 [pthread_t t; pthread_create(&t,NULL,g,NULL);])],
207 [],
208 [AC_MSG_ERROR([Pthreads are required to build libatomic])])])
209 CFLAGS="$save_CFLAGS $XCFLAGS"
210 ;;
211esac
212
213# See what sort of export controls are available.
214LIBAT_CHECK_ATTRIBUTE_VISIBILITY
215LIBAT_CHECK_ATTRIBUTE_DLLEXPORT
216LIBAT_CHECK_ATTRIBUTE_ALIAS
217if test x$try_ifunc = xyes; then
218 LIBAT_CHECK_IFUNC
219fi
220
221# Check linker support.
222LIBAT_ENABLE_SYMVERS
223
224# Cleanup and exit.
225CFLAGS="$save_CFLAGS"
226AC_CACHE_SAVE
227
228# Add -Wall -Werror if we are using GCC.
229if test "x$GCC" = "xyes"; then
230 XCFLAGS="$XCFLAGS -Wall -Werror"
231fi
232
233XCFLAGS="$XCFLAGS $XPCFLAGS"
234
235AC_SUBST(config_path)
236AC_SUBST(XCFLAGS)
237AC_SUBST(XLDFLAGS)
238AC_SUBST(LIBS)
239AC_SUBST(SIZES)
240
241AM_CONDITIONAL(HAVE_IFUNC, test x$libat_cv_have_ifunc = xyes)
242AM_CONDITIONAL(ARCH_ARM_LINUX,
243 [expr "$config_path" : ".* linux/arm .*" > /dev/null])
244AM_CONDITIONAL(ARCH_I386,
245 [test "$ARCH" = x86 && test x$libat_cv_wordsize = x4])
246AM_CONDITIONAL(ARCH_X86_64,
247 [test "$ARCH" = x86 && test x$libat_cv_wordsize = x8])
248
249if test ${multilib} = yes; then
250 multilib_arg="--enable-multilib"
251else
252 multilib_arg=
253fi
254
255AC_CONFIG_FILES(Makefile testsuite/Makefile)
256AC_OUTPUT