annotate src/opus-1.3/m4/ax_add_fortify_source.m4 @ 169:223a55898ab9 tip default

Add null config files
author Chris Cannam <cannam@all-day-breakfast.com>
date Mon, 02 Mar 2020 14:03:47 +0000
parents 4664ac0c1032
children
rev   line source
cannam@154 1 # ===========================================================================
cannam@154 2 # Modified from https://www.gnu.org/software/autoconf-archive/ax_add_fortify_source.html
cannam@154 3 # ===========================================================================
cannam@154 4 #
cannam@154 5 # SYNOPSIS
cannam@154 6 #
cannam@154 7 # AX_ADD_FORTIFY_SOURCE
cannam@154 8 #
cannam@154 9 # DESCRIPTION
cannam@154 10 #
cannam@154 11 # Check whether -D_FORTIFY_SOURCE=2 can be added to CFLAGS without macro
cannam@154 12 # redefinition warnings. Some distributions (such as Gentoo Linux) enable
cannam@154 13 # _FORTIFY_SOURCE globally in their compilers, leading to unnecessary
cannam@154 14 # warnings in the form of
cannam@154 15 #
cannam@154 16 # <command-line>:0:0: error: "_FORTIFY_SOURCE" redefined [-Werror]
cannam@154 17 # <built-in>: note: this is the location of the previous definition
cannam@154 18 #
cannam@154 19 # which is a problem if -Werror is enabled. This macro checks whether
cannam@154 20 # _FORTIFY_SOURCE is already defined, and if not, adds -D_FORTIFY_SOURCE=2
cannam@154 21 # to CFLAGS.
cannam@154 22 #
cannam@154 23 # LICENSE
cannam@154 24 #
cannam@154 25 # Copyright (c) 2017 David Seifert <soap@gentoo.org>
cannam@154 26 #
cannam@154 27 # Copying and distribution of this file, with or without modification, are
cannam@154 28 # permitted in any medium without royalty provided the copyright notice
cannam@154 29 # and this notice are preserved. This file is offered as-is, without any
cannam@154 30 # warranty.
cannam@154 31
cannam@154 32 #serial 1
cannam@154 33
cannam@154 34 AC_DEFUN([AX_ADD_FORTIFY_SOURCE],[
cannam@154 35 AC_MSG_CHECKING([whether to add -D_FORTIFY_SOURCE=2 to CFLAGS])
cannam@154 36 AC_LINK_IFELSE([
cannam@154 37 AC_LANG_SOURCE(
cannam@154 38 [[
cannam@154 39 int main() {
cannam@154 40 #ifndef _FORTIFY_SOURCE
cannam@154 41 return 0;
cannam@154 42 #else
cannam@154 43 this_is_an_error;
cannam@154 44 #endif
cannam@154 45 }
cannam@154 46 ]]
cannam@154 47 )], [
cannam@154 48 AC_MSG_RESULT([yes])
cannam@154 49 CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
cannam@154 50 ], [
cannam@154 51 AC_MSG_RESULT([no])
cannam@154 52 ])
cannam@154 53 ])