PR target/65871
[official-gcc.git] / libcilkrts / configure.ac
blob8ad647ea8e77a0190f79978291af3ad8ae884fa4
1 #  @copyright
2 #  Copyright (C) 2011-2013, Intel Corporation
3 #  All rights reserved.
4 #  
5 #  @copyright
6 #  Redistribution and use in source and binary forms, with or without
7 #  modification, are permitted provided that the following conditions
8 #  are met:
9 #  
10 #    * Redistributions of source code must retain the above copyright
11 #      notice, this list of conditions and the following disclaimer.
12 #    * Redistributions in binary form must reproduce the above copyright
13 #      notice, this list of conditions and the following disclaimer in
14 #      the documentation and/or other materials provided with the
15 #      distribution.
16 #    * Neither the name of Intel Corporation nor the names of its
17 #      contributors may be used to endorse or promote products derived
18 #      from this software without specific prior written permission.
19 #  
20 #  @copyright
21 #  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 #  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 #  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 #  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 #  HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 #  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 #  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28 #  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 #  AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 #  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
31 #  WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 #  POSSIBILITY OF SUCH DAMAGE.
34 AC_INIT([Cilk Runtime Library], [2.0], [cilk@intel.com])
35 AC_PREREQ([2.64])
37 # Needed to define ${target}.  Needs to be very early to avoid annoying
38 # warning about calling AC_ARG_PROGRAM before AC_CANONICAL_SYSTEM
39 AC_CANONICAL_SYSTEM
40 target_alias=${target_alias-$host_alias}
41 AC_SUBST(target_alias)
42 AM_INIT_AUTOMAKE(foreign no-dist)
44 AM_MAINTAINER_MODE
46 AM_ENABLE_MULTILIB(, ..)
48 # Build a DLL on Windows
49 # AC_LIBTOOL_WIN32_DLL
50 AC_PROG_CC
51 AC_PROG_CXX
52 # AC_PROG_LIBTOOL
53 # AC_CONFIG_MACRO_DIR([..])
54 AC_CONFIG_FILES([Makefile libcilkrts.spec])
55 AC_FUNC_ALLOCA
57 # Check whether the target supports protected visibility.
58 save_CFLAGS="$CFLAGS"
59 CFLAGS="$CFLAGS -Werror"
60 AC_TRY_COMPILE([void __attribute__((visibility("protected"))) foo(void) { }],
61                [], libcilkrts_cv_have_attribute_visibility=yes,
62                libcilkrts_cv_have_attribute_visibility=no)
63 CFLAGS="$save_CFLAGS"
64 if test $libcilkrts_cv_have_attribute_visibility = yes; then
65   AC_DEFINE(HAVE_ATTRIBUTE_VISIBILITY, 1,
66     [Define to 1 if the target supports __attribute__((visibility(...))).])
69 # Get target configury.
70 . ${srcdir}/configure.tgt
71 if test -n "$UNSUPPORTED"; then
72    AC_MSG_ERROR([Configuration ${target} is unsupported.])
75 if test "${multilib}" = "yes"; then
76   multilib_arg="--enable-multilib"
77 else
78   multilib_arg=
81 AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
82 AC_ARG_ENABLE([version-specific-runtime-libs],
83   AC_HELP_STRING([--enable-version-specific-runtime-libs],
84                  [Specify that runtime libraries should be installed in a compi
85 ler-specific directory]),
86   [case "$enableval" in
87     yes) enable_version_specific_runtime_libs=yes ;;
88     no)  enable_version_specific_runtime_libs=no ;;
89     *)   AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs
90 ]);;
91    esac],
92   [enable_version_specific_runtime_libs=no])
93 AC_MSG_RESULT($enable_version_specific_runtime_libs)
96 # Calculate toolexeclibdir
97 # Also toolexecdir, though it's only used in toolexeclibdir
98 case ${enable_version_specific_runtime_libs} in
99   yes)
100     # Need the gcc compiler version to know where to install libraries
101     # and header files if --enable-version-specific-runtime-libs option
102     # is selected.
103     toolexecdir='$(libdir)/gcc/$(target_alias)'
104     toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)'
105     ;;
106   no)
107     if test -n "$with_cross_host" &&
108        test x"$with_cross_host" != x"no"; then
109       # Install a library built with a cross compiler in tooldir, not libdir.
110       toolexecdir='$(exec_prefix)/$(target_alias)'
111       toolexeclibdir='$(toolexecdir)/lib'
112     else
113       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
114       toolexeclibdir='$(libdir)'
115     fi
116     multi_os_directory=`$CC -print-multi-os-directory`
117     case $multi_os_directory in
118       .) ;; # Avoid trailing /.
119       *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
120     esac
121     ;;
122 esac
124 # Set config_dir based on the target.  config_dir specifies where to get
125 # target-specific files.  The generic implementation is incomplete, but
126 # contains information on what's needed
127 case "${target}" in
129   x86_64-*-*)
130     config_dir="x86"
131     ;;
133   i?86-*-*)
134     config_dir="x86"
135     ;;
137   *)
138     config_dir="generic"
139     ;;
141 esac
142 AC_SUBST(config_dir)
144 # We have linker scripts for appropriate operating systems
145 linux_linker_script=no
146 case "${host}" in
147     *-*-linux*)
148         linux_linker_script=yes
149         ;;
150 esac
151 AM_CONDITIONAL(LINUX_LINKER_SCRIPT, test "$linux_linker_script" = "yes")
153 mac_linker_script=no
154 case "${host}" in
155     *-*-apple*)
156         mac_linker_script=yes
157         ;;
158 esac
159 AM_CONDITIONAL(MAC_LINKER_SCRIPT, test "$mac_linker_script" = "yes")
161 AC_LIBTOOL_DLOPEN
162 AM_PROG_LIBTOOL
163 AC_SUBST(toolexecdir)
164 AC_SUBST(toolexeclibdir)
166 AC_SUBST(lt_cv_dlopen_libs)
168 # Check to see if -pthread or -lpthread is needed.  Prefer the former.
169 # Note that the CILK_SELF_SPEC in gcc.c may force -pthread.
170 # In case the pthread.h system header is not found, this test will fail.
171 XCFLAGS=""
172 XLDFLAGS=""
173 CFLAGS="$CFLAGS -pthread"
174 AC_LINK_IFELSE(
175  [AC_LANG_PROGRAM(
176   [#include <pthread.h>
177    void *g(void *d) { return NULL; }],
178   [pthread_t t; pthread_create(&t,NULL,g,NULL);])],
179  [XCFLAGS=" -Wc,-pthread"],
180  [CFLAGS="$save_CFLAGS" LIBS="-lpthread $LIBS"
181   AC_LINK_IFELSE(
182    [AC_LANG_PROGRAM(
183     [#include <pthread.h>
184      void *g(void *d) { return NULL; }],
185     [pthread_t t; pthread_create(&t,NULL,g,NULL);])],
186    [],
187    [AC_MSG_ERROR([Pthreads are required to build libcilkrts])])])
189 # Check for pthread_{,attr_}[sg]etaffinity_np.
190 AC_LINK_IFELSE(
191  [AC_LANG_PROGRAM(
192   [#define _GNU_SOURCE
193    #include <pthread.h>],
194   [cpu_set_t cpuset;
195    pthread_attr_t attr;
196    pthread_getaffinity_np (pthread_self (), sizeof (cpu_set_t), &cpuset);
197    if (CPU_ISSET (0, &cpuset))
198      CPU_SET (1, &cpuset);
199    else
200      CPU_ZERO (&cpuset);
201    pthread_setaffinity_np (pthread_self (), sizeof (cpu_set_t), &cpuset);
202    pthread_attr_init (&attr);
203    pthread_attr_getaffinity_np (&attr, sizeof (cpu_set_t), &cpuset);
204    pthread_attr_setaffinity_np (&attr, sizeof (cpu_set_t), &cpuset);])],
205   AC_DEFINE(HAVE_PTHREAD_AFFINITY_NP, 1,
206 [       Define if pthread_{,attr_}{g,s}etaffinity_np is supported.]))
208 # Every c++ lib is linking by default with -nostdlib, which leads to the
209 # fact, that proper pthread library will not be given at link time. We have
210 # to hard-code that.
211 case "${target}" in
213   *android*)
214     XLDFLAGS="$XLDFLAGS -lc"
215      ;;
216   *)
217     XLDFLAGS="$XLDFLAGS -lpthread"
218     ;;
220 esac
222 AC_SUBST(XCFLAGS)
223 AC_SUBST(XLDFLAGS)
225 CFLAGS="$save_CFLAGS"
227 if test $enable_shared = yes; then
228   link_cilkrts="-lcilkrts %{static: $LIBS}"
229 else
230   link_cilkrts="-lcilkrts $LIBS"
232 AC_SUBST(link_cilkrts)
235 # Must be last
236 AC_OUTPUT