From 26d72360c5e29ad0f1b37af7b22c82595dabace3 Mon Sep 17 00:00:00 2001 From: John Safranek Date: Mon, 28 Oct 2013 12:27:56 -0700 Subject: [PATCH] Improvement to M4 scripts to check for clang when building under Darwin. --- m4/ax_pthread.m4 | 9 ++++----- m4/wolfssl_darwin_clang.m4 | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 m4/wolfssl_darwin_clang.m4 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 + ])