1# openmp.m4 serial 3 (gettext-0.16) 2dnl Copyright (C) 2006 Free Software Foundation, Inc. 3dnl This file is free software; the Free Software Foundation 4dnl gives unlimited permission to copy and/or distribute it, 5dnl with or without modifications, as long as this notice is preserved. 6 7dnl Determine the compiler flags needed to support OpenMP. 8dnl Define OPENMP_CFLAGS. 9 10dnl From Bruno Haible. 11 12AC_DEFUN([gt_OPENMP], 13[ 14 AC_MSG_CHECKING([whether to use OpenMP]) 15 AC_ARG_ENABLE(openmp, 16 [ --disable-openmp do not use OpenMP], 17 [OPENMP_CHOICE="$enableval"], 18 [OPENMP_CHOICE=yes]) 19 AC_MSG_RESULT([$OPENMP_CHOICE]) 20 OPENMP_CFLAGS= 21 if test "$OPENMP_CHOICE" = yes; then 22 AC_MSG_CHECKING([for $CC option to support OpenMP]) 23 AC_CACHE_VAL([gt_cv_prog_cc_openmp], [ 24 gt_cv_prog_cc_openmp=no 25 AC_COMPILE_IFELSE([ 26#ifndef _OPENMP 27 Unlucky 28#endif 29 ], [gt_cv_prog_cc_openmp=none]) 30 if test "$gt_cv_prog_cc_openmp" = no; then 31 dnl Try these flags: 32 dnl GCC >= 4.2 -fopenmp 33 dnl SunPRO C -xopenmp 34 dnl Intel C -openmp 35 dnl SGI C, PGI C -mp 36 dnl Tru64 Compaq C -omp 37 dnl AIX IBM C -qsmp=omp 38 if test "$GCC" = yes; then 39 dnl --- Test for GCC. 40 gt_save_CFLAGS="$CFLAGS" 41 CFLAGS="$CFLAGS -fopenmp" 42 AC_COMPILE_IFELSE([ 43#ifndef _OPENMP 44 Unlucky 45#endif 46 ], [gt_cv_prog_cc_openmp="-fopenmp"]) 47 CFLAGS="$gt_save_CFLAGS" 48 else 49 dnl --- Test for SunPRO C. 50 AC_EGREP_CPP([Brand], [ 51#if defined __SUNPRO_C || defined __SUNPRO_CC 52 Brand 53#endif 54 ], result=yes, result=no) 55 if test $result = yes; then 56 gt_save_CFLAGS="$CFLAGS" 57 CFLAGS="$CFLAGS -xopenmp" 58 AC_COMPILE_IFELSE([ 59#ifndef _OPENMP 60 Unlucky 61#endif 62 ], [gt_cv_prog_cc_openmp="-xopenmp"]) 63 CFLAGS="$gt_save_CFLAGS" 64 else 65 dnl --- Test for Intel C. 66 AC_EGREP_CPP([Brand], [ 67#if defined __INTEL_COMPILER 68 Brand 69#endif 70 ], result=yes, result=no) 71 if test $result = yes; then 72 gt_save_CFLAGS="$CFLAGS" 73 CFLAGS="$CFLAGS -openmp" 74 AC_COMPILE_IFELSE([ 75#ifndef _OPENMP 76 Unlucky 77#endif 78 ], [gt_cv_prog_cc_openmp="-openmp"]) 79 CFLAGS="$gt_save_CFLAGS" 80 else 81 dnl --- Test for SGI C, PGI C. 82 AC_EGREP_CPP([Brand], [ 83#if defined __sgi || defined __PGI || defined __PGIC__ 84 Brand 85#endif 86 ], result=yes, result=no) 87 if test $result = yes; then 88 gt_save_CFLAGS="$CFLAGS" 89 CFLAGS="$CFLAGS -mp" 90 AC_COMPILE_IFELSE([ 91#ifndef _OPENMP 92 Unlucky 93#endif 94 ], [gt_cv_prog_cc_openmp="-mp"]) 95 CFLAGS="$gt_save_CFLAGS" 96 else 97 dnl --- Test for Compaq C. 98 AC_EGREP_CPP([Brand], [ 99#if defined __DECC || defined __DECCXX 100 Brand 101#endif 102 ], result=yes, result=no) 103 if test $result = yes; then 104 gt_save_CFLAGS="$CFLAGS" 105 CFLAGS="$CFLAGS -omp" 106 AC_COMPILE_IFELSE([ 107#ifndef _OPENMP 108 Unlucky 109#endif 110 ], [gt_cv_prog_cc_openmp="-omp"]) 111 CFLAGS="$gt_save_CFLAGS" 112 else 113 dnl --- Test for AIX IBM C. 114 AC_EGREP_CPP([Brand], [ 115#if defined _AIX 116 Brand 117#endif 118 ], result=yes, result=no) 119 if test $result = yes; then 120 gt_save_CFLAGS="$CFLAGS" 121 CFLAGS="$CFLAGS -qsmp=omp" 122 AC_COMPILE_IFELSE([ 123#ifndef _OPENMP 124 Unlucky 125#endif 126 ], [gt_cv_prog_cc_openmp="-qsmp=omp"]) 127 CFLAGS="$gt_save_CFLAGS" 128 else 129 : 130 fi 131 fi 132 fi 133 fi 134 fi 135 fi 136 fi 137 ]) 138 case $gt_cv_prog_cc_openmp in 139 none) 140 AC_MSG_RESULT([none needed]) ;; 141 no) 142 AC_MSG_RESULT([unsupported]) ;; 143 *) 144 AC_MSG_RESULT([$gt_cv_prog_cc_openmp]) ;; 145 esac 146 case $gt_cv_prog_cc_openmp in 147 none | no) 148 OPENMP_CFLAGS= ;; 149 *) 150 OPENMP_CFLAGS=$gt_cv_prog_cc_openmp ;; 151 esac 152 fi 153 AC_SUBST([OPENMP_CFLAGS]) 154]) 155