configure.ac 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. # Process this file with autoconf to produce a configure script, like so:
  2. # aclocal -I ../config && autoconf && autoheader && automake
  3. AC_INIT([GNU Offloading and Multi Processing Runtime Library], 1.0,,[libgomp])
  4. AC_CONFIG_HEADER(config.h)
  5. # -------
  6. # Options
  7. # -------
  8. AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
  9. LIBGOMP_ENABLE(version-specific-runtime-libs, no, ,
  10. [Specify that runtime libraries should be installed in a compiler-specific directory],
  11. permit yes|no)
  12. AC_MSG_RESULT($enable_version_specific_runtime_libs)
  13. # We would like our source tree to be readonly. However when releases or
  14. # pre-releases are generated, the flex/bison generated files as well as the
  15. # various formats of manuals need to be included along with the rest of the
  16. # sources. Therefore we have --enable-generated-files-in-srcdir to do
  17. # just that.
  18. AC_MSG_CHECKING([for --enable-generated-files-in-srcdir])
  19. LIBGOMP_ENABLE(generated-files-in-srcdir, no, ,
  20. [put copies of generated files in source dir intended for creating source
  21. tarballs for users without texinfo bison or flex.],
  22. permit yes|no)
  23. AC_MSG_RESULT($enable_generated_files_in_srcdir)
  24. AM_CONDITIONAL(GENINSRC, test "$enable_generated_files_in_srcdir" = yes)
  25. # -------
  26. # -------
  27. # Gets build, host, target, *_vendor, *_cpu, *_os, etc.
  28. #
  29. # You will slowly go insane if you do not grok the following fact: when
  30. # building this library, the top-level /target/ becomes the library's /host/.
  31. #
  32. # configure then causes --target to default to --host, exactly like any
  33. # other package using autoconf. Therefore, 'target' and 'host' will
  34. # always be the same. This makes sense both for native and cross compilers
  35. # just think about it for a little while. :-)
  36. #
  37. # Also, if this library is being configured as part of a cross compiler, the
  38. # top-level configure script will pass the "real" host as $with_cross_host.
  39. #
  40. # Do not delete or change the following two lines. For why, see
  41. # http://gcc.gnu.org/ml/libstdc++/2003-07/msg00451.html
  42. AC_CANONICAL_SYSTEM
  43. target_alias=${target_alias-$host_alias}
  44. # Sets up automake. Must come after AC_CANONICAL_SYSTEM. Each of the
  45. # following is magically included in AUTOMAKE_OPTIONS in each Makefile.am.
  46. # 1.9.0: minimum required version
  47. # no-define: PACKAGE and VERSION will not be #define'd in config.h (a bunch
  48. # of other PACKAGE_* variables will, however, and there's nothing
  49. # we can do about that; they come from AC_INIT).
  50. # foreign: we don't follow the normal rules for GNU packages (no COPYING
  51. # file in the top srcdir, etc, etc), so stop complaining.
  52. # no-dist: we don't want 'dist' and related rules.
  53. # -Wall: turns on all automake warnings...
  54. # -Wno-portability: ...except this one, since GNU make is required.
  55. # -Wno-override: ... and this one, since we do want this in testsuite.
  56. AM_INIT_AUTOMAKE([1.9.0 foreign no-dist -Wall -Wno-portability -Wno-override])
  57. AM_ENABLE_MULTILIB(, ..)
  58. GCC_WITH_TOOLEXECLIBDIR
  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. case ${with_toolexeclibdir} in
  75. no)
  76. toolexeclibdir='$(toolexecdir)/lib'
  77. ;;
  78. *)
  79. toolexeclibdir=${with_toolexeclibdir}
  80. ;;
  81. esac
  82. else
  83. toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
  84. toolexeclibdir='$(libdir)'
  85. fi
  86. multi_os_directory=`$CC -print-multi-os-directory`
  87. case $multi_os_directory in
  88. .) ;; # Avoid trailing /.
  89. *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
  90. esac
  91. ;;
  92. esac
  93. AC_SUBST(toolexecdir)
  94. AC_SUBST(toolexeclibdir)
  95. # Check the compiler.
  96. # The same as in boehm-gc and libstdc++. Have to borrow it from there.
  97. # We must force CC to /not/ be precious variables; otherwise
  98. # the wrong, non-multilib-adjusted value will be used in multilibs.
  99. # As a side effect, we have to subst CFLAGS ourselves.
  100. m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
  101. m4_define([_AC_ARG_VAR_PRECIOUS],[])
  102. AC_PROG_CC
  103. m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
  104. AC_SUBST(CFLAGS)
  105. # In order to override CFLAGS_FOR_TARGET, all of our special flags go
  106. # in XCFLAGS. But we need them in CFLAGS during configury. So put them
  107. # in both places for now and restore CFLAGS at the end of config.
  108. save_CFLAGS="$CFLAGS"
  109. AC_ARG_ENABLE([werror],
  110. [AS_HELP_STRING([--disable-werror], [disable building with -Werror])])
  111. # Add -Wall -Werror if we are using GCC.
  112. AS_IF([test "x$GCC" = "xyes"],
  113. [XCFLAGS="$XCFLAGS -Wall"])
  114. AS_IF([test "x$enable_werror" != "xno" && test "x$GCC" = "xyes"],
  115. [XCFLAGS="$XCFLAGS -Werror"])
  116. # Find other programs we need.
  117. AC_CHECK_TOOL(AR, ar)
  118. AC_CHECK_TOOL(RANLIB, ranlib, ranlib-not-found-in-path-error)
  119. AC_PATH_PROG(PERL, perl, perl-not-found-in-path-error)
  120. AC_PROG_MAKE_SET
  121. AC_PROG_INSTALL
  122. # See if makeinfo has been installed and is modern enough
  123. # that we can use it.
  124. ACX_CHECK_PROG_VER([MAKEINFO], [makeinfo], [--version],
  125. [GNU texinfo.* \([0-9][0-9.]*\)],
  126. [4.[4-9]*|4.[1-9][0-9]*|[5-9]*|[1-9][0-9]*])
  127. AM_CONDITIONAL(BUILD_INFO, test $gcc_cv_prog_makeinfo_modern = "yes")
  128. # Configure libtool
  129. AM_PROG_LIBTOOL
  130. ACX_LT_HOST_FLAGS
  131. AC_SUBST(enable_shared)
  132. AC_SUBST(enable_static)
  133. AM_MAINTAINER_MODE
  134. # Create a spec file, so that compile/link tests don't fail
  135. test -f libgfortran.spec || touch libgfortran.spec
  136. FCFLAGS="$FCFLAGS -L."
  137. # We need gfortran to compile parts of the library
  138. # We can't use AC_PROG_FC because it expects a fully working gfortran.
  139. #AC_PROG_FC(gfortran)
  140. case `echo $GFORTRAN` in
  141. -* | no* )
  142. FC=no ;;
  143. *)
  144. set dummy $GFORTRAN; ac_word=$2
  145. if test -x "$ac_word"; then
  146. FC="$GFORTRAN"
  147. else
  148. FC=no
  149. fi ;;
  150. esac
  151. AC_PROG_FC(gfortran)
  152. FCFLAGS="$FCFLAGS -Wall -L../libgfortran"
  153. # For libtool versioning info, format is CURRENT:REVISION:AGE
  154. libtool_VERSION=1:0:0
  155. AC_SUBST(libtool_VERSION)
  156. # Check header files.
  157. AC_STDC_HEADERS
  158. AC_HEADER_TIME
  159. ACX_HEADER_STRING
  160. AC_CHECK_HEADERS(pthread.h unistd.h semaphore.h sys/loadavg.h sys/sysctl.h sys/time.h)
  161. XPCFLAGS=""
  162. case "$host" in
  163. *-*-rtems*)
  164. # RTEMS supports Pthreads, but the library is not available at GCC build time.
  165. ;;
  166. nvptx*-*-* | amdgcn*-*-*)
  167. # NVPTX does not support Pthreads, has its own code replacement.
  168. libgomp_use_pthreads=no
  169. # NVPTX is an accelerator-only target
  170. libgomp_offloaded_only=yes
  171. ;;
  172. *)
  173. # Check to see if -pthread or -lpthread is needed. Prefer the former.
  174. # In case the pthread.h system header is not found, this test will fail.
  175. CFLAGS="$CFLAGS -pthread"
  176. AC_LINK_IFELSE(
  177. [AC_LANG_PROGRAM(
  178. [#include <pthread.h>
  179. void *g(void *d) { return NULL; }],
  180. [pthread_t t; pthread_create(&t,NULL,g,NULL);])],
  181. [XPCFLAGS=" -Wc,-pthread"],
  182. [CFLAGS="$save_CFLAGS" LIBS="-lpthread $LIBS"
  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. [],
  189. [AC_MSG_ERROR([Pthreads are required to build libgomp])])])
  190. esac
  191. if test x$libgomp_use_pthreads != xno; then
  192. AC_DEFINE(LIBGOMP_USE_PTHREADS, 1,
  193. [Define to 1 if libgomp should use POSIX threads.])
  194. fi
  195. if test x$libgomp_offloaded_only = xyes; then
  196. AC_DEFINE(LIBGOMP_OFFLOADED_ONLY, 1,
  197. [Define to 1 if building libgomp for an accelerator-only target.])
  198. fi
  199. if test "x$enable_offload_defaulted" = xyes; then
  200. AC_DEFINE(OFFLOAD_DEFAULTED, 1,
  201. [Define to 1 to if -foffload is defaulted])
  202. fi
  203. AC_CHECK_SIZEOF([void *])
  204. m4_include([plugin/configfrag.ac])
  205. # Check for functions needed.
  206. AC_CHECK_FUNCS(getloadavg clock_gettime strtoull)
  207. AC_CHECK_FUNCS(aligned_alloc posix_memalign memalign _aligned_malloc)
  208. # Check for broken semaphore implementation on darwin.
  209. # sem_init returns: sem_init error: Function not implemented.
  210. case "$host" in
  211. *-darwin*)
  212. AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
  213. Define if the POSIX Semaphores do not work on your system.)
  214. ;;
  215. esac
  216. # RTEMS specific checks
  217. case "$host" in
  218. *-*-rtems*)
  219. AC_CHECK_TYPES([struct _Mutex_Control],[],[],[#include <sys/lock.h>])
  220. ;;
  221. esac
  222. 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.]))
  241. # At least for glibc, clock_gettime is in librt. But don't pull that
  242. # in if it still doesn't give us the function we want.
  243. if test $ac_cv_func_clock_gettime = no; then
  244. AC_CHECK_LIB(rt, clock_gettime,
  245. [LIBS="-lrt $LIBS"
  246. AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
  247. [Define to 1 if you have the `clock_gettime' function.])])
  248. fi
  249. # Check for uname.
  250. AC_COMPILE_IFELSE(
  251. [AC_LANG_PROGRAM(
  252. [#include <string.h>
  253. #include <stdlib.h>
  254. #include <sys/utsname.h>],
  255. [struct utsname buf;
  256. volatile size_t len = 0;
  257. if (!uname (buf))
  258. len = strlen (buf.nodename);])],
  259. AC_DEFINE(HAVE_UNAME, 1,
  260. [ Define if uname is supported and struct utsname has nodename field.]))
  261. # Check for gethostname.
  262. AC_COMPILE_IFELSE(
  263. [AC_LANG_PROGRAM(
  264. [#include <unistd.h>],
  265. [
  266. changequote(,)dnl
  267. char buf[256];
  268. if (gethostname (buf, sizeof (buf) - 1) == 0)
  269. buf[255] = '\0';
  270. changequote([,])dnl
  271. ])],
  272. AC_DEFINE(HAVE_GETHOSTNAME, 1,
  273. [ Define if gethostname is supported.]))
  274. # Check for getpid.
  275. AC_COMPILE_IFELSE(
  276. [AC_LANG_PROGRAM(
  277. [#include <unistd.h>],
  278. [int pid = getpid ();])],
  279. AC_DEFINE(HAVE_GETPID, 1,
  280. [ Define if getpid is supported.]))
  281. # See if we support thread-local storage.
  282. GCC_CHECK_TLS
  283. # See if we have emulated thread-local storage.
  284. GCC_CHECK_EMUTLS
  285. # See what sort of export controls are available.
  286. LIBGOMP_CHECK_ATTRIBUTE_VISIBILITY
  287. LIBGOMP_CHECK_ATTRIBUTE_DLLEXPORT
  288. LIBGOMP_CHECK_ATTRIBUTE_ALIAS
  289. LIBGOMP_ENABLE_SYMVERS
  290. if test $enable_symvers = gnu; then
  291. AC_DEFINE(LIBGOMP_GNU_SYMBOL_VERSIONING, 1,
  292. [Define to 1 if GNU symbol versioning is used for libgomp.])
  293. fi
  294. # Determine cpu count to limit testsuite parallelism.
  295. AX_COUNT_CPUS
  296. AC_SUBST(CPU_COUNT)
  297. # Get target configury.
  298. . ${srcdir}/configure.tgt
  299. CFLAGS="$save_CFLAGS $XCFLAGS"
  300. # Check for __sync_val_compare_and_swap, but only after the target has
  301. # had a chance to set XCFLAGS.
  302. LIBGOMP_CHECK_SYNC_BUILTINS
  303. XCFLAGS="$XCFLAGS$XPCFLAGS"
  304. # Add CET specific flags if CET is enabled
  305. GCC_CET_FLAGS(CET_FLAGS)
  306. XCFLAGS="$XCFLAGS $CET_FLAGS"
  307. FCFLAGS="$FCFLAGS $CET_FLAGS"
  308. AC_SUBST(config_path)
  309. AC_SUBST(XCFLAGS)
  310. AC_SUBST(XLDFLAGS)
  311. # Conditionalize the makefile for this target machine.
  312. tmake_file_=
  313. for f in ${tmake_file}
  314. do
  315. if test -f ${srcdir}/config/$f
  316. then
  317. tmake_file_="${tmake_file_} \$(srcdir)/config/$f"
  318. fi
  319. done
  320. tmake_file="${tmake_file_}"
  321. AC_SUBST(tmake_file)
  322. # Cleanup and exit.
  323. CFLAGS="$save_CFLAGS"
  324. AC_CACHE_SAVE
  325. if test ${multilib} = yes; then
  326. multilib_arg="--enable-multilib"
  327. else
  328. multilib_arg=
  329. fi
  330. # Set up the set of libraries that we need to link against for libgomp.
  331. # Note that the GOMP_SELF_SPEC in gcc.c may force -pthread,
  332. # which will force linkage against -lpthread (or equivalent for the system).
  333. # That's not 100% ideal, but about the best we can do easily.
  334. if test $enable_shared = yes; then
  335. link_gomp="-lgomp %{static: $LIBS}"
  336. else
  337. link_gomp="-lgomp $LIBS"
  338. fi
  339. AC_SUBST(link_gomp)
  340. AM_CONDITIONAL([USE_FORTRAN], [test "$ac_cv_fc_compiler_gnu" = yes])
  341. # ??? 2006-01-24: Paulo committed to asking autoconf folk to document
  342. # and export AC_COMPUTE_INT. If that happens, then we'll need to remove
  343. # the underscore here and update the PREREQ. If it doesn't, then we'll
  344. # need to copy this macro to our acinclude.m4.
  345. save_CFLAGS="$CFLAGS"
  346. for i in $config_path; do
  347. if test -f $srcdir/config/$i/omp-lock.h; then
  348. CFLAGS="$CFLAGS -include confdefs.h -include $srcdir/config/$i/omp-lock.h"
  349. break
  350. fi
  351. done
  352. _AC_COMPUTE_INT([sizeof (__INTPTR_TYPE__)], [INTPTR_T_KIND])
  353. _AC_COMPUTE_INT([sizeof (__int128)], [OMP_INT128_SIZE],,[OMP_INT128_SIZE=0])
  354. _AC_COMPUTE_INT([2*sizeof (__INTPTR_TYPE__)], [OMP_DEPEND_KIND],,
  355. [OMP_DEPEND_KIND=0])
  356. _AC_COMPUTE_INT([sizeof (omp_lock_t)], [OMP_LOCK_SIZE],,
  357. [AC_MSG_ERROR([unsupported system, cannot find sizeof (omp_lock_t)])])
  358. _AC_COMPUTE_INT([__alignof (omp_lock_t)], [OMP_LOCK_ALIGN])
  359. _AC_COMPUTE_INT([sizeof (omp_nest_lock_t)], [OMP_NEST_LOCK_SIZE])
  360. _AC_COMPUTE_INT([__alignof (omp_nest_lock_t)], [OMP_NEST_LOCK_ALIGN])
  361. _AC_COMPUTE_INT([sizeof (omp_lock_25_t)], [OMP_LOCK_25_SIZE],,
  362. [AC_MSG_ERROR([unsupported system, cannot find sizeof (omp_lock_25_t)])])
  363. _AC_COMPUTE_INT([__alignof (omp_lock_25_t)], [OMP_LOCK_25_ALIGN])
  364. _AC_COMPUTE_INT([sizeof (omp_nest_lock_25_t)], [OMP_NEST_LOCK_25_SIZE])
  365. _AC_COMPUTE_INT([__alignof (omp_nest_lock_25_t)], [OMP_NEST_LOCK_25_ALIGN])
  366. # If the lock fits in an integer, then arrange for Fortran to use that
  367. # integer. If it doesn't, then arrange for Fortran to use a pointer.
  368. # Except that we don't have a way at present to multi-lib the installed
  369. # Fortran modules, so we assume 8 bytes for pointers, regardless of the
  370. # actual target.
  371. OMP_LOCK_KIND=$OMP_LOCK_SIZE
  372. OMP_NEST_LOCK_KIND=$OMP_NEST_LOCK_SIZE
  373. if test $OMP_LOCK_SIZE -gt 8 || test $OMP_LOCK_ALIGN -gt $OMP_LOCK_SIZE; then
  374. OMP_LOCK_KIND=8
  375. fi
  376. if test $OMP_NEST_LOCK_SIZE -gt 8 || test $OMP_NEST_LOCK_ALIGN -gt $OMP_NEST_LOCK_SIZE; then
  377. OMP_NEST_LOCK_KIND=8
  378. fi
  379. OMP_LOCK_25_KIND=$OMP_LOCK_25_SIZE
  380. OMP_NEST_LOCK_25_KIND=$OMP_NEST_LOCK_25_SIZE
  381. if test $OMP_LOCK_25_SIZE -gt 8 || test $OMP_LOCK_25_ALIGN -gt $OMP_LOCK_25_SIZE; then
  382. OMP_LOCK_25_KIND=8
  383. fi
  384. if test $OMP_NEST_LOCK_25_SIZE -gt 8 || test $OMP_NEST_LOCK_25_ALIGN -gt $OMP_NEST_LOCK_25_SIZE; then
  385. OMP_NEST_LOCK_25_KIND=8
  386. fi
  387. if test "$ac_cv_fc_compiler_gnu" = yes; then
  388. if test $OMP_DEPEND_KIND -eq 16; then
  389. if test $OMP_INT128_SIZE -ne 16; then
  390. AC_MSG_ERROR([unsupported system, cannot find Fortran int kind=16, needed for omp_depend_kind])
  391. fi
  392. else
  393. if test $OMP_DEPEND_KIND -ne 8; then
  394. AC_MSG_ERROR([unsupported system, cannot find Fortran integer kind for omp_depend_kind])
  395. fi
  396. fi
  397. fi
  398. AC_SUBST(INTPTR_T_KIND)
  399. AC_SUBST(OMP_LOCK_SIZE)
  400. AC_SUBST(OMP_LOCK_ALIGN)
  401. AC_SUBST(OMP_NEST_LOCK_SIZE)
  402. AC_SUBST(OMP_NEST_LOCK_ALIGN)
  403. AC_SUBST(OMP_LOCK_KIND)
  404. AC_SUBST(OMP_NEST_LOCK_KIND)
  405. AC_SUBST(OMP_LOCK_25_SIZE)
  406. AC_SUBST(OMP_LOCK_25_ALIGN)
  407. AC_SUBST(OMP_NEST_LOCK_25_SIZE)
  408. AC_SUBST(OMP_NEST_LOCK_25_ALIGN)
  409. AC_SUBST(OMP_LOCK_25_KIND)
  410. AC_SUBST(OMP_NEST_LOCK_25_KIND)
  411. AC_SUBST(OMP_DEPEND_KIND)
  412. CFLAGS="$save_CFLAGS"
  413. # Determine what GCC version number to use in filesystem paths.
  414. GCC_BASE_VER
  415. AC_CONFIG_FILES(omp.h omp_lib.h omp_lib.f90 libgomp_f.h)
  416. AC_CONFIG_FILES(Makefile testsuite/Makefile libgomp.spec)
  417. AC_CONFIG_FILES([testsuite/libgomp-test-support.pt.exp:testsuite/libgomp-test-support.exp.in])
  418. AC_CONFIG_FILES([testsuite/libgomp-site-extra.exp])
  419. AC_OUTPUT