1# Taken from the autoconf source in 05/2020 2# Copyright (C) 2001-2017, 2020 Free Software Foundation, Inc. 3 4# This file is part of Autoconf. This program is free 5# software; you can redistribute it and/or modify it under the 6# terms of the GNU General Public License as published by the 7# Free Software Foundation, either version 3 of the License, or 8# (at your option) any later version. 9# 10# This program is distributed in the hope that it will be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13# GNU General Public License for more details. 14# 15# Under Section 7 of GPL version 3, you are granted additional 16# permissions described in the Autoconf Configure Script Exception, 17# version 3.0, as published by the Free Software Foundation. 18# 19# You should have received a copy of the GNU General Public License 20# and a copy of the Autoconf Configure Script Exception along with 21# this program; see the files COPYINGv3 and COPYING.EXCEPTION 22# respectively. If not, see <https://www.gnu.org/licenses/>. 23 24# Written by David MacKenzie, with help from 25# Akim Demaille, Paul Eggert, 26# Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor, 27# Roland McGrath, Noah Friedman, david d zuhn, and many others. 28 29 30AC_DEFUN([AX_OPENMP], 31[ 32 AC_PREREQ(2.62) 33 OPENMP_[]_AC_LANG_PREFIX[]FLAGS= 34 35 AC_CACHE_CHECK([for $[]_AC_CC[] option to support OpenMP], 36 [ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp], 37 [AC_LINK_IFELSE([_AC_LANG_OPENMP], 38 [ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp='none needed'], 39 [ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp='unsupported' 40 dnl Try these flags: 41 dnl GCC >= 4.2 -fopenmp 42 dnl Intel C -qopenmp -openmp 43 dnl SGI C, PGI C -mp 44 dnl Tru64 Compaq C -omp 45 dnl IBM XL C (AIX, Linux) -qsmp=omp 46 dnl Cray CCE -homp 47 dnl NEC SX -Popenmp 48 dnl Lahey Fortran (Linux) --openmp 49 dnl SunPRO C -xopenmp 50 dnl If in this loop a compiler is passed an option that it doesn't 51 dnl understand or that it misinterprets, the AC_LINK_IFELSE test 52 dnl will fail (since we know that it failed without the option), 53 dnl therefore the loop will continue searching for an option, and 54 dnl no output file called 'penmp' or 'mp' is created. 55 for ac_option in -fopenmp -qopenmp -openmp -mp -omp -qsmp=omp -homp \ 56 -Popenmp --openmp -xopenmp; do 57 ac_save_[]_AC_LANG_PREFIX[]FLAGS=$[]_AC_LANG_PREFIX[]FLAGS 58 _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $ac_option" 59 AC_LINK_IFELSE([_AC_LANG_OPENMP], 60 [ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp=$ac_option]) 61 _AC_LANG_PREFIX[]FLAGS=$ac_save_[]_AC_LANG_PREFIX[]FLAGS 62 if test "$ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp" != unsupported; then 63 break 64 fi 65 done])]) 66 case $ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp in #( 67 unsupported) 68 ;; #( 69 "none needed" ) 70 AC_DEFINE(HAVE_OPENMP,1,[Define if OpenMP is enabled]) ;; #( 71 *) 72 OPENMP_[]_AC_LANG_PREFIX[]FLAGS=$ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp 73 AC_DEFINE(HAVE_OPENMP,1,[Define if OpenMP is enabled]) ;; 74 esac 75 76 AC_SUBST([OPENMP_]_AC_LANG_PREFIX[FLAGS]) 77]) 78