1169695Skan# Process this file with autoconf to produce a configure script, like so: 2169695Skan# aclocal -I ../config && autoconf && autoheader && automake 3169695Skan 4169695SkanAC_PREREQ(2.59) 5169695SkanAC_INIT([GNU OpenMP Runtime Library], 1.0,,[libgomp]) 6169695SkanAC_CONFIG_HEADER(config.h) 7169695Skan 8169695Skan# ------- 9169695Skan# Options 10169695Skan# ------- 11169695Skan 12169695SkanAC_MSG_CHECKING([for --enable-version-specific-runtime-libs]) 13169695SkanLIBGOMP_ENABLE(version-specific-runtime-libs, no, , 14169695Skan [Specify that runtime libraries should be installed in a compiler-specific directory], 15169695Skan permit yes|no) 16169695SkanAC_MSG_RESULT($enable_version_specific_runtime_libs) 17169695Skan 18169695Skan# We would like our source tree to be readonly. However when releases or 19169695Skan# pre-releases are generated, the flex/bison generated files as well as the 20169695Skan# various formats of manuals need to be included along with the rest of the 21169695Skan# sources. Therefore we have --enable-generated-files-in-srcdir to do 22169695Skan# just that. 23169695SkanAC_MSG_CHECKING([for --enable-generated-files-in-srcdir]) 24169695SkanLIBGOMP_ENABLE(generated-files-in-srcdir, no, , 25169695Skan [put copies of generated files in source dir intended for creating source 26169695Skan tarballs for users without texinfo bison or flex.], 27169695Skan permit yes|no) 28169695SkanAC_MSG_RESULT($enable_generated_files_in_srcdir) 29169695SkanAM_CONDITIONAL(GENINSRC, test "$enable_generated_files_in_srcdir" = yes) 30169695Skan 31169695Skan 32169695Skan# ------- 33169695Skan# ------- 34169695Skan 35169695Skan# Gets build, host, target, *_vendor, *_cpu, *_os, etc. 36169695Skan# 37169695Skan# You will slowly go insane if you do not grok the following fact: when 38169695Skan# building this library, the top-level /target/ becomes the library's /host/. 39169695Skan# 40169695Skan# configure then causes --target to default to --host, exactly like any 41169695Skan# other package using autoconf. Therefore, 'target' and 'host' will 42169695Skan# always be the same. This makes sense both for native and cross compilers 43169695Skan# just think about it for a little while. :-) 44169695Skan# 45169695Skan# Also, if this library is being configured as part of a cross compiler, the 46169695Skan# top-level configure script will pass the "real" host as $with_cross_host. 47169695Skan# 48169695Skan# Do not delete or change the following two lines. For why, see 49169695Skan# http://gcc.gnu.org/ml/libstdc++/2003-07/msg00451.html 50169695SkanAC_CANONICAL_SYSTEM 51169695Skantarget_alias=${target_alias-$host_alias} 52169695Skan 53169695Skan# Sets up automake. Must come after AC_CANONICAL_SYSTEM. Each of the 54169695Skan# following is magically included in AUTOMAKE_OPTIONS in each Makefile.am. 55169695Skan# 1.9.0: minimum required version 56169695Skan# no-define: PACKAGE and VERSION will not be #define'd in config.h (a bunch 57169695Skan# of other PACKAGE_* variables will, however, and there's nothing 58169695Skan# we can do about that; they come from AC_INIT). 59169695Skan# foreign: we don't follow the normal rules for GNU packages (no COPYING 60169695Skan# file in the top srcdir, etc, etc), so stop complaining. 61282152Spfg# no-dist: we don't want 'dist' and related rules. 62169695Skan# -Wall: turns on all automake warnings... 63169695Skan# -Wno-portability: ...except this one, since GNU make is required. 64169695Skan# -Wno-override: ... and this one, since we do want this in testsuite. 65282152SpfgAM_INIT_AUTOMAKE([1.9.0 foreign no-dist -Wall -Wno-portability -Wno-override]) 66169695SkanAM_ENABLE_MULTILIB(, ..) 67169695Skan 68169695Skan# Calculate toolexeclibdir 69169695Skan# Also toolexecdir, though it's only used in toolexeclibdir 70169695Skancase ${enable_version_specific_runtime_libs} in 71169695Skan yes) 72169695Skan # Need the gcc compiler version to know where to install libraries 73169695Skan # and header files if --enable-version-specific-runtime-libs option 74169695Skan # is selected. 75169695Skan toolexecdir='$(libdir)/gcc/$(target_alias)' 76169695Skan toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)' 77169695Skan ;; 78169695Skan no) 79169695Skan if test -n "$with_cross_host" && 80169695Skan test x"$with_cross_host" != x"no"; then 81169695Skan # Install a library built with a cross compiler in tooldir, not libdir. 82169695Skan toolexecdir='$(exec_prefix)/$(target_alias)' 83169695Skan toolexeclibdir='$(toolexecdir)/lib' 84169695Skan else 85169695Skan toolexecdir='$(libdir)/gcc-lib/$(target_alias)' 86169695Skan toolexeclibdir='$(libdir)' 87169695Skan fi 88169695Skan multi_os_directory=`$CC -print-multi-os-directory` 89169695Skan case $multi_os_directory in 90169695Skan .) ;; # Avoid trailing /. 91169695Skan *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;; 92169695Skan esac 93169695Skan ;; 94169695Skanesac 95169695SkanAC_SUBST(toolexecdir) 96169695SkanAC_SUBST(toolexeclibdir) 97169695Skan 98169695Skan# Check the compiler. 99169695Skan# The same as in boehm-gc and libstdc++. Have to borrow it from there. 100169695Skan# We must force CC to /not/ be precious variables; otherwise 101169695Skan# the wrong, non-multilib-adjusted value will be used in multilibs. 102169695Skan# As a side effect, we have to subst CFLAGS ourselves. 103169695Skan 104169695Skanm4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS]) 105169695Skanm4_define([_AC_ARG_VAR_PRECIOUS],[]) 106169695SkanAC_PROG_CC 107169695Skanm4_rename([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS]) 108169695Skan 109169695SkanAC_SUBST(CFLAGS) 110169695Skan 111169695Skan# In order to override CFLAGS_FOR_TARGET, all of our special flags go 112169695Skan# in XCFLAGS. But we need them in CFLAGS during configury. So put them 113169695Skan# in both places for now and restore CFLAGS at the end of config. 114169695Skansave_CFLAGS="$CFLAGS" 115169695Skan 116169695Skan# Add -Wall -Werror if we are using GCC. 117169695Skanif test "x$GCC" = "xyes"; then 118169695Skan XCFLAGS="$XCFLAGS -Wall -Werror" 119169695Skanfi 120169695Skan 121169695Skan# Find other programs we need. 122169695SkanAC_CHECK_TOOL(AR, ar) 123169695SkanAC_CHECK_TOOL(RANLIB, ranlib, ranlib-not-found-in-path-error) 124169695SkanAC_PATH_PROG(PERL, perl, perl-not-found-in-path-error) 125169695SkanAC_PROG_MAKE_SET 126169695SkanAC_PROG_INSTALL 127169695Skan 128169695Skan# See if makeinfo has been installed and is modern enough 129169695Skan# that we can use it. 130169695SkanACX_CHECK_PROG_VER([MAKEINFO], [makeinfo], [--version], 131169695Skan [GNU texinfo.* \([0-9][0-9.]*\)], 132282152Spfg [4.[4-9]*|4.[1-9][0-9]*|[5-9]*|[1-9][0-9]*]) 133169695SkanAM_CONDITIONAL(BUILD_INFO, test $gcc_cv_prog_makeinfo_modern = "yes") 134169695Skan 135169695Skan 136169695Skan# Configure libtool 137169695SkanAM_PROG_LIBTOOL 138169695SkanAC_SUBST(enable_shared) 139169695SkanAC_SUBST(enable_static) 140169695Skan 141169695SkanAM_MAINTAINER_MODE 142169695Skan 143169695Skan# We need gfortran to compile parts of the library 144169695Skan# We can't use AC_PROG_FC because it expects a fully working gfortran. 145169695Skan#AC_PROG_FC(gfortran) 146169695SkanFC="$GFORTRAN" 147169695SkanAC_PROG_FC(gfortran) 148169695SkanFCFLAGS="$FCFLAGS -Wall" 149169695Skan 150169695Skan# For libtool versioning info, format is CURRENT:REVISION:AGE 151169695Skanlibtool_VERSION=1:0:0 152169695SkanAC_SUBST(libtool_VERSION) 153169695Skan 154169695Skan# Check header files. 155169695SkanAC_STDC_HEADERS 156169695SkanAC_HEADER_TIME 157282201SpfgAC_CHECK_HEADERS(unistd.h semaphore.h sys/loadavg.h sys/sysctl.h sys/time.h) 158169695Skan 159169695SkanGCC_HEADER_STDINT(gstdint.h) 160169695Skan 161169695Skan# Check to see if -pthread or -lpthread is needed. Prefer the former. 162169695Skan# In case the pthread.h system header is not found, this test will fail. 163169695SkanXPCFLAGS="" 164169695SkanCFLAGS="$CFLAGS -pthread" 165169695SkanAC_LINK_IFELSE( 166169695Skan [AC_LANG_PROGRAM( 167169695Skan [#include <pthread.h> 168169695Skan void *g(void *d) { return NULL; }], 169169695Skan [pthread_t t; pthread_create(&t,NULL,g,NULL);])], 170169695Skan [XPCFLAGS=" -Wc,-pthread"], 171169695Skan [CFLAGS="$save_CFLAGS" LIBS="-lpthread $LIBS" 172169695Skan AC_LINK_IFELSE( 173169695Skan [AC_LANG_PROGRAM( 174169695Skan [#include <pthread.h> 175169695Skan void *g(void *d) { return NULL; }], 176169695Skan [pthread_t t; pthread_create(&t,NULL,g,NULL);])], 177169695Skan [], 178169695Skan [AC_MSG_ERROR([Pthreads are required to build libgomp])])]) 179169695Skan 180169695Skan# Check for functions needed. 181169695SkanAC_CHECK_FUNCS(getloadavg clock_gettime) 182169695Skan 183169695Skan# Check for broken semaphore implementation on darwin. 184169695Skan# sem_init returns: sem_init error: Function not implemented. 185169695Skancase "$host" in 186169695Skan *-darwin*) 187169695Skan AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1, 188169695Skan Define if the POSIX Semaphores do not work on your system.) 189169695Skan ;; 190169695Skanesac 191169695Skan 192282152SpfgGCC_LINUX_FUTEX(:) 193282152Spfg 194282115Spfg# Check for pthread_{,attr_}[sg]etaffinity_np. 195282115SpfgAC_LINK_IFELSE( 196282115Spfg [AC_LANG_PROGRAM( 197282115Spfg [#define _GNU_SOURCE 198282115Spfg #include <pthread.h>], 199282115Spfg [cpu_set_t cpuset; 200282115Spfg pthread_attr_t attr; 201282115Spfg pthread_getaffinity_np (pthread_self (), sizeof (cpu_set_t), &cpuset); 202282115Spfg if (CPU_ISSET (0, &cpuset)) 203282115Spfg CPU_SET (1, &cpuset); 204282115Spfg else 205282115Spfg CPU_ZERO (&cpuset); 206282115Spfg pthread_setaffinity_np (pthread_self (), sizeof (cpu_set_t), &cpuset); 207282115Spfg pthread_attr_init (&attr); 208282115Spfg pthread_attr_getaffinity_np (&attr, sizeof (cpu_set_t), &cpuset); 209282115Spfg pthread_attr_setaffinity_np (&attr, sizeof (cpu_set_t), &cpuset);])], 210282115Spfg AC_DEFINE(HAVE_PTHREAD_AFFINITY_NP, 1, 211282115Spfg[ Define if pthread_{,attr_}{g,s}etaffinity_np is supported.])) 212282115Spfg 213169695Skan# At least for glibc, clock_gettime is in librt. But don't pull that 214169695Skan# in if it still doesn't give us the function we want. 215169695Skanif test $ac_cv_func_clock_gettime = no; then 216169695Skan AC_CHECK_LIB(rt, clock_gettime, 217169695Skan [LIBS="-lrt $LIBS" 218169695Skan AC_DEFINE(HAVE_CLOCK_GETTIME, 1, 219169695Skan [Define to 1 if you have the `clock_gettime' function.])]) 220169695Skanfi 221169695Skan 222169695Skan# See if we support thread-local storage. 223169695SkanGCC_CHECK_TLS 224169695Skan 225169695Skan# See what sort of export controls are availible. 226169695SkanLIBGOMP_CHECK_ATTRIBUTE_VISIBILITY 227169695SkanLIBGOMP_CHECK_ATTRIBUTE_DLLEXPORT 228169695SkanLIBGOMP_CHECK_ATTRIBUTE_ALIAS 229169695SkanLIBGOMP_ENABLE_SYMVERS 230169695Skan 231169695Skan# Get target configury. 232169695Skan. ${srcdir}/configure.tgt 233169695SkanCFLAGS="$save_CFLAGS $XCFLAGS" 234169695Skan 235169695Skan# Check for __sync_val_compare_and_swap, but only after the target has 236169695Skan# had a chance to set XCFLAGS. 237169695SkanLIBGOMP_CHECK_SYNC_BUILTINS 238169695Skan 239169695SkanXCFLAGS="$XCFLAGS$XPCFLAGS" 240169695Skan 241169695SkanAC_SUBST(config_path) 242169695SkanAC_SUBST(XCFLAGS) 243169695SkanAC_SUBST(XLDFLAGS) 244169695Skan 245169695Skan# Cleanup and exit. 246169695SkanCFLAGS="$save_CFLAGS" 247169695SkanAC_CACHE_SAVE 248169695Skan 249169695Skanif test ${multilib} = yes; then 250169695Skan multilib_arg="--enable-multilib" 251169695Skanelse 252169695Skan multilib_arg= 253169695Skanfi 254169695Skan 255169695Skan# Set up the set of libraries that we need to link against for libgomp. 256169695Skan# Note that the GOMP_SELF_SPEC in gcc.c will force -pthread for -fopenmp, 257169695Skan# which will force linkage against -lpthread (or equivalent for the system). 258169695Skan# That's not 100% ideal, but about the best we can do easily. 259169695Skanif test $enable_shared = yes; then 260169695Skan link_gomp="-lgomp %{static: $LIBS}" 261169695Skanelse 262169695Skan link_gomp="-lgomp $LIBS" 263169695Skanfi 264169695SkanAC_SUBST(link_gomp) 265169695Skan 266169695SkanAM_CONDITIONAL([USE_FORTRAN], [test "$ac_cv_fc_compiler_gnu" = yes]) 267169695Skan 268169695Skan# ??? 2006-01-24: Paulo committed to asking autoconf folk to document 269169695Skan# and export AC_COMPUTE_INT. If that happens, then we'll need to remove 270169695Skan# the underscore here and update the PREREQ. If it doesn't, then we'll 271169695Skan# need to copy this macro to our acinclude.m4. 272169695Skansave_CFLAGS="$CFLAGS" 273169695Skanfor i in $config_path; do 274169695Skan if test -f $srcdir/config/$i/omp-lock.h; then 275169695Skan CFLAGS="$CFLAGS -include $srcdir/config/$i/omp-lock.h" 276169695Skan break 277169695Skan fi 278169695Skandone 279169695Skan 280169695Skan_AC_COMPUTE_INT([sizeof (omp_lock_t)], [OMP_LOCK_SIZE],, 281169695Skan [AC_MSG_ERROR([unsupported system, cannot find sizeof (omp_lock_t)])]) 282169695Skan_AC_COMPUTE_INT([__alignof (omp_lock_t)], [OMP_LOCK_ALIGN]) 283169695Skan_AC_COMPUTE_INT([sizeof (omp_nest_lock_t)], [OMP_NEST_LOCK_SIZE]) 284169695Skan_AC_COMPUTE_INT([__alignof (omp_nest_lock_t)], [OMP_NEST_LOCK_ALIGN]) 285169695Skan 286169695Skan# If the lock fits in an integer, then arrange for Fortran to use that 287169695Skan# integer. If it doesn't, then arrange for Fortran to use a pointer. 288169695Skan# Except that we don't have a way at present to multi-lib the installed 289169695Skan# Fortran modules, so we assume 8 bytes for pointers, regardless of the 290169695Skan# actual target. 291169695SkanOMP_LOCK_KIND=$OMP_LOCK_SIZE 292169695SkanOMP_NEST_LOCK_KIND=$OMP_NEST_LOCK_SIZE 293169695Skanif test $OMP_LOCK_SIZE -gt 8 || test $OMP_LOCK_ALIGN -gt $OMP_LOCK_SIZE; then 294169695Skan OMP_LOCK_KIND=8 295169695Skanfi 296169695Skanif test $OMP_NEST_LOCK_SIZE -gt 8 || test $OMP_NEST_LOCK_ALIGN -gt $OMP_NEST_LOCK_SIZE; then 297169695Skan OMP_NEST_LOCK_KIND=8 298169695Skanfi 299169695Skan 300169695SkanAC_SUBST(OMP_LOCK_SIZE) 301169695SkanAC_SUBST(OMP_LOCK_ALIGN) 302169695SkanAC_SUBST(OMP_NEST_LOCK_SIZE) 303169695SkanAC_SUBST(OMP_NEST_LOCK_ALIGN) 304169695SkanAC_SUBST(OMP_LOCK_KIND) 305169695SkanAC_SUBST(OMP_NEST_LOCK_KIND) 306169695SkanCFLAGS="$save_CFLAGS" 307169695Skan 308169695SkanAC_CONFIG_FILES(omp.h omp_lib.h omp_lib.f90 libgomp_f.h) 309169695SkanAC_CONFIG_FILES(Makefile testsuite/Makefile libgomp.spec) 310169695SkanAC_OUTPUT 311