mhd_check_cc_is_clang.m4 (1534B)
1 # SPDX-License-Identifier: FSFAP 2 # 3 # SYNOPSIS 4 # 5 # MHD_CHECK_CC_IS_CLANG([ACTION-IF-CLANG], [ACTION-IF-NOT-CLANG]) 6 # 7 # DESCRIPTION 8 # 9 # This macro checks whether the compiler set by $CC is actually clang or 10 # llvm-based compiler. 11 # The result is cached in variable mhd_cv_cc_clang_based. 12 # 13 # Example usage: 14 # 15 # MHD_CHECK_CC_IS_CLANG 16 # 17 # 18 # LICENSE 19 # 20 # Copyright (c) 2022-2026 Karlson2k (Evgeny Grin) <k2k@drgrin.dev> 21 # 22 # Copying and distribution of this file, with or without modification, are 23 # permitted in any medium without royalty provided the copyright notice 24 # and this notice are preserved. This file is offered as-is, without any 25 # warranty. 26 27 #serial 1 28 29 AC_DEFUN([MHD_CHECK_CC_IS_CLANG],[dnl 30 AC_PREREQ([2.64])dnl 31 AC_REQUIRE([AC_PROG_CC])dnl 32 AC_CACHE_CHECK([whether $CC is clang or llvm-based], 33 [mhd_cv_cc_clang_based], 34 [AS_VAR_IF([GCC],["yes"], 35 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ 36 #if ! defined(__clang__) && ! defined(__llvm__) 37 #error This compiler is not clang nor llvm-based compiler 38 fail test here %%%@<:@-1@:>@ 39 #endif 40 void test_func1(void); 41 void test_func1(void) {return;} 42 ]])],dnl AC_LANG_SOURCE 43 [mhd_cv_cc_clang_based="yes"],[mhd_cv_cc_clang_based="no"])dnl AC_COMPILE_IFELSE 44 ],[mhd_cv_cc_clang_based="no"])dnl AS_VAR_IF GCC 45 ]) 46 dnl AC_CACHE_CHECK 47 m4_n([m4_ifnblank([$1$2],[AS_VAR_IF([mhd_cv_cc_clang_based],["yes"],[$1],[$2])])])dnl 48 # Re-use result in AX_PTHREAD macro 49 AS_VAR_SET_IF([ax_cv_PTHREAD_CLANG],[:],[ax_cv_PTHREAD_CLANG="$mhd_cv_cc_clang_based"]) 50 ])dnl AC_DEFUN MHD_CHECK_ADD_CC_CFLAG