| 1 | dnl lib-pathname.m4 -- 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 and a prefix, adds |
|---|
| 6 | dnl -Lprefix/lib, -Lprefix/lib32, or -Lprefix/lib64 to the variable depending |
|---|
| 7 | dnl on which directories exist and the size of a long in the compilation |
|---|
| 8 | dnl environment. |
|---|
| 9 | dnl |
|---|
| 10 | dnl Written by Russ Allbery <rra@stanford.edu> |
|---|
| 11 | dnl Copyright 2008 Board of Trustees, Leland Stanford Jr. University |
|---|
| 12 | dnl |
|---|
| 13 | dnl See LICENSE for licensing terms. |
|---|
| 14 | |
|---|
| 15 | dnl Probe for the alternate library name that we should attempt on this |
|---|
| 16 | dnl architecture, given the size of an int, and set rra_lib_arch_name to that |
|---|
| 17 | dnl name. Separated out so that it can be AC_REQUIRE'd and not run multiple |
|---|
| 18 | dnl times. |
|---|
| 19 | dnl |
|---|
| 20 | dnl There is an unfortunate abstraction violation here where we assume we know |
|---|
| 21 | dnl the cache variable name used by Autoconf. Unfortunately, Autoconf doesn't |
|---|
| 22 | dnl provide any other way of getting at that information in shell that I can |
|---|
| 23 | dnl see. |
|---|
| 24 | AC_DEFUN([_RRA_LIB_ARCH_NAME], |
|---|
| 25 | [rra_lib_arch_name=lib |
|---|
| 26 | AC_CHECK_SIZEOF([long]) |
|---|
| 27 | AS_IF([test "$ac_cv_sizeof_long" -eq 4 && test -d /usr/lib32], |
|---|
| 28 | [rra_lib_arch_name=lib32], |
|---|
| 29 | [AS_IF([test "$ac_cv_sizeof_long" -eq 8 && test -d /usr/lib64], |
|---|
| 30 | [rra_lib_arch_name=lib64])])]) |
|---|
| 31 | |
|---|
| 32 | dnl The public interface. Set VARIABLE to PREFIX/lib{,32,64} as appropriate. |
|---|
| 33 | AC_DEFUN([RRA_SET_LDFLAGS], |
|---|
| 34 | [AC_REQUIRE([_RRA_LIB_ARCH_NAME]) |
|---|
| 35 | AS_IF([test -d "$2/$rra_lib_arch_name"], |
|---|
| 36 | [$1="-L$2/$rra_lib_arch_name"], |
|---|
| 37 | [$1="-L$2/lib"])]) |
|---|