5 kx # lib-prefix.m4 serial 7 (gettext-0.18)
5 kx dnl Copyright (C) 2001-2005, 2008-2016 Free Software Foundation, Inc.
5 kx dnl This file is free software; the Free Software Foundation
5 kx dnl gives unlimited permission to copy and/or distribute it,
5 kx dnl with or without modifications, as long as this notice is preserved.
5 kx
5 kx dnl From Bruno Haible.
5 kx
5 kx dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and
5 kx dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't
5 kx dnl require excessive bracketing.
5 kx ifdef([AC_HELP_STRING],
5 kx [AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])],
5 kx [AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])])
5 kx
5 kx dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed
5 kx dnl to access previously installed libraries. The basic assumption is that
5 kx dnl a user will want packages to use other packages he previously installed
5 kx dnl with the same --prefix option.
5 kx dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate
5 kx dnl libraries, but is otherwise very convenient.
5 kx AC_DEFUN([AC_LIB_PREFIX],
5 kx [
5 kx AC_BEFORE([$0], [AC_LIB_LINKFLAGS])
5 kx AC_REQUIRE([AC_PROG_CC])
5 kx AC_REQUIRE([AC_CANONICAL_HOST])
5 kx AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
5 kx AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
5 kx dnl By default, look in $includedir and $libdir.
5 kx use_additional=yes
5 kx AC_LIB_WITH_FINAL_PREFIX([
5 kx eval additional_includedir=\"$includedir\"
5 kx eval additional_libdir=\"$libdir\"
5 kx ])
5 kx AC_LIB_ARG_WITH([lib-prefix],
5 kx [ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib
5 kx --without-lib-prefix don't search for libraries in includedir and libdir],
5 kx [
5 kx if test "X$withval" = "Xno"; then
5 kx use_additional=no
5 kx else
5 kx if test "X$withval" = "X"; then
5 kx AC_LIB_WITH_FINAL_PREFIX([
5 kx eval additional_includedir=\"$includedir\"
5 kx eval additional_libdir=\"$libdir\"
5 kx ])
5 kx else
5 kx additional_includedir="$withval/include"
5 kx additional_libdir="$withval/$acl_libdirstem"
5 kx fi
5 kx fi
5 kx ])
5 kx if test $use_additional = yes; then
5 kx dnl Potentially add $additional_includedir to $CPPFLAGS.
5 kx dnl But don't add it
5 kx dnl 1. if it's the standard /usr/include,
5 kx dnl 2. if it's already present in $CPPFLAGS,
5 kx dnl 3. if it's /usr/local/include and we are using GCC on Linux,
5 kx dnl 4. if it doesn't exist as a directory.
5 kx if test "X$additional_includedir" != "X/usr/include"; then
5 kx haveit=
5 kx for x in $CPPFLAGS; do
5 kx AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
5 kx if test "X$x" = "X-I$additional_includedir"; then
5 kx haveit=yes
5 kx break
5 kx fi
5 kx done
5 kx if test -z "$haveit"; then
5 kx if test "X$additional_includedir" = "X/usr/local/include"; then
5 kx if test -n "$GCC"; then
5 kx case $host_os in
5 kx linux* | gnu* | k*bsd*-gnu) haveit=yes;;
5 kx esac
5 kx fi
5 kx fi
5 kx if test -z "$haveit"; then
5 kx if test -d "$additional_includedir"; then
5 kx dnl Really add $additional_includedir to $CPPFLAGS.
5 kx CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir"
5 kx fi
5 kx fi
5 kx fi
5 kx fi
5 kx dnl Potentially add $additional_libdir to $LDFLAGS.
5 kx dnl But don't add it
5 kx dnl 1. if it's the standard /usr/lib,
5 kx dnl 2. if it's already present in $LDFLAGS,
5 kx dnl 3. if it's /usr/local/lib and we are using GCC on Linux,
5 kx dnl 4. if it doesn't exist as a directory.
5 kx if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then
5 kx haveit=
5 kx for x in $LDFLAGS; do
5 kx AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
5 kx if test "X$x" = "X-L$additional_libdir"; then
5 kx haveit=yes
5 kx break
5 kx fi
5 kx done
5 kx if test -z "$haveit"; then
5 kx if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then
5 kx if test -n "$GCC"; then
5 kx case $host_os in
5 kx linux*) haveit=yes;;
5 kx esac
5 kx fi
5 kx fi
5 kx if test -z "$haveit"; then
5 kx if test -d "$additional_libdir"; then
5 kx dnl Really add $additional_libdir to $LDFLAGS.
5 kx LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir"
5 kx fi
5 kx fi
5 kx fi
5 kx fi
5 kx fi
5 kx ])
5 kx
5 kx dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix,
5 kx dnl acl_final_exec_prefix, containing the values to which $prefix and
5 kx dnl $exec_prefix will expand at the end of the configure script.
5 kx AC_DEFUN([AC_LIB_PREPARE_PREFIX],
5 kx [
5 kx dnl Unfortunately, prefix and exec_prefix get only finally determined
5 kx dnl at the end of configure.
5 kx if test "X$prefix" = "XNONE"; then
5 kx acl_final_prefix="$ac_default_prefix"
5 kx else
5 kx acl_final_prefix="$prefix"
5 kx fi
5 kx if test "X$exec_prefix" = "XNONE"; then
5 kx acl_final_exec_prefix='${prefix}'
5 kx else
5 kx acl_final_exec_prefix="$exec_prefix"
5 kx fi
5 kx acl_save_prefix="$prefix"
5 kx prefix="$acl_final_prefix"
5 kx eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
5 kx prefix="$acl_save_prefix"
5 kx ])
5 kx
5 kx dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the
5 kx dnl variables prefix and exec_prefix bound to the values they will have
5 kx dnl at the end of the configure script.
5 kx AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX],
5 kx [
5 kx acl_save_prefix="$prefix"
5 kx prefix="$acl_final_prefix"
5 kx acl_save_exec_prefix="$exec_prefix"
5 kx exec_prefix="$acl_final_exec_prefix"
5 kx $1
5 kx exec_prefix="$acl_save_exec_prefix"
5 kx prefix="$acl_save_prefix"
5 kx ])
5 kx
5 kx dnl AC_LIB_PREPARE_MULTILIB creates
5 kx dnl - a variable acl_libdirstem, containing the basename of the libdir, either
5 kx dnl "lib" or "lib64" or "lib/64",
5 kx dnl - a variable acl_libdirstem2, as a secondary possible value for
5 kx dnl acl_libdirstem, either the same as acl_libdirstem or "lib/sparcv9" or
5 kx dnl "lib/amd64".
5 kx AC_DEFUN([AC_LIB_PREPARE_MULTILIB],
5 kx [
5 kx dnl There is no formal standard regarding lib and lib64.
5 kx dnl On glibc systems, the current practice is that on a system supporting
5 kx dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under
5 kx dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. We determine
5 kx dnl the compiler's default mode by looking at the compiler's library search
5 kx dnl path. If at least one of its elements ends in /lib64 or points to a
5 kx dnl directory whose absolute pathname ends in /lib64, we assume a 64-bit ABI.
5 kx dnl Otherwise we use the default, namely "lib".
5 kx dnl On Solaris systems, the current practice is that on a system supporting
5 kx dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under
5 kx dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or
5 kx dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib.
5 kx AC_REQUIRE([AC_CANONICAL_HOST])
5 kx acl_libdirstem=lib
5 kx acl_libdirstem2=
5 kx case "$host_os" in
5 kx solaris*)
5 kx dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment
5 kx dnl <http://docs.sun.com/app/docs/doc/816-5138/dev-env?l=en&a=view>.
5 kx dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link."
5 kx dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the
5 kx dnl symlink is missing, so we set acl_libdirstem2 too.
5 kx AC_CACHE_CHECK([for 64-bit host], [gl_cv_solaris_64bit],
5 kx [AC_EGREP_CPP([sixtyfour bits], [
5 kx #ifdef _LP64
5 kx sixtyfour bits
5 kx #endif
5 kx ], [gl_cv_solaris_64bit=yes], [gl_cv_solaris_64bit=no])
5 kx ])
5 kx if test $gl_cv_solaris_64bit = yes; then
5 kx acl_libdirstem=lib/64
5 kx case "$host_cpu" in
5 kx sparc*) acl_libdirstem2=lib/sparcv9 ;;
5 kx i*86 | x86_64) acl_libdirstem2=lib/amd64 ;;
5 kx esac
5 kx fi
5 kx ;;
5 kx *)
5 kx searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'`
5 kx if test -n "$searchpath"; then
5 kx acl_save_IFS="${IFS= }"; IFS=":"
5 kx for searchdir in $searchpath; do
5 kx if test -d "$searchdir"; then
5 kx case "$searchdir" in
5 kx */lib64/ | */lib64 ) acl_libdirstem=lib64 ;;
5 kx */../ | */.. )
5 kx # Better ignore directories of this form. They are misleading.
5 kx ;;
5 kx *) searchdir=`cd "$searchdir" && pwd`
5 kx case "$searchdir" in
5 kx */lib64 ) acl_libdirstem=lib64 ;;
5 kx esac ;;
5 kx esac
5 kx fi
5 kx done
5 kx IFS="$acl_save_IFS"
5 kx fi
5 kx ;;
5 kx esac
5 kx test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem"
5 kx ])