]>
Commit | Line | Data |
---|---|---|
0e60bc9b KZ |
1 | dnl Copyright (C) 2008-2011 Free Software Foundation, Inc. |
2 | dnl This file is free software; the Free Software Foundation | |
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 From Simon Josefsson | |
bdf5f542 | 7 | dnl -- derivated from coreutils m4/warnings.m4 |
0e60bc9b KZ |
8 | |
9 | # UL_AS_VAR_APPEND(VAR, VALUE) | |
10 | # ---------------------------- | |
11 | # Provide the functionality of AS_VAR_APPEND if Autoconf does not have it. | |
12 | m4_ifdef([AS_VAR_APPEND], | |
13 | [m4_copy([AS_VAR_APPEND], [UL_AS_VAR_APPEND])], | |
14 | [m4_define([UL_AS_VAR_APPEND], | |
15 | [AS_VAR_SET([$1], [AS_VAR_GET([$1])$2])])]) | |
16 | ||
55eec264 KZ |
17 | # |
18 | # Adds parameter to WARN_CFLAGS if the compiler supports it. | |
19 | # | |
20 | AC_DEFUN([UL_ADD_WARN_CFLAG], [ | |
21 | AS_VAR_PUSHDEF([ul_Warn], [ul_cv_warn_$1])dnl | |
22 | AC_CACHE_CHECK([whether compiler handles $1], m4_defn([ul_Warn]), [ | |
23 | ul_save_CPPFLAGS="$CPPFLAGS" | |
24 | CPPFLAGS="${CPPFLAGS} $1" | |
25 | AC_PREPROC_IFELSE([AC_LANG_PROGRAM([])], | |
26 | [AS_VAR_SET(ul_Warn, [yes])], | |
27 | [AS_VAR_SET(ul_Warn, [no])]) | |
28 | CPPFLAGS="$ul_save_CPPFLAGS" | |
29 | ]) | |
30 | AS_VAR_IF(ul_Warn, [yes], [UL_AS_VAR_APPEND([WARN_CFLAGS], [" $1"])]) | |
0e60bc9b | 31 | ]) |
55eec264 KZ |
32 | |
33 | # UL_WARN_ADD(PARAMETER, [EXCLUDE_CC_LIST]) | |
34 | # ----------------------------------------- | |
35 | # Adds parameter to WARN_CFLAGS if the compiler supports it. Ignore the | |
36 | # parameter if compiler is in exclude list. | |
37 | AC_DEFUN([UL_WARN_ADD], [ | |
38 | m4_ifval([$2], [ | |
39 | warn_exclude="$2" | |
40 | case $compiler_clang in | |
41 | yes) warn_cc=clang ;; | |
42 | *) warn_cc=$CC ;; | |
43 | esac | |
44 | case ${warn_exclude} in | |
45 | *${warn_cc}*) | |
46 | AC_MSG_CHECKING([whether compiler handles $1]) | |
47 | AC_MSG_RESULT([excluded]) | |
48 | ;; | |
49 | *) | |
50 | UL_ADD_WARN_CFLAG([$1]) | |
51 | ;; | |
52 | esac], | |
53 | [UL_ADD_WARN_CFLAG([$1])]) | |
0e60bc9b | 54 | ]) |
bdf5f542 KZ |
55 | |
56 | ||
57 | # UL_PROG_CLANG | |
58 | # ------------- | |
55eec264 KZ |
59 | # Checks if compiler is clang, defines compiler_clang=yes if yes. |
60 | # | |
61 | # Note that generic CC variable is not modified by this function. It's | |
62 | # possible that CC is set to 'cc' and the file /usr/bin/cc is a symlink to | |
63 | # /usr/bin/clang, then compiler_clang is also set ot 'yes'. | |
bdf5f542 KZ |
64 | AC_DEFUN([UL_PROG_CLANG], [ |
65 | AC_REQUIRE([AC_PROG_CC]) | |
66 | AC_CACHE_CHECK([whether clang is in use], [ul_cv_clang], [ | |
67 | case ${CC} in #( | |
68 | *gcc*) ul_cv_clang=no ;; | |
69 | *clang*) ul_cv_clang=yes ;; | |
70 | *) AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main() { | |
71 | #ifdef __clang__ | |
72 | return 0; | |
73 | #else | |
74 | #error The __clang__ was not defined | |
75 | #endif | |
76 | }])], | |
77 | [ul_cv_clang=yes], | |
78 | [ul_cv_clang=no] | |
79 | ) ;; | |
80 | esac | |
81 | ]) | |
82 | compiler_clang=$ul_cv_clang | |
83 | ]) |