xref: /freebsd/contrib/pam-krb5/m4/lib-pathname.m4 (revision 4b15965daa99044daf184221b7c283bf7f2d7e66)
1dnl Determine the library path name.
2dnl
3dnl Red Hat systems and some other Linux systems use lib64 and lib32 rather
4dnl than just lib in some circumstances.  This file provides an Autoconf
5dnl macro, RRA_SET_LDFLAGS, which given a variable, a prefix, and an optional
6dnl suffix, adds -Lprefix/lib, -Lprefix/lib32, or -Lprefix/lib64 to the
7dnl variable depending on which directories exist and the size of a long in
8dnl the compilation environment.  If a suffix is given, a slash and that
9dnl suffix will be appended, to allow for adding a subdirectory of the library
10dnl directory.
11dnl
12dnl The canonical version of this file is maintained in the rra-c-util
13dnl package, available at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
14dnl
15dnl Written by Russ Allbery <eagle@eyrie.org>
16dnl Copyright 2021 Russ Allbery <eagle@eyrie.org>
17dnl Copyright 2008-2009
18dnl     The Board of Trustees of the Leland Stanford Junior University
19dnl
20dnl This file is free software; the authors give unlimited permission to copy
21dnl and/or distribute it, with or without modifications, as long as this
22dnl notice is preserved.
23dnl
24dnl SPDX-License-Identifier: FSFULLR
25
26dnl Probe for the alternate library name that we should attempt on this
27dnl architecture, given the size of an int, and set rra_lib_arch_name to that
28dnl name.  Separated out so that it can be AC_REQUIRE'd and not run multiple
29dnl times.
30dnl
31dnl There is an unfortunate abstraction violation here where we assume we know
32dnl the cache variable name used by Autoconf.  Unfortunately, Autoconf doesn't
33dnl provide any other way of getting at that information in shell that I can
34dnl see.
35AC_DEFUN([_RRA_LIB_ARCH_NAME],
36[rra_lib_arch_name=lib
37 AC_CHECK_SIZEOF([long])
38 AS_IF([test "$ac_cv_sizeof_long" -eq 4],
39     [rra_lib_arch_name=lib32],
40     [AS_IF([test "$ac_cv_sizeof_long" -eq 8],
41         [rra_lib_arch_name=lib64])])])
42
43dnl Set VARIABLE to -LPREFIX/lib{,32,64} or -LPREFIX/lib{,32,64}/SUFFIX as
44dnl appropriate.
45AC_DEFUN([RRA_SET_LDFLAGS],
46[AC_REQUIRE([_RRA_LIB_ARCH_NAME])
47 AS_IF([test -d "$2/$rra_lib_arch_name"],
48    [AS_IF([test x"$3" = x],
49        [$1="[$]$1 -L$2/${rra_lib_arch_name}"],
50        [$1="[$]$1 -L$2/${rra_lib_arch_name}/$3"])],
51    [AS_IF([test x"$3" = x],
52        [$1="[$]$1 -L$2/lib"],
53        [$1="[$]$1 -L$2/lib/$3"])])
54 $1=`AS_ECHO(["[$]$1"]) | sed -e 's/^ *//'`])
55