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