1 1.1 riastrad # =========================================================================== 2 1.1 riastrad # https://www.gnu.org/software/autoconf-archive/ax_check_link_flag.html 3 1.1 riastrad # =========================================================================== 4 1.1 riastrad # 5 1.1 riastrad # SYNOPSIS 6 1.1 riastrad # 7 1.1 riastrad # AX_CHECK_LINK_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT]) 8 1.1 riastrad # 9 1.1 riastrad # DESCRIPTION 10 1.1 riastrad # 11 1.1 riastrad # Check whether the given FLAG works with the linker or gives an error. 12 1.1 riastrad # (Warnings, however, are ignored) 13 1.1 riastrad # 14 1.1 riastrad # ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on 15 1.1 riastrad # success/failure. 16 1.1 riastrad # 17 1.1 riastrad # If EXTRA-FLAGS is defined, it is added to the linker's default flags 18 1.1 riastrad # when the check is done. The check is thus made with the flags: "LDFLAGS 19 1.1 riastrad # EXTRA-FLAGS FLAG". This can for example be used to force the linker to 20 1.1 riastrad # issue an error when a bad flag is given. 21 1.1 riastrad # 22 1.1 riastrad # INPUT gives an alternative input source to AC_LINK_IFELSE. 23 1.1 riastrad # 24 1.1 riastrad # NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this 25 1.1 riastrad # macro in sync with AX_CHECK_{PREPROC,COMPILE}_FLAG. 26 1.1 riastrad # 27 1.1 riastrad # LICENSE 28 1.1 riastrad # 29 1.1 riastrad # Copyright (c) 2008 Guido U. Draheim <guidod (a] gmx.de> 30 1.1 riastrad # Copyright (c) 2011 Maarten Bosmans <mkbosmans (a] gmail.com> 31 1.1 riastrad # 32 1.1 riastrad # This program is free software: you can redistribute it and/or modify it 33 1.1 riastrad # under the terms of the GNU General Public License as published by the 34 1.1 riastrad # Free Software Foundation, either version 3 of the License, or (at your 35 1.1 riastrad # option) any later version. 36 1.1 riastrad # 37 1.1 riastrad # This program is distributed in the hope that it will be useful, but 38 1.1 riastrad # WITHOUT ANY WARRANTY; without even the implied warranty of 39 1.1 riastrad # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 40 1.1 riastrad # Public License for more details. 41 1.1 riastrad # 42 1.1 riastrad # You should have received a copy of the GNU General Public License along 43 1.1 riastrad # with this program. If not, see <https://www.gnu.org/licenses/>. 44 1.1 riastrad # 45 1.1 riastrad # As a special exception, the respective Autoconf Macro's copyright owner 46 1.1 riastrad # gives unlimited permission to copy, distribute and modify the configure 47 1.1 riastrad # scripts that are the output of Autoconf when processing the Macro. You 48 1.1 riastrad # need not follow the terms of the GNU General Public License when using 49 1.1 riastrad # or distributing such scripts, even though portions of the text of the 50 1.1 riastrad # Macro appear in them. The GNU General Public License (GPL) does govern 51 1.1 riastrad # all other use of the material that constitutes the Autoconf Macro. 52 1.1 riastrad # 53 1.1 riastrad # This special exception to the GPL applies to versions of the Autoconf 54 1.1 riastrad # Macro released by the Autoconf Archive. When you make and distribute a 55 1.1 riastrad # modified version of the Autoconf Macro, you may extend this special 56 1.1 riastrad # exception to the GPL to apply to your modified version as well. 57 1.1 riastrad 58 1.1 riastrad #serial 5 59 1.1 riastrad 60 1.1 riastrad AC_DEFUN([AX_CHECK_LINK_FLAG], 61 1.1 riastrad [AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF 62 1.1 riastrad AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_ldflags_$4_$1])dnl 63 1.1 riastrad AC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [ 64 1.1 riastrad ax_check_save_flags=$LDFLAGS 65 1.1 riastrad LDFLAGS="$LDFLAGS $4 $1" 66 1.1 riastrad AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], 67 1.1 riastrad [[time_t x; int fodder = 0; if (fodder > -1000 && time(&x)) return (int) x]])], 68 1.1 riastrad [AS_VAR_SET(CACHEVAR,[yes])], 69 1.1 riastrad [AS_VAR_SET(CACHEVAR,[no])]) 70 1.1 riastrad LDFLAGS=$ax_check_save_flags]) 71 1.1 riastrad AS_VAR_IF(CACHEVAR,yes, 72 1.1 riastrad [m4_default([$2], :)], 73 1.1 riastrad [m4_default([$3], :)]) 74 1.1 riastrad AS_VAR_POPDEF([CACHEVAR])dnl 75 1.1 riastrad ])dnl AX_CHECK_LINK_FLAGS 76