lib-prefix.m4 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. # lib-prefix.m4 serial 1 (gettext-0.11)
  2. dnl Copyright (C) 2001-2002 Free Software Foundation, Inc.
  3. dnl This file is free software, distributed under the terms of the GNU
  4. dnl General Public License. As a special exception to the GNU General
  5. dnl Public License, this file may be distributed as part of a program
  6. dnl that contains a configuration script generated by Autoconf, under
  7. dnl the same distribution terms as the rest of that program.
  8. dnl From Bruno Haible.
  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 a user will want packages to use other packages he previously installed
  12. dnl with the same --prefix option.
  13. dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate
  14. dnl libraries, but is otherwise very convenient.
  15. AC_DEFUN([AC_LIB_PREFIX],
  16. [
  17. AC_BEFORE([$0], [AC_LIB_LINKFLAGS])
  18. AC_REQUIRE([AC_PROG_CC])
  19. AC_REQUIRE([AC_CANONICAL_HOST])
  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/lib"
  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*) 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/lib"; 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/lib"; 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. dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix,
  111. dnl acl_final_exec_prefix, containing the values to which $prefix and
  112. dnl $exec_prefix will expand at the end of the configure script.
  113. AC_DEFUN([AC_LIB_PREPARE_PREFIX],
  114. [
  115. dnl Unfortunately, prefix and exec_prefix get only finally determined
  116. dnl at the end of configure.
  117. if test "X$prefix" = "XNONE"; then
  118. acl_final_prefix="$ac_default_prefix"
  119. else
  120. acl_final_prefix="$prefix"
  121. fi
  122. if test "X$exec_prefix" = "XNONE"; then
  123. acl_final_exec_prefix='${prefix}'
  124. else
  125. acl_final_exec_prefix="$exec_prefix"
  126. fi
  127. acl_save_prefix="$prefix"
  128. prefix="$acl_final_prefix"
  129. eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
  130. prefix="$acl_save_prefix"
  131. ])
  132. dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the
  133. dnl variables prefix and exec_prefix bound to the values they will have
  134. dnl at the end of the configure script.
  135. AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX],
  136. [
  137. acl_save_prefix="$prefix"
  138. prefix="$acl_final_prefix"
  139. acl_save_exec_prefix="$exec_prefix"
  140. exec_prefix="$acl_final_exec_prefix"
  141. $1
  142. exec_prefix="$acl_save_exec_prefix"
  143. prefix="$acl_save_prefix"
  144. ])