diff options
Diffstat (limited to 'm4/ax_compiler_flags_ldflags.m4')
-rw-r--r-- | m4/ax_compiler_flags_ldflags.m4 | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/m4/ax_compiler_flags_ldflags.m4 b/m4/ax_compiler_flags_ldflags.m4 index f9077fc..842e329 100644 --- a/m4/ax_compiler_flags_ldflags.m4 +++ b/m4/ax_compiler_flags_ldflags.m4 @@ -1,6 +1,6 @@ -# ============================================================================= -# http://www.gnu.org/software/autoconf-archive/ax_compiler_flags_ldflags.html -# ============================================================================= +# ============================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_compiler_flags_ldflags.html +# ============================================================================== # # SYNOPSIS # @@ -25,15 +25,16 @@ # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 3 +#serial 8 AC_DEFUN([AX_COMPILER_FLAGS_LDFLAGS],[ - AX_REQUIRE_DEFINED([AX_APPEND_COMPILE_FLAGS]) + AX_REQUIRE_DEFINED([AX_APPEND_LINK_FLAGS]) AX_REQUIRE_DEFINED([AX_APPEND_FLAG]) AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG]) + AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG]) # Variable names - m4_define(ax_warn_ldflags_variable, + m4_define([ax_warn_ldflags_variable], [m4_normalize(ifelse([$1],,[WARN_LDFLAGS],[$1]))]) # Always pass -Werror=unknown-warning-option to get Clang to fail on bad @@ -47,26 +48,42 @@ AC_DEFUN([AX_COMPILER_FLAGS_LDFLAGS],[ ax_compiler_flags_test="" ]) + # macOS linker does not have --as-needed + AX_CHECK_LINK_FLAG([-Wl,--no-as-needed], [ + ax_compiler_flags_as_needed_option="-Wl,--no-as-needed" + ], [ + ax_compiler_flags_as_needed_option="" + ]) + + # macOS linker speaks with a different accent + ax_compiler_flags_fatal_warnings_option="" + AX_CHECK_LINK_FLAG([-Wl,--fatal-warnings], [ + ax_compiler_flags_fatal_warnings_option="-Wl,--fatal-warnings" + ]) + AX_CHECK_LINK_FLAG([-Wl,-fatal_warnings], [ + ax_compiler_flags_fatal_warnings_option="-Wl,-fatal_warnings" + ]) + # Base flags - AX_APPEND_COMPILE_FLAGS([ dnl - -Wl,--no-as-needed dnl + AX_APPEND_LINK_FLAGS([ dnl + $ax_compiler_flags_as_needed_option dnl $3 dnl ],ax_warn_ldflags_variable,[$ax_compiler_flags_test]) AS_IF([test "$ax_enable_compile_warnings" != "no"],[ # "yes" flags - AX_APPEND_COMPILE_FLAGS([$4 $5 $6 $7], + AX_APPEND_LINK_FLAGS([$4 $5 $6 $7], ax_warn_ldflags_variable, [$ax_compiler_flags_test]) ]) AS_IF([test "$ax_enable_compile_warnings" = "error"],[ # "error" flags; -Werror has to be appended unconditionally because - # it’s not possible to test for + # it's not possible to test for # # suggest-attribute=format is disabled because it gives too many false # positives - AX_APPEND_COMPILE_FLAGS([ dnl - -Wl,--fatal-warnings dnl + AX_APPEND_LINK_FLAGS([ dnl + $ax_compiler_flags_fatal_warnings_option dnl ],ax_warn_ldflags_variable,[$ax_compiler_flags_test]) ]) |