Merge Trond
[m6w6/libmemcached] / m4 / pandora_ensure_gcc_version.m4
1 dnl Copyright (C) 2009 Sun Microsystems
2 dnl This file is free software; Sun Microsystems
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
6 dnl If the user is on a Mac and didn't ask for a specific compiler
7 dnl You're gonna get 4.2.
8 AC_DEFUN([PANDORA_MAC_GCC42],
9 [AS_IF([test "$GCC" = "yes"],[
10 AS_IF([test "$host_vendor" = "apple" -a "x${ac_cv_env_CC_set}" = "x"],[
11 host_os_version=`echo ${host_os} | perl -ple 's/^\D+//g;s,\..*,,'`
12 AS_IF([test "$host_os_version" -lt 10],[
13 AS_IF([test -f /usr/bin/gcc-4.2],
14 [
15 CPP="/usr/bin/gcc-4.2 -E"
16 CC=/usr/bin/gcc-4.2
17 CXX=/usr/bin/g++-4.2
18 ])
19 ])
20 ])
21 ])
22 ])
23
24 dnl
25 AC_DEFUN([PANDORA_ENSURE_GCC_VERSION],[
26 AC_REQUIRE([PANDORA_MAC_GCC42])
27 AC_CACHE_CHECK([if GCC is recent enough], [ac_cv_gcc_recent],
28 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
29 #if !defined(__GNUC__) || (__GNUC__ < 4) || ((__GNUC__ >= 4) && (__GNUC_MINOR__ < 1))
30 # error GCC is Too Old!
31 #endif
32 ]])],
33 [ac_cv_gcc_recent=yes],
34 [ac_cv_gcc_recent=no])])
35 AS_IF([test "$ac_cv_gcc_recent" = "no" -a "$host_vendor" = "apple"],
36 AC_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]))
37 AS_IF([test "$ac_cv_gcc_recent" = "no"],
38 AC_MSG_ERROR([Your version of GCC is too old. At least version 4.1 is required]))
39 ])