Import Upstream version 1.8.5
[hcoop/debian/openafs.git] / src / external / rra-c-util / m4 / lib-pathname.m4
1 dnl Determine the library path name.
2 dnl
3 dnl Red Hat systems and some other Linux systems use lib64 and lib32 rather
4 dnl than just lib in some circumstances. This file provides an Autoconf
5 dnl macro, RRA_SET_LDFLAGS, which given a variable, a prefix, and an optional
6 dnl suffix, adds -Lprefix/lib, -Lprefix/lib32, or -Lprefix/lib64 to the
7 dnl variable depending on which directories exist and the size of a long in
8 dnl the compilation environment. If a suffix is given, a slash and that
9 dnl suffix will be appended, to allow for adding a subdirectory of the library
10 dnl directory.
11 dnl
12 dnl This file also provides the Autoconf macro RRA_SET_LIBDIR, which sets the
13 dnl libdir variable to PREFIX/lib{,32,64} as appropriate.
14 dnl
15 dnl The canonical version of this file is maintained in the rra-c-util
16 dnl package, available at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
17 dnl
18 dnl Written by Russ Allbery <rra@stanford.edu>
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
26 dnl Probe for the alternate library name that we should attempt on this
27 dnl architecture, given the size of an int, and set rra_lib_arch_name to that
28 dnl name. Separated out so that it can be AC_REQUIRE'd and not run multiple
29 dnl times.
30 dnl
31 dnl There is an unfortunate abstraction violation here where we assume we know
32 dnl the cache variable name used by Autoconf. Unfortunately, Autoconf doesn't
33 dnl provide any other way of getting at that information in shell that I can
34 dnl see.
35 AC_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 && test -d /usr/lib32],
39 [rra_lib_arch_name=lib32],
40 [AS_IF([test "$ac_cv_sizeof_long" -eq 8 && test -d /usr/lib64],
41 [rra_lib_arch_name=lib64])])])
42
43 dnl Set VARIABLE to -LPREFIX/lib{,32,64} or -LPREFIX/lib{,32,64}/SUFFIX as
44 dnl appropriate.
45 AC_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=`echo "[$]$1" | sed -e 's/^ *//'`])
55
56 dnl Set libdir to PREFIX/lib{,32,64} as appropriate.
57 AC_DEFUN([RRA_SET_LIBDIR],
58 [AC_REQUIRE([_RRA_LIB_ARCH_NAME])
59 AS_IF([test -d "$1/$rra_lib_arch_name"],
60 [libdir="$1/${rra_lib_arch_name}"],
61 [libdir="$1/lib"])])