autotools: add --enable-werror option

This commit is contained in:
Anonymous Maarten 2022-10-06 19:17:18 +02:00 committed by Anonymous Maarten
parent 77822ed166
commit 335c672498
4 changed files with 259 additions and 0 deletions

91
configure vendored
View file

@ -902,6 +902,7 @@ enable_libsamplerate
enable_libsamplerate_shared enable_libsamplerate_shared
enable_arm_simd enable_arm_simd
enable_arm_neon enable_arm_neon
enable_werror
enable_video_wayland enable_video_wayland
enable_video_wayland_qt_touch enable_video_wayland_qt_touch
enable_wayland_shared enable_wayland_shared
@ -1703,6 +1704,7 @@ Optional Features:
dynamically load libsamplerate [default=yes] dynamically load libsamplerate [default=yes]
--enable-arm-simd use SIMD assembly blitters on ARM [default=no] --enable-arm-simd use SIMD assembly blitters on ARM [default=no]
--enable-arm-neon use NEON assembly blitters on ARM [default=no] --enable-arm-neon use NEON assembly blitters on ARM [default=no]
--enable-werror treat warnings as errors [default=no]
--enable-video-wayland use Wayland video driver [default=yes] --enable-video-wayland use Wayland video driver [default=yes]
--enable-video-wayland-qt-touch --enable-video-wayland-qt-touch
QtWayland server support for Wayland video driver QtWayland server support for Wayland video driver
@ -22952,6 +22954,86 @@ printf "%s\n" "$have_gcc_preferred_stack_boundary" >&6; }
fi fi
} }
CheckWerror()
{
# Check whether --enable-werror was given.
if test ${enable_werror+y}
then :
enableval=$enable_werror; enable_werror=$enableval
else $as_nop
enable_werror=no
fi
if test x$enable_werror = xyes; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GCC -Werror option" >&5
printf %s "checking for GCC -Werror option... " >&6; }
have_gcc_werror=no
save_CFLAGS="$CFLAGS"
CFLAGS="$save_CFLAGS -Werror"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int x = 0;
int
main (void)
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"
then :
have_gcc_werror=yes
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_gcc_werror" >&5
printf "%s\n" "$have_gcc_werror" >&6; }
CFLAGS="$save_CFLAGS"
if test x$have_gcc_werror = xyes; then
EXTRA_CFLAGS="$EXTRA_CFLAGS -Werror"
fi
fi
}
CheckNoErrorDeprecatedDeclarationsWerror()
{
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GCC -Werror option" >&5
printf %s "checking for GCC -Werror option... " >&6; }
have_gcc_no_werror_deprecated_declarations=no
save_CFLAGS="$CFLAGS"
CFLAGS="$save_CFLAGS -Wno-error=deprecated-declarations"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int x = 0;
int
main (void)
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"
then :
have_gcc_no_werror_deprecated_declarations=yes
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_gcc_werror" >&5
printf "%s\n" "$have_gcc_werror" >&6; }
CFLAGS="$save_CFLAGS"
if test x$have_gcc_no_werror_deprecated_declarations = xyes; then
EXTRA_CFLAGS="$EXTRA_CFLAGS -Wno-error=deprecated-declarations"
fi
}
CheckDeclarationAfterStatement() CheckDeclarationAfterStatement()
{ {
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GCC -Wdeclaration-after-statement option" >&5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GCC -Wdeclaration-after-statement option" >&5
@ -28315,6 +28397,7 @@ printf "%s\n" "#define SDL_VIDEO_DRIVER_ANDROID 1" >>confdefs.h
;; ;;
esac esac
CheckVisibilityHidden CheckVisibilityHidden
CheckWerror
CheckDeclarationAfterStatement CheckDeclarationAfterStatement
CheckDummyVideo CheckDummyVideo
CheckOffscreenVideo CheckOffscreenVideo
@ -28582,6 +28665,7 @@ printf "%s\n" "#define SDL_TIMER_UNIX 1" >>confdefs.h
have_loadso=yes have_loadso=yes
fi fi
CheckGDwarf4 CheckGDwarf4
CheckWerror
CheckDeclarationAfterStatement CheckDeclarationAfterStatement
CheckDummyVideo CheckDummyVideo
CheckOffscreenVideo CheckOffscreenVideo
@ -28905,6 +28989,8 @@ printf "%s\n" "#define SDL_FILESYSTEM_HAIKU 1" >>confdefs.h
ARCH=ios ARCH=ios
CheckVisibilityHidden CheckVisibilityHidden
CheckWerror
CheckNoErrorDeprecatedDeclarationsWerror
CheckDeclarationAfterStatement CheckDeclarationAfterStatement
CheckDummyVideo CheckDummyVideo
CheckOffscreenVideo CheckOffscreenVideo
@ -29042,6 +29128,8 @@ printf "%s\n" "#define SDL_VIDEO_RENDER_OGL_ES2 1" >>confdefs.h
CheckObjectiveCARC CheckObjectiveCARC
CheckVisibilityHidden CheckVisibilityHidden
CheckWerror
CheckNoErrorDeprecatedDeclarationsWerror
CheckDeclarationAfterStatement CheckDeclarationAfterStatement
CheckDummyVideo CheckDummyVideo
CheckOffscreenVideo CheckOffscreenVideo
@ -29187,6 +29275,7 @@ printf "%s\n" "#define SDL_AUDIO_DRIVER_EMSCRIPTEN 1" >>confdefs.h
fi fi
CheckVisibilityHidden CheckVisibilityHidden
CheckWerror
CheckDeclarationAfterStatement CheckDeclarationAfterStatement
CheckDummyVideo CheckDummyVideo
CheckOffscreenVideo CheckOffscreenVideo
@ -29246,6 +29335,7 @@ printf "%s\n" "#define SDL_TIMER_UNIX 1" >>confdefs.h
*-*-riscos*) *-*-riscos*)
ARCH=riscos ARCH=riscos
CheckVisibilityHidden CheckVisibilityHidden
CheckWerror
CheckDeclarationAfterStatement CheckDeclarationAfterStatement
CheckDummyVideo CheckDummyVideo
CheckOffscreenVideo CheckOffscreenVideo
@ -29302,6 +29392,7 @@ printf "%s\n" "#define SDL_TIMER_UNIX 1" >>confdefs.h
enable_static=no # disable static builds enable_static=no # disable static builds
EXTRA_CFLAGS="$EXTRA_CFLAGS -DBUILD_SDL -DOS2EMX_PLAIN_CHAR" EXTRA_CFLAGS="$EXTRA_CFLAGS -DBUILD_SDL -DOS2EMX_PLAIN_CHAR"
CheckOS2 CheckOS2
CheckWerror
CheckDeclarationAfterStatement CheckDeclarationAfterStatement
CheckDummyVideo CheckDummyVideo
CheckDiskAudio CheckDiskAudio

View file

@ -1595,6 +1595,49 @@ CheckStackBoundary()
fi fi
} }
dnl See if GCC's -Werror is supported.
CheckWerror()
{
AC_ARG_ENABLE(werror,
[AS_HELP_STRING([--enable-werror], [treat warnings as errors [default=no]])],
enable_werror=$enableval, enable_werror=no)
if test x$enable_werror = xyes; then
AC_MSG_CHECKING(for GCC -Werror option)
have_gcc_werror=no
save_CFLAGS="$CFLAGS"
CFLAGS="$save_CFLAGS -Werror"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
int x = 0;
]],[])], [have_gcc_werror=yes],[])
AC_MSG_RESULT($have_gcc_werror)
CFLAGS="$save_CFLAGS"
if test x$have_gcc_werror = xyes; then
EXTRA_CFLAGS="$EXTRA_CFLAGS -Werror"
fi
fi
}
dnl See if GCC's -Wno-error=deprecated-declarations is supported.
CheckNoErrorDeprecatedDeclarationsWerror()
{
AC_MSG_CHECKING(for GCC -Werror option)
have_gcc_no_werror_deprecated_declarations=no
save_CFLAGS="$CFLAGS"
CFLAGS="$save_CFLAGS -Wno-error=deprecated-declarations"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
int x = 0;
]],[])], [have_gcc_no_werror_deprecated_declarations=yes],[])
AC_MSG_RESULT($have_gcc_werror)
CFLAGS="$save_CFLAGS"
if test x$have_gcc_no_werror_deprecated_declarations = xyes; then
EXTRA_CFLAGS="$EXTRA_CFLAGS -Wno-error=deprecated-declarations"
fi
}
dnl See if GCC's -Wdeclaration-after-statement is supported. dnl See if GCC's -Wdeclaration-after-statement is supported.
dnl This lets us catch things that would fail on a C89 compiler when using dnl This lets us catch things that would fail on a C89 compiler when using
dnl a modern GCC. dnl a modern GCC.
@ -3761,6 +3804,7 @@ case "$host" in
;; ;;
esac esac
CheckVisibilityHidden CheckVisibilityHidden
CheckWerror
CheckDeclarationAfterStatement CheckDeclarationAfterStatement
CheckDummyVideo CheckDummyVideo
CheckOffscreenVideo CheckOffscreenVideo
@ -3994,6 +4038,7 @@ case "$host" in
have_loadso=yes have_loadso=yes
fi fi
CheckGDwarf4 CheckGDwarf4
CheckWerror
CheckDeclarationAfterStatement CheckDeclarationAfterStatement
CheckDummyVideo CheckDummyVideo
CheckOffscreenVideo CheckOffscreenVideo
@ -4218,6 +4263,8 @@ dnl BeOS support removed after SDL 2.0.1. Haiku still works. --ryan.
ARCH=ios ARCH=ios
CheckVisibilityHidden CheckVisibilityHidden
CheckWerror
CheckNoErrorDeprecatedDeclarationsWerror
CheckDeclarationAfterStatement CheckDeclarationAfterStatement
CheckDummyVideo CheckDummyVideo
CheckOffscreenVideo CheckOffscreenVideo
@ -4333,6 +4380,8 @@ dnl BeOS support removed after SDL 2.0.1. Haiku still works. --ryan.
CheckObjectiveCARC CheckObjectiveCARC
CheckVisibilityHidden CheckVisibilityHidden
CheckWerror
CheckNoErrorDeprecatedDeclarationsWerror
CheckDeclarationAfterStatement CheckDeclarationAfterStatement
CheckDummyVideo CheckDummyVideo
CheckOffscreenVideo CheckOffscreenVideo
@ -4458,6 +4507,7 @@ dnl BeOS support removed after SDL 2.0.1. Haiku still works. --ryan.
fi fi
CheckVisibilityHidden CheckVisibilityHidden
CheckWerror
CheckDeclarationAfterStatement CheckDeclarationAfterStatement
CheckDummyVideo CheckDummyVideo
CheckOffscreenVideo CheckOffscreenVideo
@ -4509,6 +4559,7 @@ dnl BeOS support removed after SDL 2.0.1. Haiku still works. --ryan.
*-*-riscos*) *-*-riscos*)
ARCH=riscos ARCH=riscos
CheckVisibilityHidden CheckVisibilityHidden
CheckWerror
CheckDeclarationAfterStatement CheckDeclarationAfterStatement
CheckDummyVideo CheckDummyVideo
CheckOffscreenVideo CheckOffscreenVideo
@ -4559,6 +4610,7 @@ dnl BeOS support removed after SDL 2.0.1. Haiku still works. --ryan.
enable_static=no # disable static builds enable_static=no # disable static builds
EXTRA_CFLAGS="$EXTRA_CFLAGS -DBUILD_SDL -DOS2EMX_PLAIN_CHAR" EXTRA_CFLAGS="$EXTRA_CFLAGS -DBUILD_SDL -DOS2EMX_PLAIN_CHAR"
CheckOS2 CheckOS2
CheckWerror
CheckDeclarationAfterStatement CheckDeclarationAfterStatement
CheckDummyVideo CheckDummyVideo
CheckDiskAudio CheckDiskAudio

78
test/configure vendored
View file

@ -701,6 +701,7 @@ with_sdl_prefix
with_sdl_exec_prefix with_sdl_exec_prefix
enable_sdltest enable_sdltest
with_x with_x
enable_werror
' '
ac_precious_vars='build_alias ac_precious_vars='build_alias
host_alias host_alias
@ -1344,6 +1345,7 @@ Optional Features:
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--disable-sdltest Do not try to compile and run a test SDL program --disable-sdltest Do not try to compile and run a test SDL program
--enable-werror treat warnings as errors [default=no]
Optional Packages: Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@ -4662,6 +4664,82 @@ if test x$have_opengl = xyes; then
OPENGL_TARGETS="TARGETS" OPENGL_TARGETS="TARGETS"
fi fi
# Check whether --enable-werror was given.
if test ${enable_werror+y}
then :
enableval=$enable_werror; enable_werror=$enableval
else $as_nop
enable_werror=no
fi
if test x$enable_werror = xyes; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GCC -Werror option" >&5
printf %s "checking for GCC -Werror option... " >&6; }
have_gcc_werror=no
save_CFLAGS="$CFLAGS"
CFLAGS="$save_CFLAGS -Werror"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int x = 0;
int
main (void)
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"
then :
have_gcc_werror=yes
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_gcc_werror" >&5
printf "%s\n" "$have_gcc_werror" >&6; }
CFLAGS="$save_CFLAGS"
if test x$have_gcc_werror = xyes; then
CFLAGS="$CFLAGS -Werror"
fi
fi
case "$host" in
*-ios-*|*-*-darwin* )
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GCC -Werror option" >&5
printf %s "checking for GCC -Werror option... " >&6; }
have_gcc_wno_error_deprecated_declarations=no
save_CFLAGS="$CFLAGS"
CFLAGS="$save_CFLAGS -Wno-error=deprecated-declarations"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int x = 0;
int
main (void)
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"
then :
have_gcc_wno_error_deprecated_declarations=yes
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_gcc_werror" >&5
printf "%s\n" "$have_gcc_werror" >&6; }
CFLAGS="$save_CFLAGS"
if test x$have_gcc_wno_error_deprecated_declarations = xyes; then
EXTRA_CFLAGS="$EXTRA_CFLAGS -Wno-error=deprecated-declarations"
fi
;;
esac

View file

@ -184,6 +184,44 @@ if test x$have_opengl = xyes; then
OPENGL_TARGETS="TARGETS" OPENGL_TARGETS="TARGETS"
fi fi
AC_ARG_ENABLE(werror,
[AS_HELP_STRING([--enable-werror], [treat warnings as errors [default=no]])],
enable_werror=$enableval, enable_werror=no)
if test x$enable_werror = xyes; then
AC_MSG_CHECKING(for GCC -Werror option)
have_gcc_werror=no
save_CFLAGS="$CFLAGS"
CFLAGS="$save_CFLAGS -Werror"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int x = 0;]],[])],
[have_gcc_werror=yes], [])
AC_MSG_RESULT($have_gcc_werror)
CFLAGS="$save_CFLAGS"
if test x$have_gcc_werror = xyes; then
CFLAGS="$CFLAGS -Werror"
fi
fi
case "$host" in
*-ios-*|*-*-darwin* )
AC_MSG_CHECKING(for GCC -Werror option)
have_gcc_wno_error_deprecated_declarations=no
save_CFLAGS="$CFLAGS"
CFLAGS="$save_CFLAGS -Wno-error=deprecated-declarations"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
int x = 0;
]],[])], [have_gcc_wno_error_deprecated_declarations=yes],[])
AC_MSG_RESULT($have_gcc_werror)
CFLAGS="$save_CFLAGS"
if test x$have_gcc_wno_error_deprecated_declarations = xyes; then
EXTRA_CFLAGS="$EXTRA_CFLAGS -Wno-error=deprecated-declarations"
fi
;;
esac
AC_SUBST(OPENGLES1_TARGETS) AC_SUBST(OPENGLES1_TARGETS)
AC_SUBST(OPENGLES2_TARGETS) AC_SUBST(OPENGLES2_TARGETS)
AC_SUBST(OPENGL_TARGETS) AC_SUBST(OPENGL_TARGETS)