1 # Macros to check compiler options
4 # Helper function that adds flags (words) to variable listing them.
5 # Makes sure there is no extra spaces in any situation
7 # $1 - Name of the target variable
10 AC_DEFUN([FC_ADD_WORDS_TO_VAR],
12 old_value="`eval echo '$'$1`"
13 if test "x$old_value" = "x" ; then
15 elif test "x$2" != "x" ; then
20 # Check if compiler supports given commandline parameter in language specific
21 # variable. If it does, it will be concatenated to variable. If several
22 # parameters are given, they are tested, and added to target variable,
26 # $2 - Language specific variable
27 # $3 - Parameters to test
28 # $4 - Additional parameters
29 # $5 - Variable where to add
32 AC_DEFUN([FC_COMPILER_FLAGS],
36 flags_save="`eval echo '$'$2`"
38 existing_flags="`eval echo '$'$5`"
42 dnl We need -Werror to test any flags (it can't be tested itself)
43 dnl Without it, illegal flag will not give an error for us to detect
44 $2="-Werror $flags_save $existing_flags $accepted_flags $flag $4"
45 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int a;])],
46 [FC_ADD_WORDS_TO_VAR([accepted_flags], [$flag])])
48 FC_ADD_WORDS_TO_VAR([$5], [$accepted_flags])
55 # Commandline flag tests for C and C++
58 # $1 - Parameters to test
59 # $2 - Additional parameters
60 # $3 - Variable where to add
62 AC_DEFUN([FC_C_FLAGS],
64 FC_COMPILER_FLAGS([C], [CFLAGS], [$1], [$2], [$3])
68 AC_DEFUN([FC_CXX_FLAGS],
70 FC_COMPILER_FLAGS([C++], [CXXFLAGS], [$1], [$2], [$3])
73 # Commandline flag tests for linker
76 # $1 - Parameters to test
77 # $2 - Additional parameters
78 # $3 - Variable where to add
79 AC_DEFUN([FC_LD_FLAGS],
83 existing_flags="`eval echo '$'$3`"
87 LDFLAGS="$flags_save $existing_flags $accepted_flags $flag $2"
88 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [int a;])],
89 [FC_ADD_WORDS_TO_VAR([accepted_flags], [$flag])])
91 FC_ADD_WORDS_TO_VAR([$3], [$accepted_flags])
96 # Does current C++ compiler work.
97 # Sets variable cxx_works accordingly.
98 AC_DEFUN([FC_WORKING_CXX],
100 AC_MSG_CHECKING([whether C++ compiler works])
104 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],