mirror of
https://github.com/claunia/flac.git
synced 2025-12-16 18:54:26 +00:00
configure.ac : Add hardening compile options.
Extra compile options are detected at configure time with new XIPH_ADD_*FLAGS m4 macros. Options enabled include -Wextra, -D_FORTIFY_SOURCE=2 and stack protection.
This commit is contained in:
@@ -356,6 +356,10 @@ fi
|
|||||||
|
|
||||||
XIPH_GCC_VERSION
|
XIPH_GCC_VERSION
|
||||||
|
|
||||||
|
XIPH_ADD_CFLAGS([-Wextra])
|
||||||
|
XIPH_ADD_CFLAGS([-D_FORTIFY_SOURCE=2])
|
||||||
|
XIPH_ADD_CFLAGS([-fstack-protector --param ssp-buffer-size=4])
|
||||||
|
|
||||||
if test x$ac_cv_c_compiler_gnu = xyes ; then
|
if test x$ac_cv_c_compiler_gnu = xyes ; then
|
||||||
if test x$enable_gcc_werror = "xyes" ; then
|
if test x$enable_gcc_werror = "xyes" ; then
|
||||||
CFLAGS="-Wall -Wextra -Werror $CFLAGS"
|
CFLAGS="-Wall -Wextra -Werror $CFLAGS"
|
||||||
|
|||||||
18
m4/add_cflags.m4
Normal file
18
m4/add_cflags.m4
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
dnl @synopsis XIPH_ADD_CFLAGS
|
||||||
|
dnl
|
||||||
|
dnl Add the given option to CFLAGS, if it doesn't break the compiler
|
||||||
|
|
||||||
|
AC_DEFUN([XIPH_ADD_CFLAGS],
|
||||||
|
[AC_MSG_CHECKING([if $CC accepts $1])
|
||||||
|
ac_add_cflags__old_cflags="$CFLAGS"
|
||||||
|
CFLAGS="$1"
|
||||||
|
AC_TRY_LINK([
|
||||||
|
#include <stdio.h>
|
||||||
|
],
|
||||||
|
[puts("Hello, World!"); return 0;],
|
||||||
|
AC_MSG_RESULT([yes])
|
||||||
|
CFLAGS="$ac_add_cflags__old_cflags $1",
|
||||||
|
AC_MSG_RESULT([no])
|
||||||
|
CFLAGS="$ac_add_cflags__old_cflags"
|
||||||
|
)
|
||||||
|
])# XIPH_ADD_CFLAGS
|
||||||
19
m4/add_cxxflags.m4
Normal file
19
m4/add_cxxflags.m4
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
dnl @synopsis XIPH_ADD_CXXFLAGS
|
||||||
|
dnl
|
||||||
|
dnl Add the given option to CXXFLAGS, if it doesn't break the compiler
|
||||||
|
|
||||||
|
AC_DEFUN([XIPH_ADD_CXXFLAGS],
|
||||||
|
[AC_MSG_CHECKING([if $CXX accepts $1])
|
||||||
|
AC_LANG_ASSERT([C++])
|
||||||
|
ac_add_cxxflags__old_cxxflags="$CXXFLAGS"
|
||||||
|
CXXFLAGS="$1"
|
||||||
|
AC_TRY_LINK([
|
||||||
|
#include <cstdio>
|
||||||
|
],
|
||||||
|
[puts("Hello, World!"); return 0;],
|
||||||
|
AC_MSG_RESULT([yes])
|
||||||
|
CXXFLAGS="$ac_add_cxxflags__old_cxxflags $1",
|
||||||
|
AC_MSG_RESULT([no])
|
||||||
|
CXXFLAGS="$ac_add_cxxflags__old_cxxflags"
|
||||||
|
)
|
||||||
|
])# XIPH_ADD_CXXFLAGS
|
||||||
Reference in New Issue
Block a user