You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

152 lines
4.4 KiB

  1. dnl -------------------------------------------------------- -*- autoconf -*-
  2. dnl Licensed to the Apache Software Foundation (ASF) under one or more
  3. dnl contributor license agreements. See the NOTICE file distributed with
  4. dnl this work for additional information regarding copyright ownership.
  5. dnl The ASF licenses this file to You under the Apache License, Version 2.0
  6. dnl (the "License"); you may not use this file except in compliance with
  7. dnl the License. You may obtain a copy of the License at
  8. dnl
  9. dnl http://www.apache.org/licenses/LICENSE-2.0
  10. dnl
  11. dnl Unless required by applicable law or agreed to in writing, software
  12. dnl distributed under the License is distributed on an "AS IS" BASIS,
  13. dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. dnl See the License for the specific language governing permissions and
  15. dnl limitations under the License.
  16. dnl
  17. dnl TS_ADDTO(variable, value)
  18. dnl
  19. dnl Add value to variable
  20. dnl
  21. AC_DEFUN([TS_ADDTO], [
  22. if test "x$$1" = "x"; then
  23. test "x$verbose" = "xyes" && echo " setting $1 to \"$2\""
  24. $1="$2"
  25. else
  26. ats_addto_bugger="$2"
  27. for i in $ats_addto_bugger; do
  28. ats_addto_duplicate="0"
  29. for j in $$1; do
  30. if test "x$i" = "x$j"; then
  31. ats_addto_duplicate="1"
  32. break
  33. fi
  34. done
  35. if test $ats_addto_duplicate = "0"; then
  36. test "x$verbose" = "xyes" && echo " adding \"$i\" to $1"
  37. $1="$$1 $i"
  38. fi
  39. done
  40. fi
  41. ])dnl
  42. dnl
  43. dnl TS_ADDTO_RPATH(path)
  44. dnl
  45. dnl Adds path to variable with the '-rpath' directive.
  46. dnl
  47. AC_DEFUN([TS_ADDTO_RPATH], [
  48. AC_MSG_NOTICE([adding $1 to RPATH])
  49. TS_ADDTO(LIBTOOL_LINK_FLAGS, [-R$1])
  50. ])dnl
  51. dnl
  52. dnl pcre.m4: Trafficserver's pcre autoconf macros
  53. dnl
  54. dnl
  55. dnl TS_CHECK_PCRE: look for pcre libraries and headers
  56. dnl
  57. AC_DEFUN([TS_CHECK_PCRE], [
  58. enable_pcre=no
  59. AC_ARG_WITH(pcre, [AC_HELP_STRING([--with-pcre=DIR],[use a specific pcre library])],
  60. [
  61. if test "x$withval" != "xyes" && test "x$withval" != "x"; then
  62. pcre_base_dir="$withval"
  63. if test "$withval" != "no"; then
  64. enable_pcre=yes
  65. case "$withval" in
  66. *":"*)
  67. pcre_include="`echo $withval |sed -e 's/:.*$//'`"
  68. pcre_ldflags="`echo $withval |sed -e 's/^.*://'`"
  69. AC_MSG_CHECKING(checking for pcre includes in $pcre_include libs in $pcre_ldflags )
  70. ;;
  71. *)
  72. pcre_include="$withval/include"
  73. pcre_ldflags="$withval/lib"
  74. AC_MSG_CHECKING(checking for pcre includes in $withval)
  75. ;;
  76. esac
  77. fi
  78. fi
  79. ],
  80. [
  81. AC_CHECK_PROG(PCRE_CONFIG, pcre-config, pcre-config)
  82. if test "x$PCRE_CONFIG" != "x"; then
  83. enable_pcre=yes
  84. pcre_base_dir="`$PCRE_CONFIG --prefix`"
  85. pcre_include="`$PCRE_CONFIG --cflags | sed -es/-I//`"
  86. pcre_ldflags="`$PCRE_CONFIG --libs | sed -es/-lpcre// -es/-L//`"
  87. fi
  88. ])
  89. if test "x$pcre_base_dir" = "x"; then
  90. AC_MSG_CHECKING([for pcre location])
  91. AC_CACHE_VAL(ats_cv_pcre_dir,[
  92. for dir in /usr/local /usr ; do
  93. if test -d $dir && ( test -f $dir/include/pcre.h || test -f $dir/include/pcre/pcre.h ); then
  94. ats_cv_pcre_dir=$dir
  95. break
  96. fi
  97. done
  98. ])
  99. pcre_base_dir=$ats_cv_pcre_dir
  100. if test "x$pcre_base_dir" = "x"; then
  101. enable_pcre=no
  102. AC_MSG_RESULT([not found])
  103. else
  104. enable_pcre=yes
  105. pcre_include="$pcre_base_dir/include"
  106. pcre_ldflags="$pcre_base_dir/lib"
  107. AC_MSG_RESULT([$pcre_base_dir])
  108. fi
  109. else
  110. AC_MSG_CHECKING(for pcre headers in $pcre_include)
  111. if test -d $pcre_include && test -d $pcre_ldflags && ( test -f $pcre_include/pcre.h || test -f $pcre_include/pcre/pcre.h ); then
  112. AC_MSG_RESULT([ok])
  113. else
  114. AC_MSG_RESULT([not found])
  115. fi
  116. fi
  117. pcreh=0
  118. pcre_pcreh=0
  119. if test "$enable_pcre" != "no"; then
  120. saved_ldflags=$LDFLAGS
  121. saved_cppflags=$CFLAGS
  122. pcre_have_headers=0
  123. pcre_have_libs=0
  124. if test "$pcre_base_dir" != "/usr"; then
  125. TS_ADDTO(CFLAGS, [-I${pcre_include}])
  126. TS_ADDTO(CFLAGS, [-DPCRE_STATIC])
  127. TS_ADDTO(LDFLAGS, [-L${pcre_ldflags}])
  128. TS_ADDTO_RPATH(${pcre_ldflags})
  129. fi
  130. AC_SEARCH_LIBS([pcre_exec], [pcre], [pcre_have_libs=1])
  131. if test "$pcre_have_libs" != "0"; then
  132. AC_CHECK_HEADERS(pcre.h, [pcre_have_headers=1])
  133. AC_CHECK_HEADERS(pcre/pcre.h, [pcre_have_headers=1])
  134. fi
  135. if test "$pcre_have_headers" != "0"; then
  136. AC_DEFINE(HAVE_LIBPCRE,1,[Compiling with pcre support])
  137. AC_SUBST(LIBPCRE, [-lpcre])
  138. else
  139. enable_pcre=no
  140. CFLAGS=$saved_cppflags
  141. LDFLAGS=$saved_ldflags
  142. fi
  143. fi
  144. AC_SUBST(pcreh)
  145. AC_SUBST(pcre_pcreh)
  146. ])