The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/contrib/openzfs/config/lib-prefix.m4

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 # lib-prefix.m4 serial 14
    2 dnl Copyright (C) 2001-2005, 2008-2019 Free Software Foundation, Inc.
    3 dnl This file is free software; the Free Software Foundation
    4 dnl gives unlimited permission to copy and/or distribute it,
    5 dnl with or without modifications, as long as this notice is preserved.
    6 
    7 dnl From Bruno Haible.
    8 
    9 dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed
   10 dnl to access previously installed libraries. The basic assumption is that
   11 dnl packages should use other packages that are installed with the same
   12 dnl --prefix option.  This macro is not needed if only AC_LIB_LINKFLAGS is
   13 dnl used to locate libraries, but is otherwise very convenient.
   14 AC_DEFUN([AC_LIB_PREFIX],
   15 [
   16   AC_BEFORE([$0], [AC_LIB_LINKFLAGS])
   17   AC_REQUIRE([AC_PROG_CC])
   18   AC_REQUIRE([AC_CANONICAL_HOST])
   19   AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
   20   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
   21   dnl By default, look in $includedir and $libdir.
   22   use_additional=yes
   23   AC_LIB_WITH_FINAL_PREFIX([
   24     eval additional_includedir=\"$includedir\"
   25     eval additional_libdir=\"$libdir\"
   26   ])
   27   AC_ARG_WITH([lib-prefix],
   28 [[  --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib
   29   --without-lib-prefix    don't search for libraries in includedir and libdir]],
   30 [
   31     if test "X$withval" = "Xno"; then
   32       use_additional=no
   33     else
   34       if test "X$withval" = "X"; then
   35         AC_LIB_WITH_FINAL_PREFIX([
   36           eval additional_includedir=\"$includedir\"
   37           eval additional_libdir=\"$libdir\"
   38         ])
   39       else
   40         additional_includedir="$withval/include"
   41         additional_libdir="$withval/$acl_libdirstem"
   42       fi
   43     fi
   44 ])
   45   if test $use_additional = yes; then
   46     dnl Potentially add $additional_includedir to $CPPFLAGS.
   47     dnl But don't add it
   48     dnl   1. if it's the standard /usr/include,
   49     dnl   2. if it's already present in $CPPFLAGS,
   50     dnl   3. if it's /usr/local/include and we are using GCC on Linux,
   51     dnl   4. if it doesn't exist as a directory.
   52     if test "X$additional_includedir" != "X/usr/include"; then
   53       haveit=
   54       for x in $CPPFLAGS; do
   55         AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
   56         if test "X$x" = "X-I$additional_includedir"; then
   57           haveit=yes
   58           break
   59         fi
   60       done
   61       if test -z "$haveit"; then
   62         if test "X$additional_includedir" = "X/usr/local/include"; then
   63           if test -n "$GCC"; then
   64             case $host_os in
   65               linux* | gnu* | k*bsd*-gnu) haveit=yes;;
   66             esac
   67           fi
   68         fi
   69         if test -z "$haveit"; then
   70           if test -d "$additional_includedir"; then
   71             dnl Really add $additional_includedir to $CPPFLAGS.
   72             CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir"
   73           fi
   74         fi
   75       fi
   76     fi
   77     dnl Potentially add $additional_libdir to $LDFLAGS.
   78     dnl But don't add it
   79     dnl   1. if it's the standard /usr/lib,
   80     dnl   2. if it's already present in $LDFLAGS,
   81     dnl   3. if it's /usr/local/lib and we are using GCC on Linux,
   82     dnl   4. if it doesn't exist as a directory.
   83     if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then
   84       haveit=
   85       for x in $LDFLAGS; do
   86         AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
   87         if test "X$x" = "X-L$additional_libdir"; then
   88           haveit=yes
   89           break
   90         fi
   91       done
   92       if test -z "$haveit"; then
   93         if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then
   94           if test -n "$GCC"; then
   95             case $host_os in
   96               linux*) haveit=yes;;
   97             esac
   98           fi
   99         fi
  100         if test -z "$haveit"; then
  101           if test -d "$additional_libdir"; then
  102             dnl Really add $additional_libdir to $LDFLAGS.
  103             LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir"
  104           fi
  105         fi
  106       fi
  107     fi
  108   fi
  109 ])
  110 
  111 dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix,
  112 dnl acl_final_exec_prefix, containing the values to which $prefix and
  113 dnl $exec_prefix will expand at the end of the configure script.
  114 AC_DEFUN([AC_LIB_PREPARE_PREFIX],
  115 [
  116   dnl Unfortunately, prefix and exec_prefix get only finally determined
  117   dnl at the end of configure.
  118   if test "X$prefix" = "XNONE"; then
  119     acl_final_prefix="$ac_default_prefix"
  120   else
  121     acl_final_prefix="$prefix"
  122   fi
  123   if test "X$exec_prefix" = "XNONE"; then
  124     acl_final_exec_prefix='${prefix}'
  125   else
  126     acl_final_exec_prefix="$exec_prefix"
  127   fi
  128   acl_save_prefix="$prefix"
  129   prefix="$acl_final_prefix"
  130   eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
  131   prefix="$acl_save_prefix"
  132 ])
  133 
  134 dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the
  135 dnl variables prefix and exec_prefix bound to the values they will have
  136 dnl at the end of the configure script.
  137 AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX],
  138 [
  139   acl_save_prefix="$prefix"
  140   prefix="$acl_final_prefix"
  141   acl_save_exec_prefix="$exec_prefix"
  142   exec_prefix="$acl_final_exec_prefix"
  143   $1
  144   exec_prefix="$acl_save_exec_prefix"
  145   prefix="$acl_save_prefix"
  146 ])
  147 
  148 dnl AC_LIB_PREPARE_MULTILIB creates
  149 dnl - a variable acl_libdirstem, containing the basename of the libdir, either
  150 dnl   "lib" or "lib64" or "lib/64",
  151 dnl - a variable acl_libdirstem2, as a secondary possible value for
  152 dnl   acl_libdirstem, either the same as acl_libdirstem or "lib/sparcv9" or
  153 dnl   "lib/amd64".
  154 AC_DEFUN([AC_LIB_PREPARE_MULTILIB],
  155 [
  156   dnl There is no formal standard regarding lib and lib64.
  157   dnl On glibc systems, the current practice is that on a system supporting
  158   dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under
  159   dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. We determine
  160   dnl the compiler's default mode by looking at the compiler's library search
  161   dnl path. If at least one of its elements ends in /lib64 or points to a
  162   dnl directory whose absolute pathname ends in /lib64, we assume a 64-bit ABI.
  163   dnl Otherwise we use the default, namely "lib".
  164   dnl On Solaris systems, the current practice is that on a system supporting
  165   dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under
  166   dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or
  167   dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib.
  168   AC_REQUIRE([AC_CANONICAL_HOST])
  169   AC_REQUIRE([gl_HOST_CPU_C_ABI_32BIT])
  170 
  171   case "$host_os" in
  172     solaris*)
  173       AC_CACHE_CHECK([for 64-bit host], [gl_cv_solaris_64bit],
  174         [AC_COMPILE_IFELSE(
  175            [AC_LANG_SOURCE(
  176               [[#ifdef _LP64
  177                  int ok;
  178                 #else
  179                  error fail
  180                 #endif
  181               ]])],
  182            [gl_cv_solaris_64bit=yes],
  183            [gl_cv_solaris_64bit=no])
  184         ]);;
  185   esac
  186 
  187   dnl Allow the user to override the result by setting acl_cv_libdirstems.
  188   AC_CACHE_CHECK([for the common suffixes of directories in the library search path],
  189     [acl_cv_libdirstems],
  190     [acl_libdirstem=lib
  191      acl_libdirstem2=
  192      case "$host_os" in
  193        solaris*)
  194          dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment
  195          dnl <https://docs.oracle.com/cd/E19253-01/816-5138/dev-env/index.html>.
  196          dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link."
  197          dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the
  198          dnl symlink is missing, so we set acl_libdirstem2 too.
  199          if test $gl_cv_solaris_64bit = yes; then
  200            acl_libdirstem=lib/64
  201            case "$host_cpu" in
  202              sparc*)        acl_libdirstem2=lib/sparcv9 ;;
  203              i*86 | x86_64) acl_libdirstem2=lib/amd64 ;;
  204            esac
  205          fi
  206          ;;
  207        *)
  208          dnl If $CC generates code for a 32-bit ABI, the libraries are
  209          dnl surely under $prefix/lib, not $prefix/lib64.
  210          if test "$HOST_CPU_C_ABI_32BIT" != yes; then
  211            dnl The result is a property of the system. However, non-system
  212            dnl compilers sometimes have odd library search paths. Therefore
  213            dnl prefer asking /usr/bin/gcc, if available, rather than $CC.
  214            searchpath=`(if test -f /usr/bin/gcc \
  215                            && LC_ALL=C /usr/bin/gcc -print-search-dirs >/dev/null 2>/dev/null; then \
  216                           LC_ALL=C /usr/bin/gcc -print-search-dirs; \
  217                         else \
  218                           LC_ALL=C $CC -print-search-dirs; \
  219                         fi) 2>/dev/null \
  220                        | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'`
  221            if test -n "$searchpath"; then
  222              acl_save_IFS="${IFS=       }"; IFS=":"
  223              for searchdir in $searchpath; do
  224                if test -d "$searchdir"; then
  225                  case "$searchdir" in
  226                    */lib64/ | */lib64 ) acl_libdirstem=lib64 ;;
  227                    */../ | */.. )
  228                      # Better ignore directories of this form. They are misleading.
  229                      ;;
  230                    *) searchdir=`cd "$searchdir" && pwd`
  231                       case "$searchdir" in
  232                         */lib64 ) acl_libdirstem=lib64 ;;
  233                       esac ;;
  234                  esac
  235                fi
  236              done
  237              IFS="$acl_save_IFS"
  238            fi
  239          fi
  240          ;;
  241      esac
  242      test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem"
  243      acl_cv_libdirstems="$acl_libdirstem,$acl_libdirstem2"
  244     ])
  245   # Decompose acl_cv_libdirstems into acl_libdirstem and acl_libdirstem2.
  246   acl_libdirstem=`echo "$acl_cv_libdirstems" | sed -e 's/,.*//'`
  247   acl_libdirstem2=`echo "$acl_cv_libdirstems" | sed -e '/,/s/.*,//'`
  248 ])

Cache object: 461a4b6030fcb114dce72d9ae77a2be7


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.