configure.ac 12 KB

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