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