diff --git a/m4/ax_pthread.m4 b/m4/ax_pthread.m4 index d09a1cd68..bdb34b0ae 100644 --- a/m4/ax_pthread.m4 +++ b/m4/ax_pthread.m4 @@ -160,11 +160,10 @@ case ${host_os} in ;; darwin*) - if test "$CC" = "clang"; then - ax_pthread_flags="$ax_pthread_flags" - else - ax_pthread_flags="-pthread $ax_pthread_flags" - fi + AC_REQUIRE([WOLFSSL_DARWIN_USING_CLANG]) + AS_IF([test x"$wolfssl_darwin_clang" = x"yes"], + [ax_pthread_flags="$ax_pthread_flags"], + [ax_pthread_flags="-pthread $ax_pthread_flags"]) ;; esac diff --git a/m4/wolfssl_darwin_clang.m4 b/m4/wolfssl_darwin_clang.m4 new file mode 100644 index 000000000..fee9b6ae0 --- /dev/null +++ b/m4/wolfssl_darwin_clang.m4 @@ -0,0 +1,37 @@ +# =========================================================================== +# +# SYNOPSIS +# +# WOLFSSL_DARWIN_USING_CLANG +# +# DESCRIPTION +# +# With the advent of Apple Xcode v5.0, the old tool sets are missing from +# the distribution. The provided "gcc" executable wrapper accepts the +# "-pthread" flag, and passes it to the underlying "clang" which chokes +# on it. This script checks the version of the gcc executable to see if +# it reports it is really "clang". +# +# The value is placed in the wolfssl_darwin_clang variable. +# +# LICENSE +# +# Copyright (c) 2013 John Safranek +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 1 + +AC_DEFUN([WOLFSSL_DARWIN_USING_CLANG], + [ + if test x"$CC" = xclang; then + wolfssl_darwin_clang=yes + elif test x"$CC" = x || test x"$CC" = xgcc; then + if /usr/bin/gcc -v 2>&1 | grep 'clang' >/dev/null 2>&1; then + wolfssl_darwin_clang=yes + fi + fi + ])