1 dnl Determine the library path name.
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
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.
15 dnl Written by Russ Allbery <rra@stanford.edu>
16 dnl Copyright 2008, 2009 Board of Trustees, Leland Stanford Jr. University
18 dnl See LICENSE for licensing terms.
20 dnl Probe for the alternate library name that we should attempt on this
21 dnl architecture, given the size of an int, and set rra_lib_arch_name to that
22 dnl name. Separated out so that it can be AC_REQUIRE'd and not run multiple
25 dnl There is an unfortunate abstraction violation here where we assume we know
26 dnl the cache variable name used by Autoconf. Unfortunately, Autoconf doesn't
27 dnl provide any other way of getting at that information in shell that I can
29 AC_DEFUN([_RRA_LIB_ARCH_NAME],
30 [rra_lib_arch_name=lib
31 AC_CHECK_SIZEOF([long])
32 AS_IF([test "$ac_cv_sizeof_long" -eq 4 && test -d /usr/lib32],
33 [rra_lib_arch_name=lib32],
34 [AS_IF([test "$ac_cv_sizeof_long" -eq 8 && test -d /usr/lib64],
35 [rra_lib_arch_name=lib64])])])
37 dnl Set VARIABLE to -LPREFIX/lib{,32,64} or -LPREFIX/lib{,32,64}/SUFFIX as
39 AC_DEFUN([RRA_SET_LDFLAGS],
40 [AC_REQUIRE([_RRA_LIB_ARCH_NAME])
41 AS_IF([test -d "$2/$rra_lib_arch_name"],
42 [AS_IF([test x"$3" = x],
43 [$1="[$]$1 -L$2/${rra_lib_arch_name}"],
44 [$1="[$]$1 -L$2/${rra_lib_arch_name}/$3"])],
45 [AS_IF([test x"$3" = x],
46 [$1="[$]$1 -L$2/lib"],
47 [$1="[$]$1 -L$2/lib/$3"])])
48 $1=`echo "[$]$1" | sed -e 's/^ *//'`])
50 dnl Set libdir to PREFIX/lib{,32,64} as appropriate.
51 AC_DEFUN([RRA_SET_LIBDIR],
52 [AC_REQUIRE([_RRA_LIB_ARCH_NAME])
53 AS_IF([test -d "$1/$rra_lib_arch_name"],
54 [libdir="$1/${rra_lib_arch_name}"],