lalsuite_gccflags.m4 2.62 KB
Newer Older
1
# -*- mode: autoconf; -*-
Adam Mercer's avatar
Adam Mercer committed
2 3
# lalsuite_gccflags.m4 - macros to set strict gcc flags
#
4 5 6 7 8 9 10 11 12 13 14 15 16 17
# serial 17

AC_DEFUN([LALSUITE_ENABLE_GCC_FLAGS],[
  # $0: enable GCC warning flags
  AC_ARG_ENABLE([gcc_flags],
    AC_HELP_STRING([--enable-gcc-flags],[turn on strict GCC warning flags [default=yes]]),
    AS_CASE(["${enableval}"],
      [yes|no],[:],
      AC_MSG_ERROR([bad value '${enableval}' for --enable-gcc-flags])
    ),[
      enable_gcc_flags=yes
    ]
  )
  # end $0
Adam Mercer's avatar
Adam Mercer committed
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
AC_DEFUN([LALSUITE_ADD_GCC_FLAGS],[
  # $0: add GCC warning flags
  AS_IF([test "x${GCC}" = xyes && test "x${enable_gcc_flags}" = xyes],[

    gcc_flags="-g3 -Wall -W -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -fno-common -Wnested-externs -Wno-format-zero-length -fno-strict-aliasing"

    # check if compiler supports -Wno-unused-result
    LALSUITE_PUSH_UVARS
    LALSUITE_CLEAR_UVARS
    CFLAGS="-Wno-unused-result"
    AC_MSG_CHECKING([whether compiler supports -Wno-unused-result])
    AC_COMPILE_IFELSE([
      AC_LANG_PROGRAM([])
    ],[
      AC_MSG_RESULT([yes])
      gcc_flags="${gcc_flags} -Wno-unused-result"
    ],[
      AC_MSG_RESULT([no])
    ])
    LALSUITE_POP_UVARS

    # don't use -Werror in LALApps
    AS_CASE([${PACKAGE}],
      [lalapps],[:],
      [gcc_flags="${gcc_flags} -Werror"]
    )
46

47 48 49
# comment out usage of -pedantic flag due to gcc bug 7263
# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7263
#
50
#  AS_CASE(["${host_cpu}-${host_os}"],
51 52 53
#      [*i386-darwin*], [gcc_flags="${gcc_flags} -pedantic"],
#      [*x86_64-darwin*], [gcc_flags="${gcc_flags} -pedantic"],
#      [gcc_flags="${gcc_flags} -pedantic-errors"])
54 55

    # add mac os x specific flags
56 57 58 59 60 61
    AS_IF([test "x${MACOSX_VERSION}" != "x"],[
      gcc_flags="${gcc_flags} -mmacosx-version-min=10.4"
    ])

    gcc_cflags="${gcc_flags}"
    gcc_cxxflags="${gcc_cxxflags}"
62

63
    # don't warn about unknown warning options for clang/clang++
64 65
    AS_IF([test -n "${CLANG_CC}"], [gcc_cflags="-Wno-unknown-warning-option ${gcc_cflags}"])
    AS_IF([test -n "${CLANG_CXX}"], [gcc_cxxflags="-Wno-unknown-warning-option ${gcc_cxxflags}"])
66

67
    # ignore unused flags with clang/clang++
68 69 70 71 72 73 74 75 76 77 78
    AS_IF([test -n "${CLANG_CC}"], [gcc_cflags="${gcc_cflags} -Xcompiler -Qunused-arguments"])
    AS_IF([test -n "${CLANG_CXX}"], [gcc_cxxflags="${gcc_cxxflags} -Xcompiler -Qunused-arguments"])

    # don't use gcc flags when cuda is enabled
    AS_IF([test "x${cuda}" = "xtrue"],[
      AC_MSG_NOTICE([CUDA support is enabled, disabling GCC flags])
    ],[
      LALSUITE_ADD_FLAGS([C],[${gcc_cflags}],[])
      LALSUITE_ADD_FLAGS([CXX],[${gcc_cxxflags}],[])
    ])

79
  ])
80
  # end $0
81
])