1dnl -------------------------------------------------------- -*- autoconf -*-
2dnl Licensed to the Apache Software Foundation (ASF) under one or more
3dnl contributor license agreements.  See the NOTICE file distributed with
4dnl this work for additional information regarding copyright ownership.
5dnl The ASF licenses this file to You under the Apache License, Version 2.0
6dnl (the "License"); you may not use this file except in compliance with
7dnl the License.  You may obtain a copy of the License at
8dnl
9dnl     http://www.apache.org/licenses/LICENSE-2.0
10dnl
11dnl Unless required by applicable law or agreed to in writing, software
12dnl distributed under the License is distributed on an "AS IS" BASIS,
13dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14dnl See the License for the specific language governing permissions and
15dnl limitations under the License.
16
17dnl
18dnl yaml-cpp.m4: Trafficserver's yaml-cpp autoconf macros
19dnl
20
21dnl
22dnl TS_CHECK_YAML_CPP: look for yaml-cpp libraries and headers
23dnl
24AC_DEFUN([TS_CHECK_YAML_CPP], [
25has_yaml_cpp=no
26AC_ARG_WITH(yaml-cpp, [AC_HELP_STRING([--with-yaml-cpp=DIR],[use a specific yaml-cpp library])],
27[
28  if test "x$withval" != "xyes" && test "x$withval" != "x"; then
29    yaml_cpp_base_dir="$withval"
30    if test "$withval" != "no"; then
31      has_yaml_cpp=yes
32      case "$withval" in
33      *":"*)
34        yaml_cpp_include="`echo $withval |sed -e 's/:.*$//'`"
35        yaml_cpp_ldflags="`echo $withval |sed -e 's/^.*://'`"
36        AC_MSG_CHECKING(checking for yaml-cpp includes in $yaml_cpp_include libs in $yaml_cpp_ldflags )
37        ;;
38      *)
39        yaml_cpp_include="$withval/include"
40        yaml_cpp_ldflags="$withval/lib"
41        yaml_cpp_base_dir="$withval"
42        AC_MSG_CHECKING(yaml-cpp includes in $withval libs in $yaml_cpp_ldflags)
43        ;;
44      esac
45    fi
46  fi
47
48  if test -d $yaml_cpp_include && test -d $yaml_cpp_ldflags && test -f $yaml_cpp_include/yaml-cpp/yaml.h; then
49    AC_MSG_RESULT([ok])
50  else
51    AC_MSG_RESULT([not found])
52  fi
53
54if test "$has_yaml_cpp" != "no"; then
55  saved_ldflags=$LDFLAGS
56  saved_cppflags=$CPPFLAGS
57
58  YAMLCPP_LIBS=-lyaml-cpp
59  if test "$yaml_cpp_base_dir" != "/usr"; then
60    YAMLCPP_INCLUDES=-I${yaml_cpp_include}
61    YAMLCPP_LDFLAGS=-L${yaml_cpp_ldflags}
62
63    TS_ADDTO_RPATH(${yaml_cpp_ldflags})
64  fi
65
66  if test "$yaml_cpp_include" != "0"; then
67    YAMLCPP_INCLUDES=-I${yaml_cpp_include}
68  else
69    has_yaml_cpp=no
70    CPPFLAGS=$saved_cppflags
71    LDFLAGS=$saved_ldflags
72  fi
73fi
74],
75[
76  has_yaml_cpp=no
77  YAMLCPP_INCLUDES=-I\${abs_top_srcdir}/lib/yamlcpp/include
78  YAMLCPP_LIBS=-lyamlcpp
79  YAMLCPP_LDFLAGS=-L\${abs_top_builddir}/lib/yamlcpp
80])
81
82AC_SUBST([YAMLCPP_INCLUDES])
83AC_SUBST([YAMLCPP_LIBS])
84AC_SUBST([YAMLCPP_LDFLAGS])
85
86])
87
88dnl TS_CHECK_YAML_HEADERS_EXPORT: check if we want to export yaml-cpp headers from trafficserver. default: not exported
89AC_DEFUN([TS_CHECK_YAML_HEADERS_EXPORT], [
90AC_MSG_CHECKING([whether to export yaml-cpp headers])
91AC_ARG_ENABLE([yaml-headers],
92  [AS_HELP_STRING([--enable-yaml-headers],[Export yaml-cpp headers])],
93  [],
94  [enable_yaml_headers=no]
95)
96AC_MSG_RESULT([$enable_yaml_headers])
97])
98