File: acx_enable_warn.m4

package info (click to toggle)
madness 0.10.1%2Bgit20200818.eee5fd9f-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 34,980 kB
  • sloc: cpp: 280,841; ansic: 12,626; python: 4,961; fortran: 4,245; xml: 1,053; makefile: 714; sh: 276; perl: 244; yacc: 227; lex: 188; asm: 141; csh: 55
file content (66 lines) | stat: -rw-r--r-- 2,136 bytes parent folder | download | duplicates (4)
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
# This function is used to add compiler specific warning flags to CFLAGS and
# CXXFLAGS environment variables. Users are expected to specify their own warning
# flags for unknown compilers or special use cases by adding appropriate values
# to CFLAGS and CXXFLAGS.
AC_DEFUN([ACX_ENABLE_WARN], [
  acx_enable_warn=""
  acx_enable_warn_flags=""
  acx_enable_warn_compiler="$CXXVENDOR"
  
  # Allow the user to enable or disable warnings
  AC_ARG_ENABLE([warning],
    [AC_HELP_STRING([--enable-warning@<:@=yes|no|GNU|clang|Pathscale|Portland|Intel|IBM@:>@],
      [Automatically set warnings for compiler.@<:@default=yes@:>@])],
    [
      case $enableval in
      yes)
        acx_enable_warn="yes"
      ;;
      no)
        acx_enable_warn="no"
      ;;
      *)
        acx_enable_warn="yes"
        acx_enable_warn_compiler="$enableval"
      esac
    ],
    [acx_enable_warn="yes"]
  )
  
  # Automatically specify the warning flags for known compilers. 
  if test $acx_enable_warn != "no"; then
    case $acx_enable_warn_compiler in
      GNU)
        acx_enable_warn_flags="-Wall -Wno-strict-aliasing -Wno-deprecated -Wno-unused-local-typedefs"
      ;;
      clang)
        acx_enable_warn_flags="-Wall"
      ;;
      Pathscale)
        acx_enable_warn_flags="-Wall"
      ;;
      Portland)
        acx_enable_warn_flags=""
      ;;
      Intel)
        acx_enable_warn_flags="-Wall -diag-disable remark,279,654,1125"
      ;;
      IBM)
        acx_enable_warn_flags="-qflag=w:w"
      ;;
      *)
        AC_MSG_WARN([Warning flags not set for $acx_enable_optimal_compile compiler])
      ;;
    esac

    # Test the flags and add them to flag variables if successful.
    ACX_CHECK_COMPILER_FLAG([C], [CFLAGS], [$acx_enable_warn_flags],
      [CFLAGS="$CFLAGS $acx_enable_warn_flags"],
      [AC_MSG_WARN([$CC does not accept $acx_enable_warn_flags, no warning flags will be used.])])
    ACX_CHECK_COMPILER_FLAG([C++], [CXXFLAGS], [$acx_enable_warn_flags],
      [CXXFLAGS="$CXXFLAGS $acx_enable_warn_flags"],
      [AC_MSG_WARN([$CXX does not accept $acx_enable_warn_flags, no warning flags will be used.])])
  fi
  

])