lib-prefix.m4 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. # lib-prefix.m4 serial 2 (gettext-0.12)
  2. dnl Copyright (C) 2001-2003 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_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and
  10. dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't
  11. dnl require excessive bracketing.
  12. ifdef([AC_HELP_STRING],
  13. [AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])],
  14. [AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])])
  15. dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed
  16. dnl to access previously installed libraries. The basic assumption is that
  17. dnl a user will want packages to use other packages he previously installed
  18. dnl with the same --prefix option.
  19. dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate
  20. dnl libraries, but is otherwise very convenient.
  21. AC_DEFUN([AC_LIB_PREFIX],
  22. [
  23. AC_BEFORE([$0], [AC_LIB_LINKFLAGS])
  24. AC_REQUIRE([AC_PROG_CC])
  25. AC_REQUIRE([AC_CANONICAL_HOST])
  26. AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
  27. dnl By default, look in $includedir and $libdir.
  28. use_additional=yes
  29. AC_LIB_WITH_FINAL_PREFIX([
  30. eval additional_includedir=\"$includedir\"
  31. eval additional_libdir=\"$libdir\"
  32. ])
  33. AC_LIB_ARG_WITH([lib-prefix],
  34. [ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib
  35. --without-lib-prefix don't search for libraries in includedir and libdir],
  36. [
  37. if test "X$withval" = "Xno"; then
  38. use_additional=no
  39. else
  40. if test "X$withval" = "X"; then
  41. AC_LIB_WITH_FINAL_PREFIX([
  42. eval additional_includedir=\"$includedir\"
  43. eval additional_libdir=\"$libdir\"
  44. ])
  45. else
  46. additional_includedir="$withval/include"
  47. additional_libdir="$withval/lib"
  48. fi
  49. fi
  50. ])
  51. if test $use_additional = yes; then
  52. dnl Potentially add $additional_includedir to $CPPFLAGS.
  53. dnl But don't add it
  54. dnl 1. if it's the standard /usr/include,
  55. dnl 2. if it's already present in $CPPFLAGS,
  56. dnl 3. if it's /usr/local/include and we are using GCC on Linux,
  57. dnl 4. if it doesn't exist as a directory.
  58. if test "X$additional_includedir" != "X/usr/include"; then
  59. haveit=
  60. for x in $CPPFLAGS; do
  61. AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
  62. if test "X$x" = "X-I$additional_includedir"; then
  63. haveit=yes
  64. break
  65. fi
  66. done
  67. if test -z "$haveit"; then
  68. if test "X$additional_includedir" = "X/usr/local/include"; then
  69. if test -n "$GCC"; then
  70. case $host_os in
  71. linux*) haveit=yes;;
  72. esac
  73. fi
  74. fi
  75. if test -z "$haveit"; then
  76. if test -d "$additional_includedir"; then
  77. dnl Really add $additional_includedir to $CPPFLAGS.
  78. CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir"
  79. fi
  80. fi
  81. fi
  82. fi
  83. dnl Potentially add $additional_libdir to $LDFLAGS.
  84. dnl But don't add it
  85. dnl 1. if it's the standard /usr/lib,
  86. dnl 2. if it's already present in $LDFLAGS,
  87. dnl 3. if it's /usr/local/lib and we are using GCC on Linux,
  88. dnl 4. if it doesn't exist as a directory.
  89. if test "X$additional_libdir" != "X/usr/lib"; then
  90. haveit=
  91. for x in $LDFLAGS; do
  92. AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
  93. if test "X$x" = "X-L$additional_libdir"; then
  94. haveit=yes
  95. break
  96. fi
  97. done
  98. if test -z "$haveit"; then
  99. if test "X$additional_libdir" = "X/usr/local/lib"; then
  100. if test -n "$GCC"; then
  101. case $host_os in
  102. linux*) haveit=yes;;
  103. esac
  104. fi
  105. fi
  106. if test -z "$haveit"; then
  107. if test -d "$additional_libdir"; then
  108. dnl Really add $additional_libdir to $LDFLAGS.
  109. LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir"
  110. fi
  111. fi
  112. fi
  113. fi
  114. fi
  115. ])
  116. dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix,
  117. dnl acl_final_exec_prefix, containing the values to which $prefix and
  118. dnl $exec_prefix will expand at the end of the configure script.
  119. AC_DEFUN([AC_LIB_PREPARE_PREFIX],
  120. [
  121. dnl Unfortunately, prefix and exec_prefix get only finally determined
  122. dnl at the end of configure.
  123. if test "X$prefix" = "XNONE"; then
  124. acl_final_prefix="$ac_default_prefix"
  125. else
  126. acl_final_prefix="$prefix"
  127. fi
  128. if test "X$exec_prefix" = "XNONE"; then
  129. acl_final_exec_prefix='${prefix}'
  130. else
  131. acl_final_exec_prefix="$exec_prefix"
  132. fi
  133. acl_save_prefix="$prefix"
  134. prefix="$acl_final_prefix"
  135. eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
  136. prefix="$acl_save_prefix"
  137. ])
  138. dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the
  139. dnl variables prefix and exec_prefix bound to the values they will have
  140. dnl at the end of the configure script.
  141. AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX],
  142. [
  143. acl_save_prefix="$prefix"
  144. prefix="$acl_final_prefix"
  145. acl_save_exec_prefix="$exec_prefix"
  146. exec_prefix="$acl_final_exec_prefix"
  147. $1
  148. exec_prefix="$acl_save_exec_prefix"
  149. prefix="$acl_save_prefix"
  150. ])