From: Bruno Haible Date: Thu, 27 Jul 2006 12:18:17 +0000 (+0000) Subject: Determine how to use OpenMP. X-Git-Tag: 0.16.x-branchpoint~312 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=09a681943003b1297b8ce2e84f8ad94c25fcf27e;p=thirdparty%2Fgettext.git Determine how to use OpenMP. --- diff --git a/gettext-tools/m4/openmp.m4 b/gettext-tools/m4/openmp.m4 new file mode 100644 index 000000000..794e44c0c --- /dev/null +++ b/gettext-tools/m4/openmp.m4 @@ -0,0 +1,108 @@ +# openmp.m4 serial 1 (gettext-0.15.1) +dnl Copyright (C) 2006 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Determine the compiler flags needed to support OpenMP. +dnl Define OPENMP_CFLAGS. + +dnl From Bruno Haible. + +AC_DEFUN([gt_OPENMP], +[ + AC_MSG_CHECKING([whether to use OpenMP]) + AC_ARG_ENABLE(openmp, + [ --disable-openmp do not use OpenMP], + [OPENMP_CHOICE="$enableval"], + [OPENMP_CHOICE=yes]) + AC_MSG_RESULT([$OPENMP_CHOICE]) + OPENMP_CFLAGS= + if test "$OPENMP_CHOICE" = yes; then + AC_MSG_CHECKING([for $CC option to support OpenMP]) + AC_CACHE_VAL([gt_cv_prog_cc_openmp], [ + gt_cv_prog_cc_openmp=no + AC_COMPILE_IFELSE([ +#ifndef _OPENMP + Unlucky +#endif + ], [gt_cv_prog_cc_openmp=none]) + if test "$gt_cv_prog_cc_openmp" = no; then + dnl Try these flags: + dnl GCC >= 4.2 -fopenmp + dnl SunPRO C -xopenmp + dnl Intel C -openmp + dnl SGI C, PGI C -mp + dnl Tru64 Compaq C -omp + dnl AIX IBM C -qsmp=omp + if test "$GCC" = yes; then + gt_save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -fopenmp" + AC_COMPILE_IFELSE([ +#ifndef _OPENMP + Unlucky +#endif + ], [gt_cv_prog_cc_openmp="-fopenmp"]) + CFLAGS="$gt_save_CFLAGS" + else + AC_EGREP_CPP([Brand], [ +#if defined __SUNPRO_C || defined __SUNPRO_CC + Brand +#endif + ], result=yes, result=no) + if test $result = yes; then + gt_save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -xopenmp" + AC_COMPILE_IFELSE([ +#ifndef _OPENMP + Unlucky +#endif + ], [gt_cv_prog_cc_openmp="-xopenmp"]) + CFLAGS="$gt_save_CFLAGS" + else + AC_EGREP_CPP([Brand], [ +#if defined __INTEL_COMPILER + Brand +#endif + ], result=yes, result=no) + if test $result = yes; then + gt_save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -openmp" + AC_COMPILE_IFELSE([ +#ifndef _OPENMP + Unlucky +#endif + ], [gt_cv_prog_cc_openmp="-openmp"]) + CFLAGS="$gt_save_CFLAGS" + else + for flag in -mp -omp -qsmp=omp; do + gt_save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $flag" + AC_COMPILE_IFELSE([ +#ifndef _OPENMP + Unlucky +#endif + ], [gt_cv_prog_cc_openmp="$flag"; break]) + done + fi + fi + fi + fi + ]) + case $gt_cv_prog_cc_openmp in + none) + AC_MSG_RESULT([none needed]) ;; + no) + AC_MSG_RESULT([unsupported]) ;; + *) + AC_MSG_RESULT([$gt_cv_prog_cc_openmp]) ;; + esac + case $gt_cv_prog_cc_openmp in + none | no) + OPENMP_CFLAGS= ;; + *) + OPENMP_CFLAGS=$gt_cv_prog_cc_openmp ;; + esac + fi + AC_SUBST([OPENMP_CFLAGS]) +])