Math Processor Unit Library

libmpu – library of arithmetic functions for integer, real, and complex numbers of increased digit capacity

16 Commits   0 Branches   2 Tags
868b2b66 (kx 2024-12-20 16:11:07 +0300   1) # lib-prefix.m4 serial 17
868b2b66 (kx 2024-12-20 16:11:07 +0300   2) dnl Copyright (C) 2001-2005, 2008-2020 Free Software Foundation, Inc.
868b2b66 (kx 2024-12-20 16:11:07 +0300   3) dnl This file is free software; the Free Software Foundation
868b2b66 (kx 2024-12-20 16:11:07 +0300   4) dnl gives unlimited permission to copy and/or distribute it,
868b2b66 (kx 2024-12-20 16:11:07 +0300   5) dnl with or without modifications, as long as this notice is preserved.
868b2b66 (kx 2024-12-20 16:11:07 +0300   6) 
868b2b66 (kx 2024-12-20 16:11:07 +0300   7) dnl From Bruno Haible.
868b2b66 (kx 2024-12-20 16:11:07 +0300   8) 
868b2b66 (kx 2024-12-20 16:11:07 +0300   9) dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed
868b2b66 (kx 2024-12-20 16:11:07 +0300  10) dnl to access previously installed libraries. The basic assumption is that
868b2b66 (kx 2024-12-20 16:11:07 +0300  11) dnl a user will want packages to use other packages he previously installed
868b2b66 (kx 2024-12-20 16:11:07 +0300  12) dnl with the same --prefix option.
868b2b66 (kx 2024-12-20 16:11:07 +0300  13) dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate
868b2b66 (kx 2024-12-20 16:11:07 +0300  14) dnl libraries, but is otherwise very convenient.
868b2b66 (kx 2024-12-20 16:11:07 +0300  15) AC_DEFUN([AC_LIB_PREFIX],
868b2b66 (kx 2024-12-20 16:11:07 +0300  16) [
868b2b66 (kx 2024-12-20 16:11:07 +0300  17)   AC_BEFORE([$0], [AC_LIB_LINKFLAGS])
868b2b66 (kx 2024-12-20 16:11:07 +0300  18)   AC_REQUIRE([AC_PROG_CC])
868b2b66 (kx 2024-12-20 16:11:07 +0300  19)   AC_REQUIRE([AC_CANONICAL_HOST])
868b2b66 (kx 2024-12-20 16:11:07 +0300  20)   AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
868b2b66 (kx 2024-12-20 16:11:07 +0300  21)   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
868b2b66 (kx 2024-12-20 16:11:07 +0300  22)   dnl By default, look in $includedir and $libdir.
868b2b66 (kx 2024-12-20 16:11:07 +0300  23)   use_additional=yes
868b2b66 (kx 2024-12-20 16:11:07 +0300  24)   AC_LIB_WITH_FINAL_PREFIX([
868b2b66 (kx 2024-12-20 16:11:07 +0300  25)     eval additional_includedir=\"$includedir\"
868b2b66 (kx 2024-12-20 16:11:07 +0300  26)     eval additional_libdir=\"$libdir\"
868b2b66 (kx 2024-12-20 16:11:07 +0300  27)   ])
868b2b66 (kx 2024-12-20 16:11:07 +0300  28)   AC_ARG_WITH([lib-prefix],
868b2b66 (kx 2024-12-20 16:11:07 +0300  29) [[  --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib
868b2b66 (kx 2024-12-20 16:11:07 +0300  30)   --without-lib-prefix    don't search for libraries in includedir and libdir]],
868b2b66 (kx 2024-12-20 16:11:07 +0300  31) [
868b2b66 (kx 2024-12-20 16:11:07 +0300  32)     if test "X$withval" = "Xno"; then
868b2b66 (kx 2024-12-20 16:11:07 +0300  33)       use_additional=no
868b2b66 (kx 2024-12-20 16:11:07 +0300  34)     else
868b2b66 (kx 2024-12-20 16:11:07 +0300  35)       if test "X$withval" = "X"; then
868b2b66 (kx 2024-12-20 16:11:07 +0300  36)         AC_LIB_WITH_FINAL_PREFIX([
868b2b66 (kx 2024-12-20 16:11:07 +0300  37)           eval additional_includedir=\"$includedir\"
868b2b66 (kx 2024-12-20 16:11:07 +0300  38)           eval additional_libdir=\"$libdir\"
868b2b66 (kx 2024-12-20 16:11:07 +0300  39)         ])
868b2b66 (kx 2024-12-20 16:11:07 +0300  40)       else
868b2b66 (kx 2024-12-20 16:11:07 +0300  41)         additional_includedir="$withval/include"
868b2b66 (kx 2024-12-20 16:11:07 +0300  42)         additional_libdir="$withval/$acl_libdirstem"
868b2b66 (kx 2024-12-20 16:11:07 +0300  43)       fi
868b2b66 (kx 2024-12-20 16:11:07 +0300  44)     fi
868b2b66 (kx 2024-12-20 16:11:07 +0300  45) ])
868b2b66 (kx 2024-12-20 16:11:07 +0300  46)   if test $use_additional = yes; then
868b2b66 (kx 2024-12-20 16:11:07 +0300  47)     dnl Potentially add $additional_includedir to $CPPFLAGS.
868b2b66 (kx 2024-12-20 16:11:07 +0300  48)     dnl But don't add it
868b2b66 (kx 2024-12-20 16:11:07 +0300  49)     dnl   1. if it's the standard /usr/include,
868b2b66 (kx 2024-12-20 16:11:07 +0300  50)     dnl   2. if it's already present in $CPPFLAGS,
868b2b66 (kx 2024-12-20 16:11:07 +0300  51)     dnl   3. if it's /usr/local/include and we are using GCC on Linux,
868b2b66 (kx 2024-12-20 16:11:07 +0300  52)     dnl   4. if it doesn't exist as a directory.
868b2b66 (kx 2024-12-20 16:11:07 +0300  53)     if test "X$additional_includedir" != "X/usr/include"; then
868b2b66 (kx 2024-12-20 16:11:07 +0300  54)       haveit=
868b2b66 (kx 2024-12-20 16:11:07 +0300  55)       for x in $CPPFLAGS; do
868b2b66 (kx 2024-12-20 16:11:07 +0300  56)         AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
868b2b66 (kx 2024-12-20 16:11:07 +0300  57)         if test "X$x" = "X-I$additional_includedir"; then
868b2b66 (kx 2024-12-20 16:11:07 +0300  58)           haveit=yes
868b2b66 (kx 2024-12-20 16:11:07 +0300  59)           break
868b2b66 (kx 2024-12-20 16:11:07 +0300  60)         fi
868b2b66 (kx 2024-12-20 16:11:07 +0300  61)       done
868b2b66 (kx 2024-12-20 16:11:07 +0300  62)       if test -z "$haveit"; then
868b2b66 (kx 2024-12-20 16:11:07 +0300  63)         if test "X$additional_includedir" = "X/usr/local/include"; then
868b2b66 (kx 2024-12-20 16:11:07 +0300  64)           if test -n "$GCC"; then
868b2b66 (kx 2024-12-20 16:11:07 +0300  65)             case $host_os in
868b2b66 (kx 2024-12-20 16:11:07 +0300  66)               linux* | gnu* | k*bsd*-gnu) haveit=yes;;
868b2b66 (kx 2024-12-20 16:11:07 +0300  67)             esac
868b2b66 (kx 2024-12-20 16:11:07 +0300  68)           fi
868b2b66 (kx 2024-12-20 16:11:07 +0300  69)         fi
868b2b66 (kx 2024-12-20 16:11:07 +0300  70)         if test -z "$haveit"; then
868b2b66 (kx 2024-12-20 16:11:07 +0300  71)           if test -d "$additional_includedir"; then
868b2b66 (kx 2024-12-20 16:11:07 +0300  72)             dnl Really add $additional_includedir to $CPPFLAGS.
868b2b66 (kx 2024-12-20 16:11:07 +0300  73)             CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir"
868b2b66 (kx 2024-12-20 16:11:07 +0300  74)           fi
868b2b66 (kx 2024-12-20 16:11:07 +0300  75)         fi
868b2b66 (kx 2024-12-20 16:11:07 +0300  76)       fi
868b2b66 (kx 2024-12-20 16:11:07 +0300  77)     fi
868b2b66 (kx 2024-12-20 16:11:07 +0300  78)     dnl Potentially add $additional_libdir to $LDFLAGS.
868b2b66 (kx 2024-12-20 16:11:07 +0300  79)     dnl But don't add it
868b2b66 (kx 2024-12-20 16:11:07 +0300  80)     dnl   1. if it's the standard /usr/lib,
868b2b66 (kx 2024-12-20 16:11:07 +0300  81)     dnl   2. if it's already present in $LDFLAGS,
868b2b66 (kx 2024-12-20 16:11:07 +0300  82)     dnl   3. if it's /usr/local/lib and we are using GCC on Linux,
868b2b66 (kx 2024-12-20 16:11:07 +0300  83)     dnl   4. if it doesn't exist as a directory.
868b2b66 (kx 2024-12-20 16:11:07 +0300  84)     if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then
868b2b66 (kx 2024-12-20 16:11:07 +0300  85)       haveit=
868b2b66 (kx 2024-12-20 16:11:07 +0300  86)       for x in $LDFLAGS; do
868b2b66 (kx 2024-12-20 16:11:07 +0300  87)         AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
868b2b66 (kx 2024-12-20 16:11:07 +0300  88)         if test "X$x" = "X-L$additional_libdir"; then
868b2b66 (kx 2024-12-20 16:11:07 +0300  89)           haveit=yes
868b2b66 (kx 2024-12-20 16:11:07 +0300  90)           break
868b2b66 (kx 2024-12-20 16:11:07 +0300  91)         fi
868b2b66 (kx 2024-12-20 16:11:07 +0300  92)       done
868b2b66 (kx 2024-12-20 16:11:07 +0300  93)       if test -z "$haveit"; then
868b2b66 (kx 2024-12-20 16:11:07 +0300  94)         if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then
868b2b66 (kx 2024-12-20 16:11:07 +0300  95)           if test -n "$GCC"; then
868b2b66 (kx 2024-12-20 16:11:07 +0300  96)             case $host_os in
868b2b66 (kx 2024-12-20 16:11:07 +0300  97)               linux*) haveit=yes;;
868b2b66 (kx 2024-12-20 16:11:07 +0300  98)             esac
868b2b66 (kx 2024-12-20 16:11:07 +0300  99)           fi
868b2b66 (kx 2024-12-20 16:11:07 +0300 100)         fi
868b2b66 (kx 2024-12-20 16:11:07 +0300 101)         if test -z "$haveit"; then
868b2b66 (kx 2024-12-20 16:11:07 +0300 102)           if test -d "$additional_libdir"; then
868b2b66 (kx 2024-12-20 16:11:07 +0300 103)             dnl Really add $additional_libdir to $LDFLAGS.
868b2b66 (kx 2024-12-20 16:11:07 +0300 104)             LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir"
868b2b66 (kx 2024-12-20 16:11:07 +0300 105)           fi
868b2b66 (kx 2024-12-20 16:11:07 +0300 106)         fi
868b2b66 (kx 2024-12-20 16:11:07 +0300 107)       fi
868b2b66 (kx 2024-12-20 16:11:07 +0300 108)     fi
868b2b66 (kx 2024-12-20 16:11:07 +0300 109)   fi
868b2b66 (kx 2024-12-20 16:11:07 +0300 110) ])
868b2b66 (kx 2024-12-20 16:11:07 +0300 111) 
868b2b66 (kx 2024-12-20 16:11:07 +0300 112) dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix,
868b2b66 (kx 2024-12-20 16:11:07 +0300 113) dnl acl_final_exec_prefix, containing the values to which $prefix and
868b2b66 (kx 2024-12-20 16:11:07 +0300 114) dnl $exec_prefix will expand at the end of the configure script.
868b2b66 (kx 2024-12-20 16:11:07 +0300 115) AC_DEFUN([AC_LIB_PREPARE_PREFIX],
868b2b66 (kx 2024-12-20 16:11:07 +0300 116) [
868b2b66 (kx 2024-12-20 16:11:07 +0300 117)   dnl Unfortunately, prefix and exec_prefix get only finally determined
868b2b66 (kx 2024-12-20 16:11:07 +0300 118)   dnl at the end of configure.
868b2b66 (kx 2024-12-20 16:11:07 +0300 119)   if test "X$prefix" = "XNONE"; then
868b2b66 (kx 2024-12-20 16:11:07 +0300 120)     acl_final_prefix="$ac_default_prefix"
868b2b66 (kx 2024-12-20 16:11:07 +0300 121)   else
868b2b66 (kx 2024-12-20 16:11:07 +0300 122)     acl_final_prefix="$prefix"
868b2b66 (kx 2024-12-20 16:11:07 +0300 123)   fi
868b2b66 (kx 2024-12-20 16:11:07 +0300 124)   if test "X$exec_prefix" = "XNONE"; then
868b2b66 (kx 2024-12-20 16:11:07 +0300 125)     acl_final_exec_prefix='${prefix}'
868b2b66 (kx 2024-12-20 16:11:07 +0300 126)   else
868b2b66 (kx 2024-12-20 16:11:07 +0300 127)     acl_final_exec_prefix="$exec_prefix"
868b2b66 (kx 2024-12-20 16:11:07 +0300 128)   fi
868b2b66 (kx 2024-12-20 16:11:07 +0300 129)   acl_save_prefix="$prefix"
868b2b66 (kx 2024-12-20 16:11:07 +0300 130)   prefix="$acl_final_prefix"
868b2b66 (kx 2024-12-20 16:11:07 +0300 131)   eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
868b2b66 (kx 2024-12-20 16:11:07 +0300 132)   prefix="$acl_save_prefix"
868b2b66 (kx 2024-12-20 16:11:07 +0300 133) ])
868b2b66 (kx 2024-12-20 16:11:07 +0300 134) 
868b2b66 (kx 2024-12-20 16:11:07 +0300 135) dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the
868b2b66 (kx 2024-12-20 16:11:07 +0300 136) dnl variables prefix and exec_prefix bound to the values they will have
868b2b66 (kx 2024-12-20 16:11:07 +0300 137) dnl at the end of the configure script.
868b2b66 (kx 2024-12-20 16:11:07 +0300 138) AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX],
868b2b66 (kx 2024-12-20 16:11:07 +0300 139) [
868b2b66 (kx 2024-12-20 16:11:07 +0300 140)   acl_save_prefix="$prefix"
868b2b66 (kx 2024-12-20 16:11:07 +0300 141)   prefix="$acl_final_prefix"
868b2b66 (kx 2024-12-20 16:11:07 +0300 142)   acl_save_exec_prefix="$exec_prefix"
868b2b66 (kx 2024-12-20 16:11:07 +0300 143)   exec_prefix="$acl_final_exec_prefix"
868b2b66 (kx 2024-12-20 16:11:07 +0300 144)   $1
868b2b66 (kx 2024-12-20 16:11:07 +0300 145)   exec_prefix="$acl_save_exec_prefix"
868b2b66 (kx 2024-12-20 16:11:07 +0300 146)   prefix="$acl_save_prefix"
868b2b66 (kx 2024-12-20 16:11:07 +0300 147) ])
868b2b66 (kx 2024-12-20 16:11:07 +0300 148) 
868b2b66 (kx 2024-12-20 16:11:07 +0300 149) dnl AC_LIB_PREPARE_MULTILIB creates
868b2b66 (kx 2024-12-20 16:11:07 +0300 150) dnl - a function acl_is_expected_elfclass, that tests whether standard input
868b2b66 (kx 2024-12-20 16:11:07 +0300 151) dn;   has a 32-bit or 64-bit ELF header, depending on the host CPU ABI,
868b2b66 (kx 2024-12-20 16:11:07 +0300 152) dnl - 3 variables acl_libdirstem, acl_libdirstem2, acl_libdirstem3, containing
868b2b66 (kx 2024-12-20 16:11:07 +0300 153) dnl   the basename of the libdir to try in turn, either "lib" or "lib64" or
868b2b66 (kx 2024-12-20 16:11:07 +0300 154) dnl   "lib/64" or "lib32" or "lib/sparcv9" or "lib/amd64" or similar.
868b2b66 (kx 2024-12-20 16:11:07 +0300 155) AC_DEFUN([AC_LIB_PREPARE_MULTILIB],
868b2b66 (kx 2024-12-20 16:11:07 +0300 156) [
868b2b66 (kx 2024-12-20 16:11:07 +0300 157)   dnl There is no formal standard regarding lib, lib32, and lib64.
868b2b66 (kx 2024-12-20 16:11:07 +0300 158)   dnl On most glibc systems, the current practice is that on a system supporting
868b2b66 (kx 2024-12-20 16:11:07 +0300 159)   dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under
868b2b66 (kx 2024-12-20 16:11:07 +0300 160)   dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. However, on
868b2b66 (kx 2024-12-20 16:11:07 +0300 161)   dnl Arch Linux based distributions, it's the opposite: 32-bit libraries go
868b2b66 (kx 2024-12-20 16:11:07 +0300 162)   dnl under $prefix/lib32 and 64-bit libraries go under $prefix/lib.
868b2b66 (kx 2024-12-20 16:11:07 +0300 163)   dnl We determine the compiler's default mode by looking at the compiler's
868b2b66 (kx 2024-12-20 16:11:07 +0300 164)   dnl library search path. If at least one of its elements ends in /lib64 or
868b2b66 (kx 2024-12-20 16:11:07 +0300 165)   dnl points to a directory whose absolute pathname ends in /lib64, we use that
868b2b66 (kx 2024-12-20 16:11:07 +0300 166)   dnl for 64-bit ABIs. Similarly for 32-bit ABIs. Otherwise we use the default,
868b2b66 (kx 2024-12-20 16:11:07 +0300 167)   dnl namely "lib".
868b2b66 (kx 2024-12-20 16:11:07 +0300 168)   dnl On Solaris systems, the current practice is that on a system supporting
868b2b66 (kx 2024-12-20 16:11:07 +0300 169)   dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under
868b2b66 (kx 2024-12-20 16:11:07 +0300 170)   dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or
868b2b66 (kx 2024-12-20 16:11:07 +0300 171)   dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib.
868b2b66 (kx 2024-12-20 16:11:07 +0300 172)   AC_REQUIRE([AC_CANONICAL_HOST])
868b2b66 (kx 2024-12-20 16:11:07 +0300 173)   AC_REQUIRE([gl_HOST_CPU_C_ABI_32BIT])
868b2b66 (kx 2024-12-20 16:11:07 +0300 174) 
868b2b66 (kx 2024-12-20 16:11:07 +0300 175)   AC_CACHE_CHECK([for ELF binary format], [gl_cv_elf],
868b2b66 (kx 2024-12-20 16:11:07 +0300 176)     [AC_EGREP_CPP([Extensible Linking Format],
868b2b66 (kx 2024-12-20 16:11:07 +0300 177)        [#ifdef __ELF__
868b2b66 (kx 2024-12-20 16:11:07 +0300 178)         Extensible Linking Format
868b2b66 (kx 2024-12-20 16:11:07 +0300 179)         #endif
868b2b66 (kx 2024-12-20 16:11:07 +0300 180)        ],
868b2b66 (kx 2024-12-20 16:11:07 +0300 181)        [gl_cv_elf=yes],
868b2b66 (kx 2024-12-20 16:11:07 +0300 182)        [gl_cv_elf=no])
868b2b66 (kx 2024-12-20 16:11:07 +0300 183)      ])
868b2b66 (kx 2024-12-20 16:11:07 +0300 184)   if test $gl_cv_elf; then
868b2b66 (kx 2024-12-20 16:11:07 +0300 185)     # Extract the ELF class of a file (5th byte) in decimal.
868b2b66 (kx 2024-12-20 16:11:07 +0300 186)     # Cf. https://en.wikipedia.org/wiki/Executable_and_Linkable_Format#File_header
868b2b66 (kx 2024-12-20 16:11:07 +0300 187)     if od -A x < /dev/null >/dev/null 2>/dev/null; then
868b2b66 (kx 2024-12-20 16:11:07 +0300 188)       # Use POSIX od.
868b2b66 (kx 2024-12-20 16:11:07 +0300 189)       func_elfclass ()
868b2b66 (kx 2024-12-20 16:11:07 +0300 190)       {
868b2b66 (kx 2024-12-20 16:11:07 +0300 191)         od -A n -t d1 -j 4 -N 1
868b2b66 (kx 2024-12-20 16:11:07 +0300 192)       }
868b2b66 (kx 2024-12-20 16:11:07 +0300 193)     else
868b2b66 (kx 2024-12-20 16:11:07 +0300 194)       # Use BSD hexdump.
868b2b66 (kx 2024-12-20 16:11:07 +0300 195)       func_elfclass ()
868b2b66 (kx 2024-12-20 16:11:07 +0300 196)       {
868b2b66 (kx 2024-12-20 16:11:07 +0300 197)         dd bs=1 count=1 skip=4 2>/dev/null | hexdump -e '1/1 "%3d "'
868b2b66 (kx 2024-12-20 16:11:07 +0300 198)         echo
868b2b66 (kx 2024-12-20 16:11:07 +0300 199)       }
868b2b66 (kx 2024-12-20 16:11:07 +0300 200)     fi
868b2b66 (kx 2024-12-20 16:11:07 +0300 201) changequote(,)dnl
868b2b66 (kx 2024-12-20 16:11:07 +0300 202)     case $HOST_CPU_C_ABI_32BIT in
868b2b66 (kx 2024-12-20 16:11:07 +0300 203)       yes)
868b2b66 (kx 2024-12-20 16:11:07 +0300 204)         # 32-bit ABI.
868b2b66 (kx 2024-12-20 16:11:07 +0300 205)         acl_is_expected_elfclass ()
868b2b66 (kx 2024-12-20 16:11:07 +0300 206)         {
868b2b66 (kx 2024-12-20 16:11:07 +0300 207)           test "`func_elfclass | sed -e 's/[ 	]//g'`" = 1
868b2b66 (kx 2024-12-20 16:11:07 +0300 208)         }
868b2b66 (kx 2024-12-20 16:11:07 +0300 209)         ;;
868b2b66 (kx 2024-12-20 16:11:07 +0300 210)       no)
868b2b66 (kx 2024-12-20 16:11:07 +0300 211)         # 64-bit ABI.
868b2b66 (kx 2024-12-20 16:11:07 +0300 212)         acl_is_expected_elfclass ()
868b2b66 (kx 2024-12-20 16:11:07 +0300 213)         {
868b2b66 (kx 2024-12-20 16:11:07 +0300 214)           test "`func_elfclass | sed -e 's/[ 	]//g'`" = 2
868b2b66 (kx 2024-12-20 16:11:07 +0300 215)         }
868b2b66 (kx 2024-12-20 16:11:07 +0300 216)         ;;
868b2b66 (kx 2024-12-20 16:11:07 +0300 217)       *)
868b2b66 (kx 2024-12-20 16:11:07 +0300 218)         # Unknown.
868b2b66 (kx 2024-12-20 16:11:07 +0300 219)         acl_is_expected_elfclass ()
868b2b66 (kx 2024-12-20 16:11:07 +0300 220)         {
868b2b66 (kx 2024-12-20 16:11:07 +0300 221)           :
868b2b66 (kx 2024-12-20 16:11:07 +0300 222)         }
868b2b66 (kx 2024-12-20 16:11:07 +0300 223)         ;;
868b2b66 (kx 2024-12-20 16:11:07 +0300 224)     esac
868b2b66 (kx 2024-12-20 16:11:07 +0300 225) changequote([,])dnl
868b2b66 (kx 2024-12-20 16:11:07 +0300 226)   else
868b2b66 (kx 2024-12-20 16:11:07 +0300 227)     acl_is_expected_elfclass ()
868b2b66 (kx 2024-12-20 16:11:07 +0300 228)     {
868b2b66 (kx 2024-12-20 16:11:07 +0300 229)       :
868b2b66 (kx 2024-12-20 16:11:07 +0300 230)     }
868b2b66 (kx 2024-12-20 16:11:07 +0300 231)   fi
868b2b66 (kx 2024-12-20 16:11:07 +0300 232) 
868b2b66 (kx 2024-12-20 16:11:07 +0300 233)   dnl Allow the user to override the result by setting acl_cv_libdirstems.
868b2b66 (kx 2024-12-20 16:11:07 +0300 234)   AC_CACHE_CHECK([for the common suffixes of directories in the library search path],
868b2b66 (kx 2024-12-20 16:11:07 +0300 235)     [acl_cv_libdirstems],
868b2b66 (kx 2024-12-20 16:11:07 +0300 236)     [dnl Try 'lib' first, because that's the default for libdir in GNU, see
868b2b66 (kx 2024-12-20 16:11:07 +0300 237)      dnl <https://www.gnu.org/prep/standards/html_node/Directory-Variables.html>.
868b2b66 (kx 2024-12-20 16:11:07 +0300 238)      acl_libdirstem=lib
868b2b66 (kx 2024-12-20 16:11:07 +0300 239)      acl_libdirstem2=
868b2b66 (kx 2024-12-20 16:11:07 +0300 240)      acl_libdirstem3=
868b2b66 (kx 2024-12-20 16:11:07 +0300 241)      case "$host_os" in
868b2b66 (kx 2024-12-20 16:11:07 +0300 242)        solaris*)
868b2b66 (kx 2024-12-20 16:11:07 +0300 243)          dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment
868b2b66 (kx 2024-12-20 16:11:07 +0300 244)          dnl <https://docs.oracle.com/cd/E19253-01/816-5138/dev-env/index.html>.
868b2b66 (kx 2024-12-20 16:11:07 +0300 245)          dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link."
868b2b66 (kx 2024-12-20 16:11:07 +0300 246)          dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the
868b2b66 (kx 2024-12-20 16:11:07 +0300 247)          dnl symlink is missing, so we set acl_libdirstem2 too.
868b2b66 (kx 2024-12-20 16:11:07 +0300 248)          if test $HOST_CPU_C_ABI_32BIT = no; then
868b2b66 (kx 2024-12-20 16:11:07 +0300 249)            acl_libdirstem2=lib/64
868b2b66 (kx 2024-12-20 16:11:07 +0300 250)            case "$host_cpu" in
868b2b66 (kx 2024-12-20 16:11:07 +0300 251)              sparc*)        acl_libdirstem3=lib/sparcv9 ;;
868b2b66 (kx 2024-12-20 16:11:07 +0300 252)              i*86 | x86_64) acl_libdirstem3=lib/amd64 ;;
868b2b66 (kx 2024-12-20 16:11:07 +0300 253)            esac
868b2b66 (kx 2024-12-20 16:11:07 +0300 254)          fi
868b2b66 (kx 2024-12-20 16:11:07 +0300 255)          ;;
868b2b66 (kx 2024-12-20 16:11:07 +0300 256)        *)
868b2b66 (kx 2024-12-20 16:11:07 +0300 257)          dnl If $CC generates code for a 32-bit ABI, the libraries are
868b2b66 (kx 2024-12-20 16:11:07 +0300 258)          dnl surely under $prefix/lib or $prefix/lib32, not $prefix/lib64.
868b2b66 (kx 2024-12-20 16:11:07 +0300 259)          dnl Similarly, if $CC generates code for a 64-bit ABI, the libraries
868b2b66 (kx 2024-12-20 16:11:07 +0300 260)          dnl are surely under $prefix/lib or $prefix/lib64, not $prefix/lib32.
868b2b66 (kx 2024-12-20 16:11:07 +0300 261)          dnl Find the compiler's search path. However, non-system compilers
868b2b66 (kx 2024-12-20 16:11:07 +0300 262)          dnl sometimes have odd library search paths. But we can't simply invoke
868b2b66 (kx 2024-12-20 16:11:07 +0300 263)          dnl '/usr/bin/gcc -print-search-dirs' because that would not take into
868b2b66 (kx 2024-12-20 16:11:07 +0300 264)          dnl account the -m32/-m31 or -m64 options from the $CC or $CFLAGS.
868b2b66 (kx 2024-12-20 16:11:07 +0300 265)          searchpath=`(LC_ALL=C $CC $CPPFLAGS $CFLAGS -print-search-dirs) 2>/dev/null \
868b2b66 (kx 2024-12-20 16:11:07 +0300 266)                      | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'`
868b2b66 (kx 2024-12-20 16:11:07 +0300 267)          if test $HOST_CPU_C_ABI_32BIT != no; then
868b2b66 (kx 2024-12-20 16:11:07 +0300 268)            # 32-bit or unknown ABI.
868b2b66 (kx 2024-12-20 16:11:07 +0300 269)            if test -d /usr/lib32; then
868b2b66 (kx 2024-12-20 16:11:07 +0300 270)              acl_libdirstem2=lib32
868b2b66 (kx 2024-12-20 16:11:07 +0300 271)            fi
868b2b66 (kx 2024-12-20 16:11:07 +0300 272)          fi
868b2b66 (kx 2024-12-20 16:11:07 +0300 273)          if test $HOST_CPU_C_ABI_32BIT != yes; then
868b2b66 (kx 2024-12-20 16:11:07 +0300 274)            # 64-bit or unknown ABI.
868b2b66 (kx 2024-12-20 16:11:07 +0300 275)            if test -d /usr/lib64; then
868b2b66 (kx 2024-12-20 16:11:07 +0300 276)              acl_libdirstem3=lib64
868b2b66 (kx 2024-12-20 16:11:07 +0300 277)            fi
868b2b66 (kx 2024-12-20 16:11:07 +0300 278)          fi
868b2b66 (kx 2024-12-20 16:11:07 +0300 279)          if test -n "$searchpath"; then
868b2b66 (kx 2024-12-20 16:11:07 +0300 280)            acl_save_IFS="${IFS= 	}"; IFS=":"
868b2b66 (kx 2024-12-20 16:11:07 +0300 281)            for searchdir in $searchpath; do
868b2b66 (kx 2024-12-20 16:11:07 +0300 282)              if test -d "$searchdir"; then
868b2b66 (kx 2024-12-20 16:11:07 +0300 283)                case "$searchdir" in
868b2b66 (kx 2024-12-20 16:11:07 +0300 284)                  */lib32/ | */lib32 ) acl_libdirstem2=lib32 ;;
868b2b66 (kx 2024-12-20 16:11:07 +0300 285)                  */lib64/ | */lib64 ) acl_libdirstem3=lib64 ;;
868b2b66 (kx 2024-12-20 16:11:07 +0300 286)                  */../ | */.. )
868b2b66 (kx 2024-12-20 16:11:07 +0300 287)                    # Better ignore directories of this form. They are misleading.
868b2b66 (kx 2024-12-20 16:11:07 +0300 288)                    ;;
868b2b66 (kx 2024-12-20 16:11:07 +0300 289)                  *) searchdir=`cd "$searchdir" && pwd`
868b2b66 (kx 2024-12-20 16:11:07 +0300 290)                     case "$searchdir" in
868b2b66 (kx 2024-12-20 16:11:07 +0300 291)                       */lib32 ) acl_libdirstem2=lib32 ;;
868b2b66 (kx 2024-12-20 16:11:07 +0300 292)                       */lib64 ) acl_libdirstem3=lib64 ;;
868b2b66 (kx 2024-12-20 16:11:07 +0300 293)                     esac ;;
868b2b66 (kx 2024-12-20 16:11:07 +0300 294)                esac
868b2b66 (kx 2024-12-20 16:11:07 +0300 295)              fi
868b2b66 (kx 2024-12-20 16:11:07 +0300 296)            done
868b2b66 (kx 2024-12-20 16:11:07 +0300 297)            IFS="$acl_save_IFS"
868b2b66 (kx 2024-12-20 16:11:07 +0300 298)            if test $HOST_CPU_C_ABI_32BIT = yes; then
868b2b66 (kx 2024-12-20 16:11:07 +0300 299)              # 32-bit ABI.
868b2b66 (kx 2024-12-20 16:11:07 +0300 300)              acl_libdirstem3=
868b2b66 (kx 2024-12-20 16:11:07 +0300 301)            fi
868b2b66 (kx 2024-12-20 16:11:07 +0300 302)            if test $HOST_CPU_C_ABI_32BIT = no; then
868b2b66 (kx 2024-12-20 16:11:07 +0300 303)              # 64-bit ABI.
868b2b66 (kx 2024-12-20 16:11:07 +0300 304)              acl_libdirstem2=
868b2b66 (kx 2024-12-20 16:11:07 +0300 305)            fi
868b2b66 (kx 2024-12-20 16:11:07 +0300 306)          fi
868b2b66 (kx 2024-12-20 16:11:07 +0300 307)          ;;
868b2b66 (kx 2024-12-20 16:11:07 +0300 308)      esac
868b2b66 (kx 2024-12-20 16:11:07 +0300 309)      test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem"
868b2b66 (kx 2024-12-20 16:11:07 +0300 310)      test -n "$acl_libdirstem3" || acl_libdirstem3="$acl_libdirstem"
868b2b66 (kx 2024-12-20 16:11:07 +0300 311)      acl_cv_libdirstems="$acl_libdirstem,$acl_libdirstem2,$acl_libdirstem3"
868b2b66 (kx 2024-12-20 16:11:07 +0300 312)     ])
868b2b66 (kx 2024-12-20 16:11:07 +0300 313)   dnl Decompose acl_cv_libdirstems into acl_libdirstem, acl_libdirstem2, and
868b2b66 (kx 2024-12-20 16:11:07 +0300 314)   dnl acl_libdirstem3.
868b2b66 (kx 2024-12-20 16:11:07 +0300 315) changequote(,)dnl
868b2b66 (kx 2024-12-20 16:11:07 +0300 316)   acl_libdirstem=`echo "$acl_cv_libdirstems" | sed -e 's/,.*//'`
868b2b66 (kx 2024-12-20 16:11:07 +0300 317)   acl_libdirstem2=`echo "$acl_cv_libdirstems" | sed -e 's/^[^,]*,//' -e 's/,.*//'`
868b2b66 (kx 2024-12-20 16:11:07 +0300 318)   acl_libdirstem3=`echo "$acl_cv_libdirstems" | sed -e 's/^[^,]*,[^,]*,//' -e 's/,.*//'`
868b2b66 (kx 2024-12-20 16:11:07 +0300 319) changequote([,])dnl
868b2b66 (kx 2024-12-20 16:11:07 +0300 320) ])