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