pandora_ensure_gcc_version.m4 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. dnl Copyright (C) 2009 Sun Microsystems, Inc.
  2. dnl This file is free software; Sun Microsystems, Inc.
  3. dnl gives unlimited permission to copy and/or distribute it,
  4. dnl with or without modifications, as long as this notice is preserved.
  5. AC_DEFUN([_PANDORA_TRY_GCC],[
  6. pushdef([Name],[translit([$1],[./-], [___])])
  7. pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
  8. [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
  9. AC_CHECK_PROGS([CC]NAME,[gcc$1])
  10. AC_CHECK_PROGS([CXX]NAME,[g++$1])
  11. AS_IF([test "x${CC]NAME[}" != "x" -a "x${ac_cv_env_CC_set}" = "x"],
  12. [CC="${CC]NAME[}"])
  13. AS_IF([test "x${CXX]NAME[}" != "x" -a "x${ac_cv_env_CCX_set}" = "x"],
  14. [CXX="${CXX]NAME[}"])
  15. AS_IF([test "x${CC]NAME[}" != "x" -a "x${ac_cv_env_CPP_set}" = "x"],
  16. [CPP="${CC]NAME[} -E"])
  17. ])
  18. dnl If the user is on a Mac and didn't ask for a specific compiler
  19. dnl You're gonna get 4.2.
  20. AC_DEFUN([PANDORA_MAC_GCC42],
  21. [AS_IF([test "$GCC" = "yes"],[
  22. AS_IF([test "$host_vendor" = "apple" -a "x${ac_cv_env_CC_set}" = "x"],[
  23. host_os_version=`echo ${host_os} | perl -ple 's/^\D+//g;s,\..*,,'`
  24. AS_IF([test "$host_os_version" -lt 10],[
  25. _PANDORA_TRY_GCC([-4.2])
  26. ])
  27. ])
  28. ])
  29. ])
  30. dnl If the user is on CentOS or RHEL and didn't ask for a specific compiler
  31. dnl You're gonna get 4.4 (forward compatible with 4.5)
  32. AC_DEFUN([PANDORA_RH_GCC44],
  33. [AS_IF([test "$GCC" = "yes"],[
  34. AS_IF([test "x${ac_cv_env_CC_set}" = "x"],[
  35. _PANDORA_TRY_GCC([44])
  36. _PANDORA_TRY_GCC([45])
  37. ])
  38. ])
  39. ])
  40. dnl
  41. AC_DEFUN([PANDORA_ENSURE_GCC_VERSION],[
  42. AC_REQUIRE([PANDORA_MAC_GCC42])
  43. AC_REQUIRE([PANDORA_RH_GCC44])
  44. AS_IF([test "$GCC" = "yes"],[
  45. AC_CACHE_CHECK([if GCC is recent enough], [ac_cv_gcc_recent],
  46. [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  47. #if !defined(__GNUC__) || (__GNUC__ < 4) || ((__GNUC__ >= 4) && (__GNUC_MINOR__ < 2))
  48. # error GCC is Too Old!
  49. #endif
  50. ]])],
  51. [ac_cv_gcc_recent=yes],
  52. [ac_cv_gcc_recent=no])])
  53. AS_IF([test "$ac_cv_gcc_recent" = "no" -a "$host_vendor" = "apple"],
  54. PANDORA_MSG_ERROR([Your version of GCC is too old. At least version 4.2 is required on OSX. You may need to install a version of XCode >= 3.1.2]))
  55. AS_IF([test "$ac_cv_gcc_recent" = "no"],
  56. PANDORA_MSG_ERROR([Your version of GCC is too old. At least version 4.2 is required. On RHEL/CentOS systems this is found in the gcc44 and gcc44-c++ packages.]))
  57. ])
  58. ])