svn merge -r 217500:218679 svn+ssh://gcc.gnu.org/svn/gcc/trunk
[official-gcc.git] / libgomp / configure.ac
blob034c89365141055a8cdd98040a7e8b3c44b5e2ff
1 # Process this file with autoconf to produce a configure script, like so:
2 # aclocal -I ../config && autoconf && autoheader && automake
4 AC_PREREQ(2.64)
5 #TODO: Update for OpenACC?  But then also have to update copyright notices in
6 #all source files...
7 AC_INIT([GNU OpenMP Runtime Library], 1.0,,[libgomp])
8 AC_CONFIG_HEADER(config.h)
10 # -------
11 # Options
12 # -------
14 AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
15 LIBGOMP_ENABLE(version-specific-runtime-libs, no, ,
16    [Specify that runtime libraries should be installed in a compiler-specific directory],
17    permit yes|no)
18 AC_MSG_RESULT($enable_version_specific_runtime_libs)
20 # We would like our source tree to be readonly. However when releases or
21 # pre-releases are generated, the flex/bison generated files as well as the
22 # various formats of manuals need to be included along with the rest of the
23 # sources.  Therefore we have --enable-generated-files-in-srcdir to do 
24 # just that.
25 AC_MSG_CHECKING([for --enable-generated-files-in-srcdir])
26 LIBGOMP_ENABLE(generated-files-in-srcdir, no, ,
27    [put copies of generated files in source dir intended for creating source 
28     tarballs for users without texinfo bison or flex.],
29    permit yes|no)
30 AC_MSG_RESULT($enable_generated_files_in_srcdir)
31 AM_CONDITIONAL(GENINSRC, test "$enable_generated_files_in_srcdir" = yes)
34 # -------
35 # -------
37 # Gets build, host, target, *_vendor, *_cpu, *_os, etc.
39 # You will slowly go insane if you do not grok the following fact:  when
40 # building this library, the top-level /target/ becomes the library's /host/.
42 # configure then causes --target to default to --host, exactly like any
43 # other package using autoconf.  Therefore, 'target' and 'host' will
44 # always be the same.  This makes sense both for native and cross compilers
45 # just think about it for a little while.  :-)
47 # Also, if this library is being configured as part of a cross compiler, the
48 # top-level configure script will pass the "real" host as $with_cross_host.
50 # Do not delete or change the following two lines.  For why, see
51 # http://gcc.gnu.org/ml/libstdc++/2003-07/msg00451.html
52 AC_CANONICAL_SYSTEM
53 target_alias=${target_alias-$host_alias}
55 # Sets up automake.  Must come after AC_CANONICAL_SYSTEM.  Each of the
56 # following is magically included in AUTOMAKE_OPTIONS in each Makefile.am.
57 #  1.9.0:  minimum required version
58 #  no-define:  PACKAGE and VERSION will not be #define'd in config.h (a bunch
59 #              of other PACKAGE_* variables will, however, and there's nothing
60 #              we can do about that; they come from AC_INIT).
61 #  foreign:  we don't follow the normal rules for GNU packages (no COPYING
62 #            file in the top srcdir, etc, etc), so stop complaining.
63 #  no-dist:  we don't want 'dist' and related rules.
64 #  -Wall:  turns on all automake warnings...
65 #  -Wno-portability:  ...except this one, since GNU make is required.
66 #  -Wno-override: ... and this one, since we do want this in testsuite.
67 AM_INIT_AUTOMAKE([1.9.0 foreign no-dist -Wall -Wno-portability -Wno-override])
68 AM_ENABLE_MULTILIB(, ..)
70 # Calculate toolexeclibdir
71 # Also toolexecdir, though it's only used in toolexeclibdir
72 case ${enable_version_specific_runtime_libs} in
73   yes)
74     # Need the gcc compiler version to know where to install libraries
75     # and header files if --enable-version-specific-runtime-libs option
76     # is selected.
77     toolexecdir='$(libdir)/gcc/$(target_alias)'
78     toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)'
79     ;;
80   no)
81     if test -n "$with_cross_host" &&
82        test x"$with_cross_host" != x"no"; then
83       # Install a library built with a cross compiler in tooldir, not libdir.
84       toolexecdir='$(exec_prefix)/$(target_alias)'
85       toolexeclibdir='$(toolexecdir)/lib'
86     else
87       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
88       toolexeclibdir='$(libdir)'
89     fi
90     multi_os_directory=`$CC -print-multi-os-directory`
91     case $multi_os_directory in
92       .) ;; # Avoid trailing /.
93       *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
94     esac
95     ;;
96 esac
97 AC_SUBST(toolexecdir)
98 AC_SUBST(toolexeclibdir)
100 # Check the compiler.
101 # The same as in boehm-gc and libstdc++. Have to borrow it from there.
102 # We must force CC to /not/ be precious variables; otherwise
103 # the wrong, non-multilib-adjusted value will be used in multilibs.
104 # As a side effect, we have to subst CFLAGS ourselves.
106 m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
107 m4_define([_AC_ARG_VAR_PRECIOUS],[])
108 AC_PROG_CC
109 m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
111 AC_SUBST(CFLAGS)
113 # In order to override CFLAGS_FOR_TARGET, all of our special flags go
114 # in XCFLAGS.  But we need them in CFLAGS during configury.  So put them
115 # in both places for now and restore CFLAGS at the end of config.
116 save_CFLAGS="$CFLAGS"
118 # Add -Wall -Werror if we are using GCC.
119 if test "x$GCC" = "xyes"; then
120   XCFLAGS="$XCFLAGS -Wall -Werror"
123 # Find other programs we need.
124 AC_CHECK_TOOL(AR, ar)
125 AC_CHECK_TOOL(RANLIB, ranlib, ranlib-not-found-in-path-error)
126 AC_PATH_PROG(PERL, perl, perl-not-found-in-path-error)
127 AC_PROG_MAKE_SET
128 AC_PROG_INSTALL
130 # See if makeinfo has been installed and is modern enough
131 # that we can use it.
132 ACX_CHECK_PROG_VER([MAKEINFO], [makeinfo], [--version],
133                    [GNU texinfo.* \([0-9][0-9.]*\)],
134                    [4.[4-9]*|4.[1-9][0-9]*|[5-9]*|[1-9][0-9]*])
135 AM_CONDITIONAL(BUILD_INFO, test $gcc_cv_prog_makeinfo_modern = "yes")
138 # Configure libtool
139 AM_PROG_LIBTOOL
140 ACX_LT_HOST_FLAGS
141 AC_SUBST(enable_shared)
142 AC_SUBST(enable_static)
144 AM_MAINTAINER_MODE
146 # Create a spec file, so that compile/link tests don't fail
147 test -f libgfortran.spec || touch libgfortran.spec
148 FCFLAGS="$FCFLAGS -L."
150 # We need gfortran to compile parts of the library
151 # We can't use AC_PROG_FC because it expects a fully working gfortran.
152 #AC_PROG_FC(gfortran)
153 case `echo $GFORTRAN` in
154   -* | no* )
155     FC=no ;;
156   *)
157     set dummy $GFORTRAN; ac_word=$2
158     if test -x "$ac_word"; then
159       FC="$GFORTRAN"
160     else
161       FC=no
162     fi ;;
163 esac
164 AC_PROG_FC(gfortran)
165 FCFLAGS="$FCFLAGS -Wall -L../libgfortran"
167 # For libtool versioning info, format is CURRENT:REVISION:AGE
168 libtool_VERSION=1:0:0
169 AC_SUBST(libtool_VERSION)
171 # Check header files.
172 AC_STDC_HEADERS
173 AC_HEADER_TIME
174 ACX_HEADER_STRING
175 AC_CHECK_HEADERS(unistd.h semaphore.h sys/loadavg.h sys/time.h sys/time.h)
177 GCC_HEADER_STDINT(gstdint.h)
179 # Check to see if -pthread or -lpthread is needed.  Prefer the former.
180 # In case the pthread.h system header is not found, this test will fail.
181 XPCFLAGS=""
182 CFLAGS="$CFLAGS -pthread"
183 AC_LINK_IFELSE(
184  [AC_LANG_PROGRAM(
185   [#include <pthread.h>
186    void *g(void *d) { return NULL; }],
187   [pthread_t t; pthread_create(&t,NULL,g,NULL);])],
188  [XPCFLAGS=" -Wc,-pthread"],
189  [CFLAGS="$save_CFLAGS" LIBS="-lpthread $LIBS"
190   AC_LINK_IFELSE(
191    [AC_LANG_PROGRAM(
192     [#include <pthread.h>
193      void *g(void *d) { return NULL; }],
194     [pthread_t t; pthread_create(&t,NULL,g,NULL);])],
195    [],
196    [AC_MSG_ERROR([Pthreads are required to build libgomp])])])
198 plugin_support=yes
199 AC_CHECK_LIB(dl, dlsym, , [plugin_support=no])
200 if test x"$plugin_support" = xyes; then
201   AC_DEFINE(PLUGIN_SUPPORT, 1,
202     [Define if all infrastructure, needed for plugins, is supported.])
203 elif test "x${enable_offload_targets-no}" != xno; then
204   AC_MSG_ERROR([Can't support offloading without support for plugins])
207 AC_CONFIG_SUBDIRS([plugin])
209 # Check for functions needed.
210 AC_CHECK_FUNCS(getloadavg clock_gettime strtoull)
212 # Check for broken semaphore implementation on darwin.
213 # sem_init returns: sem_init error: Function not implemented.
214 case "$host" in
215   *-darwin*)
216     AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
217         Define if the POSIX Semaphores do not work on your system.)
218     ;;
219 esac
221 GCC_LINUX_FUTEX(:)
223 # Check for pthread_{,attr_}[sg]etaffinity_np.
224 AC_LINK_IFELSE(
225  [AC_LANG_PROGRAM(
226   [#define _GNU_SOURCE
227    #include <pthread.h>],
228   [cpu_set_t cpuset;
229    pthread_attr_t attr;
230    pthread_getaffinity_np (pthread_self (), sizeof (cpu_set_t), &cpuset);
231    if (CPU_ISSET (0, &cpuset))
232      CPU_SET (1, &cpuset);
233    else
234      CPU_ZERO (&cpuset);
235    pthread_setaffinity_np (pthread_self (), sizeof (cpu_set_t), &cpuset);
236    pthread_attr_init (&attr);
237    pthread_attr_getaffinity_np (&attr, sizeof (cpu_set_t), &cpuset);
238    pthread_attr_setaffinity_np (&attr, sizeof (cpu_set_t), &cpuset);])],
239   AC_DEFINE(HAVE_PTHREAD_AFFINITY_NP, 1,
240 [       Define if pthread_{,attr_}{g,s}etaffinity_np is supported.]))
242 # At least for glibc, clock_gettime is in librt.  But don't pull that
243 # in if it still doesn't give us the function we want.
244 if test $ac_cv_func_clock_gettime = no; then
245   AC_CHECK_LIB(rt, clock_gettime,
246     [LIBS="-lrt $LIBS"
247      AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
248                [Define to 1 if you have the `clock_gettime' function.])])
251 # See if we support thread-local storage.
252 GCC_CHECK_TLS
254 # See if we have emulated thread-local storage.
255 GCC_CHECK_EMUTLS
257 # See what sort of export controls are available.
258 LIBGOMP_CHECK_ATTRIBUTE_VISIBILITY
259 LIBGOMP_CHECK_ATTRIBUTE_DLLEXPORT
260 LIBGOMP_CHECK_ATTRIBUTE_ALIAS
261 LIBGOMP_ENABLE_SYMVERS
263 if test $enable_symvers = gnu; then
264   AC_DEFINE(LIBGOMP_GNU_SYMBOL_VERSIONING, 1,
265             [Define to 1 if GNU symbol versioning is used for libgomp.])
268 # Get target configury.
269 . ${srcdir}/configure.tgt
270 CFLAGS="$save_CFLAGS $XCFLAGS"
272 # Check for __sync_val_compare_and_swap, but only after the target has
273 # had a chance to set XCFLAGS.
274 LIBGOMP_CHECK_SYNC_BUILTINS
276 XCFLAGS="$XCFLAGS$XPCFLAGS"
278 AC_SUBST(config_path)
279 AC_SUBST(XCFLAGS)
280 AC_SUBST(XLDFLAGS)
282 # Cleanup and exit.
283 CFLAGS="$save_CFLAGS"
284 AC_CACHE_SAVE
286 if test ${multilib} = yes; then
287   multilib_arg="--enable-multilib"
288 else
289   multilib_arg=
292 # Get accel target and path to install tree of accel compiler
293 offload_additional_options=
294 offload_additional_lib_paths=
295 offload_targets=host_nonshm
296 if test x"$enable_offload_targets" != x; then
297   for tgt in `echo $enable_offload_targets | sed -e 's#,# #g'`; do
298     tgt_dir=`echo $tgt | grep '=' | sed 's/.*=//'`
299     tgt=`echo $tgt | sed 's/=.*//'`
300     case $tgt in
301       *-intelmic-* | *-intelmicemul-*)
302         tgt_name="intelmic" ;;
303       *)
304         AC_MSG_ERROR([unknown offload target specified]) ;;
305     esac
306     if test x"$offload_targets" = x; then
307       offload_targets=$tgt_name
308     else
309       offload_targets=$offload_targets,$tgt_name
310     fi
311     if test x"$tgt_dir" != x; then
312       offload_additional_options="$offload_additional_options -B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/bin"
313       offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/lib64:$tgt_dir/lib"
314     else
315       offload_additional_options="$offload_additional_options -B\$(libexecdir)/gcc/\$(target_alias)/\$(gcc_version) -B\$(bindir)"
316       offload_additional_lib_paths="$offload_additional_lib_paths:$toolexeclibdir"
317     fi
318   done
320 AC_DEFINE_UNQUOTED(OFFLOAD_TARGETS, "$offload_targets",
321   [Define to hold the list of target names suitable for offloading.])
322 AC_SUBST(offload_targets)
323 AC_SUBST(offload_additional_options)
324 AC_SUBST(offload_additional_lib_paths)
326 # Set up the set of libraries that we need to link against for libgomp.
327 # Note that the GOMP_SELF_SPEC in gcc.c may force -pthread,
328 # which will force linkage against -lpthread (or equivalent for the system).
329 # That's not 100% ideal, but about the best we can do easily.
330 if test $enable_shared = yes; then
331   link_gomp="-lgomp %{static: $LIBS}"
332 else
333   link_gomp="-lgomp $LIBS"
335 AC_SUBST(link_gomp)
337 AM_CONDITIONAL([USE_FORTRAN], [test "$ac_cv_fc_compiler_gnu" = yes])
339 # ??? 2006-01-24: Paulo committed to asking autoconf folk to document
340 # and export AC_COMPUTE_INT.  If that happens, then we'll need to remove
341 # the underscore here and update the PREREQ.  If it doesn't, then we'll
342 # need to copy this macro to our acinclude.m4.
343 save_CFLAGS="$CFLAGS"
344 for i in $config_path; do
345   if test -f $srcdir/config/$i/omp-lock.h; then
346     CFLAGS="$CFLAGS -include confdefs.h -include $srcdir/config/$i/omp-lock.h"
347     break
348   fi
349 done
351 _AC_COMPUTE_INT([sizeof (omp_lock_t)], [OMP_LOCK_SIZE],,
352   [AC_MSG_ERROR([unsupported system, cannot find sizeof (omp_lock_t)])])
353 _AC_COMPUTE_INT([__alignof (omp_lock_t)], [OMP_LOCK_ALIGN])
354 _AC_COMPUTE_INT([sizeof (omp_nest_lock_t)], [OMP_NEST_LOCK_SIZE])
355 _AC_COMPUTE_INT([__alignof (omp_nest_lock_t)], [OMP_NEST_LOCK_ALIGN])
356 _AC_COMPUTE_INT([sizeof (omp_lock_25_t)], [OMP_LOCK_25_SIZE],,
357   [AC_MSG_ERROR([unsupported system, cannot find sizeof (omp_lock_25_t)])])
358 _AC_COMPUTE_INT([__alignof (omp_lock_25_t)], [OMP_LOCK_25_ALIGN])
359 _AC_COMPUTE_INT([sizeof (omp_nest_lock_25_t)], [OMP_NEST_LOCK_25_SIZE])
360 _AC_COMPUTE_INT([__alignof (omp_nest_lock_25_t)], [OMP_NEST_LOCK_25_ALIGN])
362 # If the lock fits in an integer, then arrange for Fortran to use that
363 # integer.  If it doesn't, then arrange for Fortran to use a pointer.
364 # Except that we don't have a way at present to multi-lib the installed
365 # Fortran modules, so we assume 8 bytes for pointers, regardless of the
366 # actual target.
367 OMP_LOCK_KIND=$OMP_LOCK_SIZE
368 OMP_NEST_LOCK_KIND=$OMP_NEST_LOCK_SIZE
369 if test $OMP_LOCK_SIZE -gt 8 || test $OMP_LOCK_ALIGN -gt $OMP_LOCK_SIZE; then
370   OMP_LOCK_KIND=8
372 if test $OMP_NEST_LOCK_SIZE -gt 8 || test $OMP_NEST_LOCK_ALIGN -gt $OMP_NEST_LOCK_SIZE; then
373   OMP_NEST_LOCK_KIND=8
375 OMP_LOCK_25_KIND=$OMP_LOCK_25_SIZE
376 OMP_NEST_LOCK_25_KIND=$OMP_NEST_LOCK_25_SIZE
377 if test $OMP_LOCK_25_SIZE -gt 8 || test $OMP_LOCK_25_ALIGN -gt $OMP_LOCK_25_SIZE; then
378   OMP_LOCK_25_KIND=8
380 if test $OMP_NEST_LOCK_25_SIZE -gt 8 || test $OMP_NEST_LOCK_25_ALIGN -gt $OMP_NEST_LOCK_25_SIZE; then
381   OMP_NEST_LOCK_25_KIND=8
384 AC_SUBST(OMP_LOCK_SIZE)
385 AC_SUBST(OMP_LOCK_ALIGN)
386 AC_SUBST(OMP_NEST_LOCK_SIZE)
387 AC_SUBST(OMP_NEST_LOCK_ALIGN)
388 AC_SUBST(OMP_LOCK_KIND)
389 AC_SUBST(OMP_NEST_LOCK_KIND)
390 AC_SUBST(OMP_LOCK_25_SIZE)
391 AC_SUBST(OMP_LOCK_25_ALIGN)
392 AC_SUBST(OMP_NEST_LOCK_25_SIZE)
393 AC_SUBST(OMP_NEST_LOCK_25_ALIGN)
394 AC_SUBST(OMP_LOCK_25_KIND)
395 AC_SUBST(OMP_NEST_LOCK_25_KIND)
396 CFLAGS="$save_CFLAGS"
398 AC_CONFIG_FILES(omp.h omp_lib.h omp_lib.f90 libgomp_f.h)
399 AC_CONFIG_FILES(Makefile testsuite/Makefile)
400 AC_CONFIG_FILES(libgomp.spec)
401 AC_OUTPUT