2
0

ax_cc_maxopt.m4 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. AC_DEFUN([AX_CC_MAXOPT],
  2. [
  3. AC_REQUIRE([AC_PROG_CC])
  4. AC_REQUIRE([AX_COMPILER_VENDOR])
  5. AC_ARG_ENABLE(portable-binary, [AC_HELP_STRING([--enable-portable-binary], [disable compiler optimizations that would produce unportable binaries])],
  6. acx_maxopt_portable=$withval, acx_maxopt_portable=no)
  7. # Try to determine "good" native compiler flags if none specified via CFLAGS
  8. if test "$ac_test_CFLAGS" != "set"; then
  9. CFLAGS=""
  10. case $ax_cv_c_compiler_vendor in
  11. dec) CFLAGS="-newc -w0 -O5 -ansi_alias -ansi_args -fp_reorder -tune host"
  12. if test "x$acx_maxopt_portable" = xno; then
  13. CFLAGS="$CFLAGS -arch host"
  14. fi;;
  15. sun) CFLAGS="-native -fast -xO5 -dalign -xc99=all"
  16. if test "x$acx_maxopt_portable" = xyes; then
  17. CFLAGS="$CFLAGS -xarch=generic"
  18. fi;;
  19. hp) CFLAGS="+Oall +Optrs_ansi +DSnative"
  20. if test "x$acx_maxopt_portable" = xyes; then
  21. CFLAGS="$CFLAGS +DAportable"
  22. fi;;
  23. ibm) if test "x$acx_maxopt_portable" = xno; then
  24. xlc_opt="-qarch=auto -qtune=auto"
  25. else
  26. xlc_opt="-qtune=auto"
  27. fi
  28. AX_CHECK_COMPILER_FLAGS($xlc_opt,
  29. CFLAGS="-O3 -qansialias -w $xlc_opt",
  30. [CFLAGS="-O3 -qansialias -w"
  31. echo "******************************************************"
  32. echo "* You seem to have the IBM C compiler. It is *"
  33. echo "* recommended for best performance that you use: *"
  34. echo "* *"
  35. echo "* CFLAGS=-O3 -qarch=xxx -qtune=xxx -qansialias -w *"
  36. echo "* ^^^ ^^^ *"
  37. echo "* where xxx is pwr2, pwr3, 604, or whatever kind of *"
  38. echo "* CPU you have. (Set the CFLAGS environment var. *"
  39. echo "* and re-run configure.) For more info, man cc. *"
  40. echo "******************************************************"])
  41. ;;
  42. intel) CFLAGS="-O3 -ansi_alias"
  43. if test "x$acx_maxopt_portable" = xno; then
  44. icc_archflag=unknown
  45. icc_flags=""
  46. case $host_cpu in
  47. i686*|x86_64*)
  48. # icc accepts gcc assembly syntax, so these should work:
  49. AX_GCC_X86_CPUID(0)
  50. AX_GCC_X86_CPUID(1)
  51. case $ax_cv_gcc_x86_cpuid_0 in # see AX_GCC_ARCHFLAG
  52. *:756e6547:*:*) # Intel
  53. case $ax_cv_gcc_x86_cpuid_1 in
  54. *6a?:*[[234]]:*:*|*6[[789b]]?:*:*:*) icc_flags="-xK";;
  55. *f3[[347]]:*:*:*|*f4[1347]:*:*:*) icc_flags="-xP -xN -xW -xK";;
  56. *f??:*:*:*) icc_flags="-xN -xW -xK";;
  57. esac ;;
  58. esac ;;
  59. esac
  60. if test "x$icc_flags" != x; then
  61. for flag in $icc_flags; do
  62. AX_CHECK_COMPILER_FLAGS($flag, [icc_archflag=$flag; break])
  63. done
  64. fi
  65. AC_MSG_CHECKING([for icc architecture flag])
  66. AC_MSG_RESULT($icc_archflag)
  67. if test "x$icc_archflag" != xunknown; then
  68. CFLAGS="$CFLAGS $icc_archflag"
  69. fi
  70. fi
  71. ;;
  72. gnu)
  73. # default optimization flags for gcc on all systems
  74. CFLAGS="-O3 -fomit-frame-pointer"
  75. # -malign-double for x86 systems
  76. AX_CHECK_COMPILER_FLAGS(-malign-double, CFLAGS="$CFLAGS -malign-double")
  77. # -fstrict-aliasing for gcc-2.95+
  78. AX_CHECK_COMPILER_FLAGS(-fstrict-aliasing,
  79. CFLAGS="$CFLAGS -fstrict-aliasing")
  80. # note that we enable "unsafe" fp optimization with other compilers, too
  81. AX_CHECK_COMPILER_FLAGS(-ffast-math, CFLAGS="$CFLAGS -ffast-math")
  82. AX_GCC_ARCHFLAG($acx_maxopt_portable)
  83. ;;
  84. esac
  85. if test -z "$CFLAGS"; then
  86. echo ""
  87. echo "********************************************************"
  88. echo "* WARNING: Don't know the best CFLAGS for this system *"
  89. echo "* Use ./configure CFLAGS=... to specify your own flags *"
  90. echo "* (otherwise, a default of CFLAGS=-O3 will be used) *"
  91. echo "********************************************************"
  92. echo ""
  93. CFLAGS="-O3"
  94. fi
  95. AX_CHECK_COMPILER_FLAGS($CFLAGS, [], [
  96. echo ""
  97. echo "********************************************************"
  98. echo "* WARNING: The guessed CFLAGS don't seem to work with *"
  99. echo "* your compiler. *"
  100. echo "* Use ./configure CFLAGS=... to specify your own flags *"
  101. echo "********************************************************"
  102. echo ""
  103. CFLAGS=""
  104. ])
  105. fi
  106. ])