xref: /freebsd/contrib/pam-krb5/m4/ld-version.m4 (revision 4757b351ea9d59d71d4a38b82506d2d16fcd560d)
1dnl Check whether the linker supports --version-script.
2dnl
3dnl Probes whether the linker supports --version-script with a simple version
4dnl script that only defines a single version.  Sets the Automake conditional
5dnl HAVE_LD_VERSION_SCRIPT based on whether it is supported.
6dnl
7dnl The canonical version of this file is maintained in the rra-c-util
8dnl package, available at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
9dnl
10dnl Written by Russ Allbery <eagle@eyrie.org>
11dnl Based on the gnulib ld-version-script macro from Simon Josefsson
12dnl Copyright 2010
13dnl     The Board of Trustees of the Leland Stanford Junior University
14dnl Copyright 2008-2010 Free Software Foundation, Inc.
15dnl
16dnl This file is free software; the authors give unlimited permission to copy
17dnl and/or distribute it, with or without modifications, as long as this
18dnl notice is preserved.
19dnl
20dnl SPDX-License-Identifier: FSFULLR
21
22AC_DEFUN([RRA_LD_VERSION_SCRIPT],
23[AC_CACHE_CHECK([if -Wl,--version-script works], [rra_cv_ld_version_script],
24    [save_LDFLAGS="$LDFLAGS"
25     LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map"
26     cat > conftest.map <<EOF
27VERSION_1 {
28    global:
29        sym;
30
31    local:
32        *;
33};
34EOF
35     AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
36        [rra_cv_ld_version_script=yes], [rra_cv_ld_version_script=no])
37     rm -f conftest.map
38     LDFLAGS="$save_LDFLAGS"])
39 AM_CONDITIONAL([HAVE_LD_VERSION_SCRIPT],
40    [test x"$rra_cv_ld_version_script" = xyes])])
41