diff options
| author | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2023-01-31 14:46:01 +0100 |
|---|---|---|
| committer | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2023-01-31 14:46:01 +0100 |
| commit | e8bd88d1fcded01ccd066572eeaae1b507989cb3 (patch) | |
| tree | c8e7be6c07c6f635f6e803e6a6ba9e7a95fee7c0 /gl/m4/lib-prefix.m4 | |
| parent | 2ad962c13473607ca0d974bfaa516a0ed53ec73d (diff) | |
| download | monitoring-plugins-e8bd88d1fcded01ccd066572eeaae1b507989cb3.tar.gz | |
Sync with the latest Gnulib code 668c0b8ffa
Diffstat (limited to 'gl/m4/lib-prefix.m4')
| -rw-r--r-- | gl/m4/lib-prefix.m4 | 241 |
1 files changed, 170 insertions, 71 deletions
diff --git a/gl/m4/lib-prefix.m4 b/gl/m4/lib-prefix.m4 index 60908e8f..aefe7f71 100644 --- a/gl/m4/lib-prefix.m4 +++ b/gl/m4/lib-prefix.m4 | |||
| @@ -1,18 +1,11 @@ | |||
| 1 | # lib-prefix.m4 serial 7 (gettext-0.18) | 1 | # lib-prefix.m4 serial 20 |
| 2 | dnl Copyright (C) 2001-2005, 2008-2013 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2001-2005, 2008-2023 Free Software Foundation, Inc. |
| 3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
| 4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
| 5 | dnl with or without modifications, as long as this notice is preserved. | 5 | dnl with or without modifications, as long as this notice is preserved. |
| 6 | 6 | ||
| 7 | dnl From Bruno Haible. | 7 | dnl From Bruno Haible. |
| 8 | 8 | ||
| 9 | dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and | ||
| 10 | dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't | ||
| 11 | dnl require excessive bracketing. | ||
| 12 | ifdef([AC_HELP_STRING], | ||
| 13 | [AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])], | ||
| 14 | [AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])]) | ||
| 15 | |||
| 16 | dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed | 9 | dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed |
| 17 | dnl to access previously installed libraries. The basic assumption is that | 10 | dnl to access previously installed libraries. The basic assumption is that |
| 18 | dnl a user will want packages to use other packages he previously installed | 11 | dnl a user will want packages to use other packages he previously installed |
| @@ -32,9 +25,9 @@ AC_DEFUN([AC_LIB_PREFIX], | |||
| 32 | eval additional_includedir=\"$includedir\" | 25 | eval additional_includedir=\"$includedir\" |
| 33 | eval additional_libdir=\"$libdir\" | 26 | eval additional_libdir=\"$libdir\" |
| 34 | ]) | 27 | ]) |
| 35 | AC_LIB_ARG_WITH([lib-prefix], | 28 | AC_ARG_WITH([lib-prefix], |
| 36 | [ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib | 29 | [[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib |
| 37 | --without-lib-prefix don't search for libraries in includedir and libdir], | 30 | --without-lib-prefix don't search for libraries in includedir and libdir]], |
| 38 | [ | 31 | [ |
| 39 | if test "X$withval" = "Xno"; then | 32 | if test "X$withval" = "Xno"; then |
| 40 | use_additional=no | 33 | use_additional=no |
| @@ -154,71 +147,177 @@ AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX], | |||
| 154 | ]) | 147 | ]) |
| 155 | 148 | ||
| 156 | dnl AC_LIB_PREPARE_MULTILIB creates | 149 | dnl AC_LIB_PREPARE_MULTILIB creates |
| 157 | dnl - a variable acl_libdirstem, containing the basename of the libdir, either | 150 | dnl - a function acl_is_expected_elfclass, that tests whether standard input |
| 158 | dnl "lib" or "lib64" or "lib/64", | 151 | dn; has a 32-bit or 64-bit ELF header, depending on the host CPU ABI, |
| 159 | dnl - a variable acl_libdirstem2, as a secondary possible value for | 152 | dnl - 3 variables acl_libdirstem, acl_libdirstem2, acl_libdirstem3, containing |
| 160 | dnl acl_libdirstem, either the same as acl_libdirstem or "lib/sparcv9" or | 153 | dnl the basename of the libdir to try in turn, either "lib" or "lib64" or |
| 161 | dnl "lib/amd64". | 154 | dnl "lib/64" or "lib32" or "lib/sparcv9" or "lib/amd64" or similar. |
| 162 | AC_DEFUN([AC_LIB_PREPARE_MULTILIB], | 155 | AC_DEFUN([AC_LIB_PREPARE_MULTILIB], |
| 163 | [ | 156 | [ |
| 164 | dnl There is no formal standard regarding lib and lib64. | 157 | dnl There is no formal standard regarding lib, lib32, and lib64. |
| 165 | dnl On glibc systems, the current practice is that on a system supporting | 158 | dnl On most glibc systems, the current practice is that on a system supporting |
| 166 | dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under | 159 | dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under |
| 167 | dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. We determine | 160 | dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. However, on |
| 168 | dnl the compiler's default mode by looking at the compiler's library search | 161 | dnl Arch Linux based distributions, it's the opposite: 32-bit libraries go |
| 169 | dnl path. If at least one of its elements ends in /lib64 or points to a | 162 | dnl under $prefix/lib32 and 64-bit libraries go under $prefix/lib. |
| 170 | dnl directory whose absolute pathname ends in /lib64, we assume a 64-bit ABI. | 163 | dnl We determine the compiler's default mode by looking at the compiler's |
| 171 | dnl Otherwise we use the default, namely "lib". | 164 | dnl library search path. If at least one of its elements ends in /lib64 or |
| 165 | dnl points to a directory whose absolute pathname ends in /lib64, we use that | ||
| 166 | dnl for 64-bit ABIs. Similarly for 32-bit ABIs. Otherwise we use the default, | ||
| 167 | dnl namely "lib". | ||
| 172 | dnl On Solaris systems, the current practice is that on a system supporting | 168 | dnl On Solaris systems, the current practice is that on a system supporting |
| 173 | dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under | 169 | dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under |
| 174 | dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or | 170 | dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or |
| 175 | dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib. | 171 | dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib. |
| 176 | AC_REQUIRE([AC_CANONICAL_HOST]) | 172 | AC_REQUIRE([AC_CANONICAL_HOST]) |
| 177 | acl_libdirstem=lib | 173 | AC_REQUIRE([gl_HOST_CPU_C_ABI_32BIT]) |
| 178 | acl_libdirstem2= | 174 | |
| 179 | case "$host_os" in | 175 | AC_CACHE_CHECK([for ELF binary format], [gl_cv_elf], |
| 180 | solaris*) | 176 | [AC_EGREP_CPP([Extensible Linking Format], |
| 181 | dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment | 177 | [#if defined __ELF__ || (defined __linux__ && defined __EDG__) |
| 182 | dnl <http://docs.sun.com/app/docs/doc/816-5138/dev-env?l=en&a=view>. | 178 | Extensible Linking Format |
| 183 | dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link." | 179 | #endif |
| 184 | dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the | 180 | ], |
| 185 | dnl symlink is missing, so we set acl_libdirstem2 too. | 181 | [gl_cv_elf=yes], |
| 186 | AC_CACHE_CHECK([for 64-bit host], [gl_cv_solaris_64bit], | 182 | [gl_cv_elf=no]) |
| 187 | [AC_EGREP_CPP([sixtyfour bits], [ | 183 | ]) |
| 188 | #ifdef _LP64 | 184 | if test $gl_cv_elf = yes; then |
| 189 | sixtyfour bits | 185 | # Extract the ELF class of a file (5th byte) in decimal. |
| 190 | #endif | 186 | # Cf. https://en.wikipedia.org/wiki/Executable_and_Linkable_Format#File_header |
| 191 | ], [gl_cv_solaris_64bit=yes], [gl_cv_solaris_64bit=no]) | 187 | if od -A x < /dev/null >/dev/null 2>/dev/null; then |
| 192 | ]) | 188 | # Use POSIX od. |
| 193 | if test $gl_cv_solaris_64bit = yes; then | 189 | func_elfclass () |
| 194 | acl_libdirstem=lib/64 | 190 | { |
| 195 | case "$host_cpu" in | 191 | od -A n -t d1 -j 4 -N 1 |
| 196 | sparc*) acl_libdirstem2=lib/sparcv9 ;; | 192 | } |
| 197 | i*86 | x86_64) acl_libdirstem2=lib/amd64 ;; | 193 | else |
| 198 | esac | 194 | # Use BSD hexdump. |
| 199 | fi | 195 | func_elfclass () |
| 200 | ;; | 196 | { |
| 201 | *) | 197 | dd bs=1 count=1 skip=4 2>/dev/null | hexdump -e '1/1 "%3d "' |
| 202 | searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` | 198 | echo |
| 203 | if test -n "$searchpath"; then | 199 | } |
| 204 | acl_save_IFS="${IFS= }"; IFS=":" | 200 | fi |
| 205 | for searchdir in $searchpath; do | 201 | # Use 'expr', not 'test', to compare the values of func_elfclass, because on |
| 206 | if test -d "$searchdir"; then | 202 | # Solaris 11 OpenIndiana and Solaris 11 OmniOS, the result is 001 or 002, |
| 207 | case "$searchdir" in | 203 | # not 1 or 2. |
| 208 | */lib64/ | */lib64 ) acl_libdirstem=lib64 ;; | 204 | changequote(,)dnl |
| 209 | */../ | */.. ) | 205 | case $HOST_CPU_C_ABI_32BIT in |
| 210 | # Better ignore directories of this form. They are misleading. | 206 | yes) |
| 211 | ;; | 207 | # 32-bit ABI. |
| 212 | *) searchdir=`cd "$searchdir" && pwd` | 208 | acl_is_expected_elfclass () |
| 213 | case "$searchdir" in | 209 | { |
| 214 | */lib64 ) acl_libdirstem=lib64 ;; | 210 | expr "`func_elfclass | sed -e 's/[ ]//g'`" = 1 > /dev/null |
| 215 | esac ;; | 211 | } |
| 216 | esac | 212 | ;; |
| 217 | fi | 213 | no) |
| 218 | done | 214 | # 64-bit ABI. |
| 219 | IFS="$acl_save_IFS" | 215 | acl_is_expected_elfclass () |
| 220 | fi | 216 | { |
| 221 | ;; | 217 | expr "`func_elfclass | sed -e 's/[ ]//g'`" = 2 > /dev/null |
| 222 | esac | 218 | } |
| 223 | test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem" | 219 | ;; |
| 220 | *) | ||
| 221 | # Unknown. | ||
| 222 | acl_is_expected_elfclass () | ||
| 223 | { | ||
| 224 | : | ||
| 225 | } | ||
| 226 | ;; | ||
| 227 | esac | ||
| 228 | changequote([,])dnl | ||
| 229 | else | ||
| 230 | acl_is_expected_elfclass () | ||
| 231 | { | ||
| 232 | : | ||
| 233 | } | ||
| 234 | fi | ||
| 235 | |||
| 236 | dnl Allow the user to override the result by setting acl_cv_libdirstems. | ||
| 237 | AC_CACHE_CHECK([for the common suffixes of directories in the library search path], | ||
| 238 | [acl_cv_libdirstems], | ||
| 239 | [dnl Try 'lib' first, because that's the default for libdir in GNU, see | ||
| 240 | dnl <https://www.gnu.org/prep/standards/html_node/Directory-Variables.html>. | ||
| 241 | acl_libdirstem=lib | ||
| 242 | acl_libdirstem2= | ||
| 243 | acl_libdirstem3= | ||
| 244 | case "$host_os" in | ||
| 245 | solaris*) | ||
| 246 | dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment | ||
| 247 | dnl <https://docs.oracle.com/cd/E19253-01/816-5138/dev-env/index.html>. | ||
| 248 | dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link." | ||
| 249 | dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the | ||
| 250 | dnl symlink is missing, so we set acl_libdirstem2 too. | ||
| 251 | if test $HOST_CPU_C_ABI_32BIT = no; then | ||
| 252 | acl_libdirstem2=lib/64 | ||
| 253 | case "$host_cpu" in | ||
| 254 | sparc*) acl_libdirstem3=lib/sparcv9 ;; | ||
| 255 | i*86 | x86_64) acl_libdirstem3=lib/amd64 ;; | ||
| 256 | esac | ||
| 257 | fi | ||
| 258 | ;; | ||
| 259 | *) | ||
| 260 | dnl If $CC generates code for a 32-bit ABI, the libraries are | ||
| 261 | dnl surely under $prefix/lib or $prefix/lib32, not $prefix/lib64. | ||
| 262 | dnl Similarly, if $CC generates code for a 64-bit ABI, the libraries | ||
| 263 | dnl are surely under $prefix/lib or $prefix/lib64, not $prefix/lib32. | ||
| 264 | dnl Find the compiler's search path. However, non-system compilers | ||
| 265 | dnl sometimes have odd library search paths. But we can't simply invoke | ||
| 266 | dnl '/usr/bin/gcc -print-search-dirs' because that would not take into | ||
| 267 | dnl account the -m32/-m31 or -m64 options from the $CC or $CFLAGS. | ||
| 268 | searchpath=`(LC_ALL=C $CC $CPPFLAGS $CFLAGS -print-search-dirs) 2>/dev/null \ | ||
| 269 | | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` | ||
| 270 | if test $HOST_CPU_C_ABI_32BIT != no; then | ||
| 271 | # 32-bit or unknown ABI. | ||
| 272 | if test -d /usr/lib32; then | ||
| 273 | acl_libdirstem2=lib32 | ||
| 274 | fi | ||
| 275 | fi | ||
| 276 | if test $HOST_CPU_C_ABI_32BIT != yes; then | ||
| 277 | # 64-bit or unknown ABI. | ||
| 278 | if test -d /usr/lib64; then | ||
| 279 | acl_libdirstem3=lib64 | ||
| 280 | fi | ||
| 281 | fi | ||
| 282 | if test -n "$searchpath"; then | ||
| 283 | acl_save_IFS="${IFS= }"; IFS=":" | ||
| 284 | for searchdir in $searchpath; do | ||
| 285 | if test -d "$searchdir"; then | ||
| 286 | case "$searchdir" in | ||
| 287 | */lib32/ | */lib32 ) acl_libdirstem2=lib32 ;; | ||
| 288 | */lib64/ | */lib64 ) acl_libdirstem3=lib64 ;; | ||
| 289 | */../ | */.. ) | ||
| 290 | # Better ignore directories of this form. They are misleading. | ||
| 291 | ;; | ||
| 292 | *) searchdir=`cd "$searchdir" && pwd` | ||
| 293 | case "$searchdir" in | ||
| 294 | */lib32 ) acl_libdirstem2=lib32 ;; | ||
| 295 | */lib64 ) acl_libdirstem3=lib64 ;; | ||
| 296 | esac ;; | ||
| 297 | esac | ||
| 298 | fi | ||
| 299 | done | ||
| 300 | IFS="$acl_save_IFS" | ||
| 301 | if test $HOST_CPU_C_ABI_32BIT = yes; then | ||
| 302 | # 32-bit ABI. | ||
| 303 | acl_libdirstem3= | ||
| 304 | fi | ||
| 305 | if test $HOST_CPU_C_ABI_32BIT = no; then | ||
| 306 | # 64-bit ABI. | ||
| 307 | acl_libdirstem2= | ||
| 308 | fi | ||
| 309 | fi | ||
| 310 | ;; | ||
| 311 | esac | ||
| 312 | test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem" | ||
| 313 | test -n "$acl_libdirstem3" || acl_libdirstem3="$acl_libdirstem" | ||
| 314 | acl_cv_libdirstems="$acl_libdirstem,$acl_libdirstem2,$acl_libdirstem3" | ||
| 315 | ]) | ||
| 316 | dnl Decompose acl_cv_libdirstems into acl_libdirstem, acl_libdirstem2, and | ||
| 317 | dnl acl_libdirstem3. | ||
| 318 | changequote(,)dnl | ||
| 319 | acl_libdirstem=`echo "$acl_cv_libdirstems" | sed -e 's/,.*//'` | ||
| 320 | acl_libdirstem2=`echo "$acl_cv_libdirstems" | sed -e 's/^[^,]*,//' -e 's/,.*//'` | ||
| 321 | acl_libdirstem3=`echo "$acl_cv_libdirstems" | sed -e 's/^[^,]*,[^,]*,//' -e 's/,.*//'` | ||
| 322 | changequote([,])dnl | ||
| 224 | ]) | 323 | ]) |
