|
| 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 | + |
| 17 | +dnl |
| 18 | +dnl hiredis.m4: Trafficserver's hiredis autoconf macros |
| 19 | +dnl |
| 20 | + |
| 21 | +dnl |
| 22 | +dnl TS_CHECK_HIREDIS: look for hiredis libraries and headers |
| 23 | +dnl |
| 24 | + |
| 25 | +AC_DEFUN([TS_CHECK_HIREDIS], [ |
| 26 | +hiredis_base_dir='/usr' |
| 27 | +has_hiredis=0 |
| 28 | +AC_ARG_WITH(hiredis, [AC_HELP_STRING([--with-hiredis=DIR],[use a specific hiredis library])], |
| 29 | +[ |
| 30 | + has_hiredis=1 |
| 31 | + if test "x$withval" != "xyes" && test "x$withval" != "x"; then |
| 32 | + hiredis_base_dir="$withval" |
| 33 | + if test "$withval" != "no"; then |
| 34 | + case "$withval" in |
| 35 | + *":"*) |
| 36 | + hiredis_include="`echo $withval |sed -e 's/:.*$//'`" |
| 37 | + hiredis_ldflags="`echo $withval |sed -e 's/^.*://'`" |
| 38 | + AC_MSG_CHECKING(checking for hiredis includes in $hiredis_include libs in $hiredis_ldflags ) |
| 39 | + ;; |
| 40 | + *) |
| 41 | + hiredis_include="$withval/include" |
| 42 | + hiredis_ldflags="$withval/lib" |
| 43 | + AC_MSG_CHECKING(checking for hiredis includes in $withval) |
| 44 | + ;; |
| 45 | + esac |
| 46 | + fi |
| 47 | + fi |
| 48 | +
|
| 49 | + if test -d $hiredis_include && test -d $hiredis_ldflags && test -f $hiredis_include/hiredis/hiredis.h; then |
| 50 | + AC_MSG_RESULT([ok]) |
| 51 | + else |
| 52 | + has_hiredis=0 |
| 53 | + AC_MSG_RESULT([not found]) |
| 54 | + fi |
| 55 | +
|
| 56 | +if test "$has_hiredis" != "0"; then |
| 57 | + saved_ldflags=$LDFLAGS |
| 58 | + saved_cppflags=$CPPFLAGS |
| 59 | + hiredis_have_headers=0 |
| 60 | + hiredis_have_libs=0 |
| 61 | + if test "$hiredis_base_dir" != "/usr"; then |
| 62 | + TS_ADDTO(CPPFLAGS, [-I${hiredis_include}]) |
| 63 | + TS_ADDTO(LDFLAGS, [-L${hiredis_ldflags}]) |
| 64 | + TS_ADDTO_RPATH(${hiredis_ldflags}) |
| 65 | + fi |
| 66 | +
|
| 67 | + AC_CHECK_LIB([hiredis], redisConnect, [hiredis_have_libs=1]) |
| 68 | + if test "$hiredis_have_libs" != "0"; then |
| 69 | + AC_CHECK_HEADERS(hiredis/hiredis.h, [hiredis_have_headers=1]) |
| 70 | + fi |
| 71 | + if test "$hiredis_have_headers" != "0"; then |
| 72 | + AC_SUBST([LIB_HIREDIS], [-lhiredis]) |
| 73 | + AC_SUBST([CFLAGS_HIREDIS], [-I${hiredis_include}]) |
| 74 | + else |
| 75 | + has_hiredis=0 |
| 76 | + CPPFLAGS=$saved_cppflags |
| 77 | + LDFLAGS=$saved_ldflags |
| 78 | + fi |
| 79 | +fi |
| 80 | +], |
| 81 | +[ |
| 82 | +has_hiredis=1 |
| 83 | +AC_CHECK_HEADER([hiredis/hiredis.h], [], [has_hiredis=0]) |
| 84 | +AC_CHECK_LIB([hiredis], redisConnect, [], [has_hiredis=0]) |
| 85 | +
|
| 86 | +if test "x$has_hiredis" == "x1"; then |
| 87 | + AC_SUBST([LIB_HIREDIS], [-lhiredis]) |
| 88 | +fi |
| 89 | +]) |
| 90 | +
|
| 91 | +]) |
| 92 | + |
| 93 | + |
0 commit comments