|
Packit |
712bc5 |
# =============================================================================
|
|
Packit |
712bc5 |
# http://www.gnu.org/software/autoconf-archive/ax_compiler_flags_ldflags.html
|
|
Packit |
712bc5 |
# =============================================================================
|
|
Packit |
712bc5 |
#
|
|
Packit |
712bc5 |
# SYNOPSIS
|
|
Packit |
712bc5 |
#
|
|
Packit |
712bc5 |
# AX_COMPILER_FLAGS_LDFLAGS([VARIABLE], [IS-RELEASE], [EXTRA-BASE-FLAGS], [EXTRA-YES-FLAGS])
|
|
Packit |
712bc5 |
#
|
|
Packit |
712bc5 |
# DESCRIPTION
|
|
Packit |
712bc5 |
#
|
|
Packit |
712bc5 |
# Add warning flags for the linker to VARIABLE, which defaults to
|
|
Packit |
712bc5 |
# WARN_LDFLAGS. VARIABLE is AC_SUBST-ed by this macro, but must be
|
|
Packit |
712bc5 |
# manually added to the LDFLAGS variable for each target in the code base.
|
|
Packit |
712bc5 |
#
|
|
Packit |
712bc5 |
# This macro depends on the environment set up by AX_COMPILER_FLAGS.
|
|
Packit |
712bc5 |
# Specifically, it uses the value of $ax_enable_compile_warnings to decide
|
|
Packit |
712bc5 |
# which flags to enable.
|
|
Packit |
712bc5 |
#
|
|
Packit |
712bc5 |
# LICENSE
|
|
Packit |
712bc5 |
#
|
|
Packit |
712bc5 |
# Copyright (c) 2014, 2015 Philip Withnall <philip@tecnocode.co.uk>
|
|
Packit |
712bc5 |
#
|
|
Packit |
712bc5 |
# Copying and distribution of this file, with or without modification, are
|
|
Packit |
712bc5 |
# permitted in any medium without royalty provided the copyright notice
|
|
Packit |
712bc5 |
# and this notice are preserved. This file is offered as-is, without any
|
|
Packit |
712bc5 |
# warranty.
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
#serial 4
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
AC_DEFUN([AX_COMPILER_FLAGS_LDFLAGS],[
|
|
Packit |
712bc5 |
AX_REQUIRE_DEFINED([AX_APPEND_COMPILE_FLAGS])
|
|
Packit |
712bc5 |
AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
|
|
Packit |
712bc5 |
AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG])
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
# Variable names
|
|
Packit |
712bc5 |
m4_define(ax_warn_ldflags_variable,
|
|
Packit |
712bc5 |
[m4_normalize(ifelse([$1],,[WARN_LDFLAGS],[$1]))])
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
# Always pass -Werror=unknown-warning-option to get Clang to fail on bad
|
|
Packit |
712bc5 |
# flags, otherwise they are always appended to the warn_ldflags variable,
|
|
Packit |
712bc5 |
# and Clang warns on them for every compilation unit.
|
|
Packit |
712bc5 |
# If this is passed to GCC, it will explode, so the flag must be enabled
|
|
Packit |
712bc5 |
# conditionally.
|
|
Packit |
712bc5 |
AX_CHECK_COMPILE_FLAG([-Werror=unknown-warning-option],[
|
|
Packit |
712bc5 |
ax_compiler_flags_test="-Werror=unknown-warning-option"
|
|
Packit |
712bc5 |
],[
|
|
Packit |
712bc5 |
ax_compiler_flags_test=""
|
|
Packit |
712bc5 |
])
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
# Base flags
|
|
Packit |
712bc5 |
AX_APPEND_COMPILE_FLAGS([ dnl
|
|
Packit |
712bc5 |
-Wl,--no-as-needed dnl
|
|
Packit |
712bc5 |
$3 dnl
|
|
Packit |
712bc5 |
],ax_warn_ldflags_variable,[$ax_compiler_flags_test])
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
AS_IF([test "$ax_enable_compile_warnings" != "no"],[
|
|
Packit |
712bc5 |
# "yes" flags
|
|
Packit |
712bc5 |
AX_APPEND_COMPILE_FLAGS([$4 $5 $6 $7],
|
|
Packit |
712bc5 |
ax_warn_ldflags_variable,
|
|
Packit |
712bc5 |
[$ax_compiler_flags_test])
|
|
Packit |
712bc5 |
])
|
|
Packit |
712bc5 |
AS_IF([test "$ax_enable_compile_warnings" = "error"],[
|
|
Packit |
712bc5 |
# "error" flags; -Werror has to be appended unconditionally because
|
|
Packit |
712bc5 |
# it's not possible to test for
|
|
Packit |
712bc5 |
#
|
|
Packit |
712bc5 |
# suggest-attribute=format is disabled because it gives too many false
|
|
Packit |
712bc5 |
# positives
|
|
Packit |
712bc5 |
AX_APPEND_COMPILE_FLAGS([ dnl
|
|
Packit |
712bc5 |
-Wl,--fatal-warnings dnl
|
|
Packit |
712bc5 |
],ax_warn_ldflags_variable,[$ax_compiler_flags_test])
|
|
Packit |
712bc5 |
])
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
# Substitute the variables
|
|
Packit |
712bc5 |
AC_SUBST(ax_warn_ldflags_variable)
|
|
Packit |
712bc5 |
])dnl AX_COMPILER_FLAGS
|