xref: /aosp_15_r20/external/libxml2/m4/ax_check_link_flag.m4 (revision 7c5688314b92172186c154356a6374bf7684c3ca)
1*7c568831SAndroid Build Coastguard Worker# ===========================================================================
2*7c568831SAndroid Build Coastguard Worker#    https://www.gnu.org/software/autoconf-archive/ax_check_link_flag.html
3*7c568831SAndroid Build Coastguard Worker# ===========================================================================
4*7c568831SAndroid Build Coastguard Worker#
5*7c568831SAndroid Build Coastguard Worker# SYNOPSIS
6*7c568831SAndroid Build Coastguard Worker#
7*7c568831SAndroid Build Coastguard Worker#   AX_CHECK_LINK_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
8*7c568831SAndroid Build Coastguard Worker#
9*7c568831SAndroid Build Coastguard Worker# DESCRIPTION
10*7c568831SAndroid Build Coastguard Worker#
11*7c568831SAndroid Build Coastguard Worker#   Check whether the given FLAG works with the linker or gives an error.
12*7c568831SAndroid Build Coastguard Worker#   (Warnings, however, are ignored)
13*7c568831SAndroid Build Coastguard Worker#
14*7c568831SAndroid Build Coastguard Worker#   ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
15*7c568831SAndroid Build Coastguard Worker#   success/failure.
16*7c568831SAndroid Build Coastguard Worker#
17*7c568831SAndroid Build Coastguard Worker#   If EXTRA-FLAGS is defined, it is added to the linker's default flags
18*7c568831SAndroid Build Coastguard Worker#   when the check is done.  The check is thus made with the flags: "LDFLAGS
19*7c568831SAndroid Build Coastguard Worker#   EXTRA-FLAGS FLAG".  This can for example be used to force the linker to
20*7c568831SAndroid Build Coastguard Worker#   issue an error when a bad flag is given.
21*7c568831SAndroid Build Coastguard Worker#
22*7c568831SAndroid Build Coastguard Worker#   INPUT gives an alternative input source to AC_LINK_IFELSE.
23*7c568831SAndroid Build Coastguard Worker#
24*7c568831SAndroid Build Coastguard Worker#   NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
25*7c568831SAndroid Build Coastguard Worker#   macro in sync with AX_CHECK_{PREPROC,COMPILE}_FLAG.
26*7c568831SAndroid Build Coastguard Worker#
27*7c568831SAndroid Build Coastguard Worker# LICENSE
28*7c568831SAndroid Build Coastguard Worker#
29*7c568831SAndroid Build Coastguard Worker#   Copyright (c) 2008 Guido U. Draheim <[email protected]>
30*7c568831SAndroid Build Coastguard Worker#   Copyright (c) 2011 Maarten Bosmans <[email protected]>
31*7c568831SAndroid Build Coastguard Worker#
32*7c568831SAndroid Build Coastguard Worker#   Copying and distribution of this file, with or without modification, are
33*7c568831SAndroid Build Coastguard Worker#   permitted in any medium without royalty provided the copyright notice
34*7c568831SAndroid Build Coastguard Worker#   and this notice are preserved.  This file is offered as-is, without any
35*7c568831SAndroid Build Coastguard Worker#   warranty.
36*7c568831SAndroid Build Coastguard Worker
37*7c568831SAndroid Build Coastguard Worker#serial 6
38*7c568831SAndroid Build Coastguard Worker
39*7c568831SAndroid Build Coastguard WorkerAC_DEFUN([AX_CHECK_LINK_FLAG],
40*7c568831SAndroid Build Coastguard Worker[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
41*7c568831SAndroid Build Coastguard WorkerAS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_ldflags_$4_$1])dnl
42*7c568831SAndroid Build Coastguard WorkerAC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [
43*7c568831SAndroid Build Coastguard Worker  ax_check_save_flags=$LDFLAGS
44*7c568831SAndroid Build Coastguard Worker  LDFLAGS="$LDFLAGS $4 $1"
45*7c568831SAndroid Build Coastguard Worker  AC_LINK_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
46*7c568831SAndroid Build Coastguard Worker    [AS_VAR_SET(CACHEVAR,[yes])],
47*7c568831SAndroid Build Coastguard Worker    [AS_VAR_SET(CACHEVAR,[no])])
48*7c568831SAndroid Build Coastguard Worker  LDFLAGS=$ax_check_save_flags])
49*7c568831SAndroid Build Coastguard WorkerAS_VAR_IF(CACHEVAR,yes,
50*7c568831SAndroid Build Coastguard Worker  [m4_default([$2], :)],
51*7c568831SAndroid Build Coastguard Worker  [m4_default([$3], :)])
52*7c568831SAndroid Build Coastguard WorkerAS_VAR_POPDEF([CACHEVAR])dnl
53*7c568831SAndroid Build Coastguard Worker])dnl AX_CHECK_LINK_FLAGS
54