| 1 |
27 |
bertin |
dnl
|
| 2 |
|
|
dnl acx_prog_cc_optim.m4
|
| 3 |
|
|
dnl
|
| 4 |
|
|
dnl Enable a reasonable set of optimization flags for the C compiler.
|
| 5 |
|
|
dnl
|
| 6 |
|
|
dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
| 7 |
|
|
dnl
|
| 8 |
|
|
dnl This file part of: AstrOmatic software
|
| 9 |
|
|
dnl
|
| 10 |
|
|
dnl Copyright: (C) 2002-2010 Emmanuel Bertin -- IAP/CNRS/UPMC
|
| 11 |
|
|
dnl (C) 2002 Ville Lauriki (original version)
|
| 12 |
|
|
dnl
|
| 13 |
|
|
dnl Licenses: GPL (this version)
|
| 14 |
|
|
dnl MIT AllPermissive (original script)
|
| 15 |
|
|
dnl
|
| 16 |
|
|
dnl AstrOmatic software is free software: you can redistribute it and/or
|
| 17 |
|
|
dnl modify it under the terms of the GNU General Public License as
|
| 18 |
|
|
dnl published by the Free Software Foundation, either version 3 of the
|
| 19 |
|
|
dnl License, or (at your option) any later version.
|
| 20 |
|
|
dnl AstrOmatic software is distributed in the hope that it will be useful,
|
| 21 |
|
|
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 22 |
|
|
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 23 |
|
|
dnl GNU General Public License for more details.
|
| 24 |
|
|
dnl You should have received a copy of the GNU General Public License
|
| 25 |
|
|
dnl along with AstrOmatic software.
|
| 26 |
|
|
dnl If not, see <http://www.gnu.org/licenses/>.
|
| 27 |
|
|
dnl
|
| 28 |
|
|
dnl Last modified: 09/10/2010
|
| 29 |
|
|
dnl
|
| 30 |
|
|
dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
| 31 |
|
|
dnl
|
| 32 |
2 |
bertin |
dnl @synopsis ACX_PROG_CC_OPTIM
|
| 33 |
|
|
dnl
|
| 34 |
|
|
dnl Currently this macro knows about GCC, Solaris C compiler,
|
| 35 |
|
|
dnl Digital Unix C compiler, C for AIX Compiler, HP-UX C compiler,
|
| 36 |
|
|
dnl IRIX C compiler, NEC SX-5 (Super-UX 10) C compiler, and Cray J90
|
| 37 |
|
|
dnl (Unicos 10.0.0.8) C compiler.
|
| 38 |
|
|
dnl
|
| 39 |
|
|
dnl This macro is a modification of Ville Laurikari's VL_PROG_CC_WARNINGS
|
| 40 |
|
|
dnl
|
| 41 |
27 |
bertin |
|
| 42 |
2 |
bertin |
AC_DEFUN([ACX_PROG_CC_OPTIM], [
|
| 43 |
|
|
msg="for C compiler optimization flags"
|
| 44 |
27 |
bertin |
AC_CACHE_CHECK($msg, prog_cc_optim_cv_flags, [
|
| 45 |
2 |
bertin |
if test -n "$CC"; then
|
| 46 |
|
|
cat > conftest.c <<EOF
|
| 47 |
|
|
int main(int argc, char **argv) { return 0; }
|
| 48 |
|
|
EOF
|
| 49 |
|
|
|
| 50 |
|
|
dnl Most compilers print some kind of a version string with some command
|
| 51 |
|
|
dnl line options (often "-V"). The version string should be checked
|
| 52 |
|
|
dnl before doing a test compilation run with compiler-specific flags.
|
| 53 |
|
|
dnl This is because some compilers (like the Cray compiler) only
|
| 54 |
|
|
dnl produce a warning message for unknown flags instead of returning
|
| 55 |
|
|
dnl an error, resulting in a false positive. Also, compilers may do
|
| 56 |
|
|
dnl erratic things when invoked with flags meant for a different
|
| 57 |
|
|
dnl compiler.
|
| 58 |
|
|
|
| 59 |
14 |
bertin |
dnl INTEL C 64bits compiler
|
| 60 |
|
|
if $CC -V 2>&1 | grep -i "Intel(R) 64" > /dev/null 2>&1 &&
|
| 61 |
|
|
$CC -c -O conftest.c > /dev/null 2>&1 &&
|
| 62 |
|
|
test -f conftest.o; then
|
| 63 |
31 |
bertin |
prog_cc_optim_cv_flags="-O3 -axSSE3,SSE4.1,SSE4.2,AVX -no-prec-div -unroll"
|
| 64 |
27 |
bertin |
prog_ld_optim_cv_flags="-static-intel"
|
| 65 |
14 |
bertin |
|
| 66 |
|
|
dnl INTEL C 32bits compiler
|
| 67 |
|
|
elif $CC -V 2>&1 | grep -i "Intel(R)" > /dev/null 2>&1 &&
|
| 68 |
|
|
$CC -c -O conftest.c > /dev/null 2>&1 &&
|
| 69 |
|
|
test -f conftest.o; then
|
| 70 |
31 |
bertin |
prog_cc_optim_cv_flags="-O3 -axSSE2,SSE3,SSE4.1,SSE4.2,AVX -no-prec-div -unroll"
|
| 71 |
27 |
bertin |
prog_ld_optim_cv_flags="-static-intel"
|
| 72 |
14 |
bertin |
|
| 73 |
|
|
dnl GCC
|
| 74 |
|
|
elif test "$GCC" = "yes"; then
|
| 75 |
27 |
bertin |
prog_cc_optim_cv_flags="-O3 -g -funroll-loops -fomit-frame-pointer -Wall"
|
| 76 |
|
|
prog_ld_optim_cv_flags=""
|
| 77 |
14 |
bertin |
|
| 78 |
2 |
bertin |
dnl Solaris C compiler
|
| 79 |
|
|
elif $CC -V 2>&1 | grep -i "WorkShop" > /dev/null 2>&1 &&
|
| 80 |
|
|
$CC -c -O conftest.c > /dev/null 2>&1 &&
|
| 81 |
|
|
test -f conftest.o; then
|
| 82 |
27 |
bertin |
prog_cc_optim_cv_flags="-O"
|
| 83 |
|
|
prog_ld_optim_cv_flags=""
|
| 84 |
2 |
bertin |
|
| 85 |
|
|
dnl Digital Unix/Compaq C compiler
|
| 86 |
|
|
elif ($CC -V 2>&1 | grep -i "Digital UNIX Compiler"> /dev/null 2>&1 ||
|
| 87 |
|
|
$CC -V 2>&1 | grep -i "Compaq C"> /dev/null 2>&1) &&
|
| 88 |
|
|
$CC -c -fast conftest.c > /dev/null 2>&1 &&
|
| 89 |
|
|
test -f conftest.o; then
|
| 90 |
27 |
bertin |
prog_cc_optim_cv_flags="-fast -tune host"
|
| 91 |
|
|
prog_ld_optim_cv_flags=""
|
| 92 |
2 |
bertin |
|
| 93 |
|
|
dnl C for AIX Compiler
|
| 94 |
|
|
elif $CC 2>&1 | grep -i "C for AIX Compiler" > /dev/null 2>&1 &&
|
| 95 |
|
|
$CC -c -qinfo=all -O2 conftest.c > /dev/null 2>&1 &&
|
| 96 |
|
|
test -f conftest.o; then
|
| 97 |
27 |
bertin |
prog_cc_optim_cv_flags="-O2"
|
| 98 |
|
|
prog_ld_optim_cv_flags=""
|
| 99 |
2 |
bertin |
|
| 100 |
|
|
dnl IRIX C compiler
|
| 101 |
|
|
elif $CC -version 2>&1 | grep -i "MIPSpro Compilers" > /dev/null 2>&1 &&
|
| 102 |
|
|
$CC -c -fullwarn -O3 conftest.c > /dev/null 2>&1 &&
|
| 103 |
|
|
test -f conftest.o; then
|
| 104 |
27 |
bertin |
prog_cc_optim_cv_flags="-O3"
|
| 105 |
|
|
prog_ld_optim_cv_flags=""
|
| 106 |
2 |
bertin |
|
| 107 |
|
|
dnl HP-UX C compiler
|
| 108 |
|
|
elif what $CC 2>&1 | grep -i "HP C Compiler" > /dev/null 2>&1 &&
|
| 109 |
|
|
$CC -c -Aa +O3 conftest.c > /dev/null 2>&1 &&
|
| 110 |
|
|
test -f conftest.o; then
|
| 111 |
27 |
bertin |
prog_cc_optim_cv_flags="+O3"
|
| 112 |
|
|
prog_ld_optim_cv_flags=""
|
| 113 |
2 |
bertin |
|
| 114 |
|
|
dnl The NEC SX-5 (Super-UX 10) C compiler
|
| 115 |
|
|
elif $CC -V 2>&1 | grep "/SX" > /dev/null 2>&1 &&
|
| 116 |
|
|
$CC -c -Xc -O conftest.c > /dev/null 2>&1 &&
|
| 117 |
|
|
test -f conftest.o; then
|
| 118 |
27 |
bertin |
prog_cc_optim_cv_flags="-O"
|
| 119 |
|
|
prog_ld_optim_cv_flags=""
|
| 120 |
2 |
bertin |
|
| 121 |
|
|
dnl The Cray C compiler (Unicos)
|
| 122 |
|
|
elif $CC -V 2>&1 | grep -i "Cray" > /dev/null 2>&1 &&
|
| 123 |
|
|
$CC -c -h conform -O3 conftest.c > /dev/null 2>&1 &&
|
| 124 |
|
|
test -f conftest.o; then
|
| 125 |
27 |
bertin |
prog_cc_optim_cv_flags="-O3"
|
| 126 |
|
|
prog_ld_optim_cv_flags=""
|
| 127 |
2 |
bertin |
|
| 128 |
|
|
fi
|
| 129 |
|
|
rm -f conftest.*
|
| 130 |
|
|
fi
|
| 131 |
27 |
bertin |
if test -n "$prog_cc_optim_cv_flags"; then
|
| 132 |
|
|
AM_CFLAGS="$CFLAGS $prog_cc_optim_cv_flags"
|
| 133 |
|
|
AM_LDFLAGS="$LDFLAGS $prog_ld_optim_cv_flags"
|
| 134 |
2 |
bertin |
else
|
| 135 |
27 |
bertin |
prog_cc_optim_cv_flags=""
|
| 136 |
|
|
prog_ld_optim_cv_flags=""
|
| 137 |
2 |
bertin |
fi
|
| 138 |
|
|
])
|
| 139 |
|
|
])dnl
|
| 140 |
14 |
bertin |
|