File: dw_compiler.m4

package info (click to toggle)
dwarfutils 20201201-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 11,868 kB
  • sloc: ansic: 104,667; sh: 5,947; cpp: 4,675; python: 878; makefile: 646; awk: 11
file content (94 lines) | stat: -rw-r--r-- 2,487 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
dnl Copyright (C) 2018 Vincent Torri <vincent dot torri at gmail dot com>
dnl This code is public domain and can be freely used or copied.

dnl Macro that check if compiler flags are available


dnl Macro that checks for a C compiler flag availability
dnl
dnl _DWARF_CHECK_C_COMPILER_FLAG(FLAGS)
dnl AC_SUBST : DWARF_CFLAGS_WARN
dnl have_flag: yes or no.
AC_DEFUN([_DWARF_CHECK_C_COMPILER_FLAG],
[dnl

dnl store in options -Wfoo if -Wno-foo is passed
option="m4_bpatsubst([[$1]], [-Wno-], [-W])"
CFLAGS_save="${CFLAGS}"
CFLAGS="${CFLAGS} ${option}"
AC_LANG_PUSH([C])

AC_MSG_CHECKING([whether the C compiler supports $1])
AC_COMPILE_IFELSE(
   [AC_LANG_PROGRAM([[]])],
   [have_flag="yes"],
   [have_flag="no"])
AC_MSG_RESULT([${have_flag}])

AC_LANG_POP([C])
CFLAGS="${CFLAGS_save}"

AS_IF(
    [test "x${have_flag}" = "xyes"],
    [DWARF_CFLAGS_WARN="${DWARF_CFLAGS_WARN} [$1]"])

AC_SUBST(DWARF_CFLAGS_WARN)dnl
])

dnl DWARF_CHECK_C_COMPILER_FLAGS(FLAGS)
dnl Checks if FLAGS are supported and add to DWARF_CLFAGS.
dnl
dnl It will first try every flag at once, if one fails we will try
dnl them one by one.
AC_DEFUN([DWARF_CHECK_C_COMPILER_FLAGS],
[dnl
_DWARF_CHECK_C_COMPILER_FLAG([$1])
AS_IF(
    [test "${have_flag}" != "yes"],
    [m4_foreach_w([flag], [$1], [_DWARF_CHECK_C_COMPILER_FLAG(m4_defn([flag]))])])
])


dnl Macro that checks for a C++ compiler flag availability
dnl
dnl _DWARF_CHECK_CXX_COMPILER_FLAG(FLAGS)
dnl AC_SUBST : DWARF_CXXFLAGS_WARN
dnl have_flag: yes or no.
AC_DEFUN([_DWARF_CHECK_CXX_COMPILER_FLAG],
[dnl

dnl store in options -Wfoo if -Wno-foo is passed
option="m4_bpatsubst([[$1]], [-Wno-], [-W])"
CXXFLAGS_save="${CXXFLAGS}"
CXXFLAGS="${CXXFLAGS} ${option}"
AC_LANG_PUSH([C++])

AC_MSG_CHECKING([whether the C++ compiler supports $1])
AC_COMPILE_IFELSE(
   [AC_LANG_PROGRAM([[]])],
   [have_flag="yes"],
   [have_flag="no"])
AC_MSG_RESULT([${have_flag}])

AC_LANG_POP([C++])
CXXFLAGS="${CXXFLAGS_save}"

AS_IF(
    [test "x${have_flag}" = "xyes"],
    [DWARF_CXXFLAGS_WARN="${DWARF_CXXFLAGS_WARN} [$1]"])

AC_SUBST(DWARF_CXXFLAGS_WARN)dnl
])

dnl DWARF_CHECK_CXX_COMPILER_FLAGS(FLAGS)
dnl Checks if FLAGS are supported and add to DWARF_CXXLFAGS.
dnl
dnl It will first try every flag at once, if one fails we will try
dnl them one by one.
AC_DEFUN([DWARF_CHECK_CXX_COMPILER_FLAGS],
[dnl
_DWARF_CHECK_CXX_COMPILER_FLAG([$1])
AS_IF(
    [test "${have_flag}" != "yes"],
    [m4_foreach_w([flag], [$1], [_DWARF_CHECK_CXX_COMPILER_FLAG(m4_defn([flag]))])])
])