1 # Process this file with autoconf to produce a configure script, like so:
2 # aclocal -I ../config && autoconf && autoheader && automake
5 #TODO: Update for OpenACC? But then also have to update copyright notices in
7 AC_INIT([GNU OpenMP Runtime Library], 1.0,,[libgomp])
8 AC_CONFIG_HEADER(config.h)
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],
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
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.],
30 AC_MSG_RESULT($enable_generated_files_in_srcdir)
31 AM_CONDITIONAL(GENINSRC, test "$enable_generated_files_in_srcdir" = yes)
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
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
74 # Need the gcc compiler version to know where to install libraries
75 # and header files if --enable-version-specific-runtime-libs option
77 toolexecdir='$(libdir)/gcc/$(target_alias)'
78 toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)'
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'
87 toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
88 toolexeclibdir='$(libdir)'
90 multi_os_directory=`$CC -print-multi-os-directory`
91 case $multi_os_directory in
92 .) ;; # Avoid trailing /.
93 *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
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],[])
109 m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
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)
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")
141 AC_SUBST(enable_shared)
142 AC_SUBST(enable_static)
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
157 set dummy $GFORTRAN; ac_word=$2
158 if test -x "$ac_word"; then
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.
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.
182 CFLAGS="$CFLAGS -pthread"
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"
192 [#include <pthread.h>
193 void *g(void *d) { return NULL; }],
194 [pthread_t t; pthread_create(&t,NULL,g,NULL);])],
196 [AC_MSG_ERROR([Pthreads are required to build libgomp])])])
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.
216 AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
217 Define if the POSIX Semaphores do not work on your system.)
223 # Check for pthread_{,attr_}[sg]etaffinity_np.
227 #include <pthread.h>],
230 pthread_getaffinity_np (pthread_self (), sizeof (cpu_set_t), &cpuset);
231 if (CPU_ISSET (0, &cpuset))
232 CPU_SET (1, &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,
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.
254 # See if we have emulated thread-local storage.
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)
283 CFLAGS="$save_CFLAGS"
286 if test ${multilib} = yes; then
287 multilib_arg="--enable-multilib"
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/=.*//'`
301 *-intelmic-* | *-intelmicemul-*)
302 tgt_name="intelmic" ;;
304 AC_MSG_ERROR([unknown offload target specified]) ;;
306 if test x"$offload_targets" = x; then
307 offload_targets=$tgt_name
309 offload_targets=$offload_targets,$tgt_name
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"
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"
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}"
333 link_gomp="-lgomp $LIBS"
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"
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
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
372 if test $OMP_NEST_LOCK_SIZE -gt 8 || test $OMP_NEST_LOCK_ALIGN -gt $OMP_NEST_LOCK_SIZE; then
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
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)