From f1285b7f4b24968b2dd6fa80612bac0847ac26ee Mon Sep 17 00:00:00 2001 From: Eric McConville Date: Wed, 27 Nov 2013 15:15:14 -0600 Subject: Created DETECT_CLANG autoconf function, and excluded '-pthread' from CFLAGS when GCC is clang --- configure.ac | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index 4bedb4d..1f8e485 100644 --- a/configure.ac +++ b/configure.ac @@ -42,6 +42,27 @@ AC_DEFUN([DETECT_ICC], fi ]) +dnl ********************************************************************** +dnl DETECT_CLANG ([ACTION-IF-YES], [ACTION-IF-NO]) +dnl +dnl check if compiler is clang, and if so run the ACTION-IF-YES sets the +dnl $CLANG variable to "yes" or "no" +dnl ********************************************************************** +AC_DEFUN([DETECT_CLANG], +[ + AC_MSG_CHECKING([for clang in use]) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([], [[ + #ifndef __clang__ + not clang + #endif + ]])], + [CLANG=yes], [CLANG=no]) + AC_MSG_RESULT([$CLANG]) + AS_IF([test "$CLANG" = "yes"],[$1],[$2]) +]) +DETECT_CLANG([],[]) + dnl ********************************************************************** dnl DETECT_SUNCC ([ACTION-IF-YES], [ACTION-IF-NO]) dnl @@ -56,7 +77,8 @@ AC_DEFUN([DETECT_SUNCC], ]) AS_IF(test "x$GCC" = "xyes", - DETECT_ICC([CFLAGS="-pthread $CFLAGS"], [CFLAGS="-fvisibility=hidden -pthread $CFLAGS"]), + DETECT_ICC([CFLAGS="-pthread $CFLAGS"], + DETECT_CLANG([], [CFLAGS="-fvisibility=hidden -pthread $CFLAGS"])), ICC=no DETECT_SUNCC([CFLAGS="-xldscope=hidden -mt -xc99=all $CFLAGS"], [])) @@ -85,6 +107,7 @@ AS_IF([test "x$enable_sasl_pwdb" = "xyes"], [enable_sasl=yes ]) + dnl ********************************************************************** dnl DETECT_SASL_CB_GETCONF dnl @@ -206,11 +229,8 @@ AC_SUBST(PROFILER_LDFLAGS) AC_ARG_ENABLE(coverage, [AS_HELP_STRING([--enable-coverage],[Disable code coverage])]) -if test "x$enable_coverage" = "xyes"; then - if test "$ICC" = "yes" - then - AC_MSG_WARN([icc doesn't support code coverage checking]) - elif test "$GCC" = "yes" +if test "x$enable_coverage" != "xno"; then + if test "$GCC" = "yes" -a "$ICC" != "yes" -a "$CLANG" != "yes" then AC_PATH_PROG([PROFILER], [gcov], "no", [$PATH]) if test "x$PROFILER" != "xno"; then @@ -230,6 +250,14 @@ if test "x$enable_coverage" = "xyes"; then if test "x$PROFILER" != "xno"; then PROFILER_FLAGS=-xprofile=tcov fi + elif test "x$CLANG" != "xno" + then + AC_PATH_PROG([PROFILER], [gcov], "no", [$PATH]) + if test "x$PROFILER" != "xno" + then + PROFILER_FLAGS="-fprofile-arcs -ftest-coverage" + PROFILER_LDFLAGS= + fi fi fi AC_SUBST(PROFILER_FLAGS) -- cgit v1.2.1