annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/share/aclocal/lib-prefix.m4 @ 68:5028fdace37b

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