Skip to content

Commit 4f5a46d

Browse files
committed
configure.ac: Detect GCC's -fdiagnostics-show-caret. Detect GCC's
-ftrack-macro-expansion when configured with --enable-debugging.
1 parent 767e75d commit 4f5a46d

File tree

2 files changed

+133
-3
lines changed

2 files changed

+133
-3
lines changed

configure

Lines changed: 129 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5255,7 +5255,71 @@ $as_echo "$ac_cv_path_GREP" >&6; }
52555255

52565256
case $ax_cv_cxx_compiler_vendor in #(
52575257
gnu|clang) :
5258-
if test "x$enable_warnings" = "xyes"; then :
5258+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking CXXFLAGS for gcc -fdiagnostics-show-caret" >&5
5259+
$as_echo_n "checking CXXFLAGS for gcc -fdiagnostics-show-caret... " >&6; }
5260+
if ${ax_cv_cxxflags_gcc_option__fdiagnostics_show_caret+:} false; then :
5261+
$as_echo_n "(cached) " >&6
5262+
else
5263+
ax_cv_cxxflags_gcc_option__fdiagnostics_show_caret="no, unknown"
5264+
5265+
ac_ext=cpp
5266+
ac_cpp='$CXXCPP $CPPFLAGS'
5267+
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
5268+
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
5269+
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
5270+
5271+
ac_save_CXXFLAGS="$CXXFLAGS"
5272+
for ac_arg in "-pedantic -Werror % -fdiagnostics-show-caret" "-pedantic % -fdiagnostics-show-caret %% no, obsolete" #
5273+
do CXXFLAGS="$ac_save_CXXFLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
5274+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5275+
/* end confdefs.h. */
5276+
5277+
int
5278+
main ()
5279+
{
5280+
return 0;
5281+
;
5282+
return 0;
5283+
}
5284+
_ACEOF
5285+
if ac_fn_cxx_try_compile "$LINENO"; then :
5286+
ax_cv_cxxflags_gcc_option__fdiagnostics_show_caret=`echo $ac_arg | sed -e 's,.*% *,,'`; break
5287+
fi
5288+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
5289+
done
5290+
CXXFLAGS="$ac_save_CXXFLAGS"
5291+
ac_ext=cpp
5292+
ac_cpp='$CXXCPP $CPPFLAGS'
5293+
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
5294+
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
5295+
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
5296+
5297+
5298+
fi
5299+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxxflags_gcc_option__fdiagnostics_show_caret" >&5
5300+
$as_echo "$ax_cv_cxxflags_gcc_option__fdiagnostics_show_caret" >&6; }
5301+
var=$ax_cv_cxxflags_gcc_option__fdiagnostics_show_caret
5302+
case ".$var" in
5303+
.ok|.ok,*) ;;
5304+
.|.no|.no,*) ;;
5305+
*)
5306+
if echo " $CXXFLAGS " | grep " $var " 2>&1 >/dev/null
5307+
then { { $as_echo "$as_me:${as_lineno-$LINENO}: : CXXFLAGS does contain \$var"; } >&5
5308+
(: CXXFLAGS does contain $var) 2>&5
5309+
ac_status=$?
5310+
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
5311+
test $ac_status = 0; }
5312+
else { { $as_echo "$as_me:${as_lineno-$LINENO}: : CXXFLAGS=\"\$CXXFLAGS \$var\""; } >&5
5313+
(: CXXFLAGS="$CXXFLAGS $var") 2>&5
5314+
ac_status=$?
5315+
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
5316+
test $ac_status = 0; }
5317+
CXXFLAGS="$CXXFLAGS $var"
5318+
fi
5319+
;;
5320+
esac
5321+
5322+
if test "x$enable_warnings" = "xyes"; then :
52595323
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking CXXFLAGS for gcc -Wextra" >&5
52605324
$as_echo_n "checking CXXFLAGS for gcc -Wextra... " >&6; }
52615325
if ${ax_cv_cxxflags_gcc_option__Wextra+:} false; then :
@@ -6465,6 +6529,70 @@ fi
64656529
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxxflags_gcc_option__ftrapv" >&5
64666530
$as_echo "$ax_cv_cxxflags_gcc_option__ftrapv" >&6; }
64676531
var=$ax_cv_cxxflags_gcc_option__ftrapv
6532+
case ".$var" in
6533+
.ok|.ok,*) ;;
6534+
.|.no|.no,*) ;;
6535+
*)
6536+
if echo " $CXXFLAGS " | grep " $var " 2>&1 >/dev/null
6537+
then { { $as_echo "$as_me:${as_lineno-$LINENO}: : CXXFLAGS does contain \$var"; } >&5
6538+
(: CXXFLAGS does contain $var) 2>&5
6539+
ac_status=$?
6540+
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
6541+
test $ac_status = 0; }
6542+
else { { $as_echo "$as_me:${as_lineno-$LINENO}: : CXXFLAGS=\"\$CXXFLAGS \$var\""; } >&5
6543+
(: CXXFLAGS="$CXXFLAGS $var") 2>&5
6544+
ac_status=$?
6545+
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
6546+
test $ac_status = 0; }
6547+
CXXFLAGS="$CXXFLAGS $var"
6548+
fi
6549+
;;
6550+
esac
6551+
6552+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking CXXFLAGS for gcc -ftrack-macro-expansion" >&5
6553+
$as_echo_n "checking CXXFLAGS for gcc -ftrack-macro-expansion... " >&6; }
6554+
if ${ax_cv_cxxflags_gcc_option__ftrack_macro_expansion+:} false; then :
6555+
$as_echo_n "(cached) " >&6
6556+
else
6557+
ax_cv_cxxflags_gcc_option__ftrack_macro_expansion="no, unknown"
6558+
6559+
ac_ext=cpp
6560+
ac_cpp='$CXXCPP $CPPFLAGS'
6561+
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
6562+
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
6563+
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
6564+
6565+
ac_save_CXXFLAGS="$CXXFLAGS"
6566+
for ac_arg in "-pedantic -Werror % -ftrack-macro-expansion" "-pedantic % -ftrack-macro-expansion %% no, obsolete" #
6567+
do CXXFLAGS="$ac_save_CXXFLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
6568+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
6569+
/* end confdefs.h. */
6570+
6571+
int
6572+
main ()
6573+
{
6574+
return 0;
6575+
;
6576+
return 0;
6577+
}
6578+
_ACEOF
6579+
if ac_fn_cxx_try_compile "$LINENO"; then :
6580+
ax_cv_cxxflags_gcc_option__ftrack_macro_expansion=`echo $ac_arg | sed -e 's,.*% *,,'`; break
6581+
fi
6582+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
6583+
done
6584+
CXXFLAGS="$ac_save_CXXFLAGS"
6585+
ac_ext=cpp
6586+
ac_cpp='$CXXCPP $CPPFLAGS'
6587+
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
6588+
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
6589+
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
6590+
6591+
6592+
fi
6593+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxxflags_gcc_option__ftrack_macro_expansion" >&5
6594+
$as_echo "$ax_cv_cxxflags_gcc_option__ftrack_macro_expansion" >&6; }
6595+
var=$ax_cv_cxxflags_gcc_option__ftrack_macro_expansion
64686596
case ".$var" in
64696597
.ok|.ok,*) ;;
64706598
.|.no|.no,*) ;;

configure.ac

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ AS_IF([test "x$enable_warnings" = "xyes"],
149149

150150
AS_CASE([$ax_cv_cxx_compiler_vendor],
151151
[gnu|clang],
152-
[AS_IF([test "x$enable_warnings" = "xyes"],
152+
[AX_CXXFLAGS_GCC_OPTION([-fdiagnostics-show-caret])
153+
AS_IF([test "x$enable_warnings" = "xyes"],
153154
[AX_CXXFLAGS_GCC_OPTION([-Wextra])
154155
dnl The -ansi switch sets __STRICT_ANSI__ which disables some
155156
dnl useful function declarations in MinGW and Cygwin headers.
@@ -188,7 +189,8 @@ AS_CASE([$ax_cv_cxx_compiler_vendor],
188189
AX_CXXFLAGS_GCC_OPTION([-fstack-protector])])
189190
dnl -Wstack-protector results into not too interesting warnings.
190191
dnl AX_CXXFLAGS_GCC_OPTION([-Wstack-protector])
191-
AX_CXXFLAGS_GCC_OPTION([-ftrapv])],
192+
AX_CXXFLAGS_GCC_OPTION([-ftrapv])
193+
AX_CXXFLAGS_GCC_OPTION([-ftrack-macro-expansion])],
192194
[AC_REQUIRE([AC_PROG_GREP])
193195
AS_IF([AS_ECHO_N(["$CXXFLAGS"]) dnl
194196
| $GREP -e ['\(^\|[[:space:]]\)-O\([^[:space:]]*\([[:space:]]\|$\)\)'] >/dev/null],

0 commit comments

Comments
 (0)