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