Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 68 additions & 55 deletions build/libswoc.m4
Original file line number Diff line number Diff line change
Expand Up @@ -20,68 +20,77 @@ dnl

dnl
dnl TS_CHECK_LIBSWOC: look for libswoc libraries and headers
dnl value
dnl "yes" libswoc is presumed available already and nothing needs to be done.
dnl "no" Not allowed, generates an error.
dnl * Presumed to be a directory containing libswoc.
dnl
AC_DEFUN([TS_CHECK_LIBSWOC], [
has_libswoc=no
AC_ARG_WITH(libswoc, [AS_HELP_STRING([--with-libswoc=DIR],[use a specific libswoc library])],
[
if test "x$withval" != "xyes" && test "x$withval" != "x"; then
libswoc_base_dir="$withval"
if test "$withval" != "no"; then
has_libswoc=yes
case "$withval" in
*":"*)
swoc_include="`echo $withval |sed -e 's/:.*$//'`"
swoc_ldflags="`echo $withval |sed -e 's/^.*://'`"
AC_MSG_CHECKING(checking for libswoc includes in $swoc_include libs in $swoc_ldflags )
;;
*)
swoc_include="$withval/include"
swoc_ldflags="$withval/lib"
libswoc_base_dir="$withval"
AC_MSG_CHECKING(libswoc includes in $withval libs in $swoc_ldflags)
;;
esac
fi
fi
# internal defaults.
has_libswoc=no
SWOC_INCLUDES=-I\${abs_top_srcdir}/lib/swoc/include
SWOC_LIBS=-ltsswoc
SWOC_LDFLAGS=-L\${abs_top_builddir}/lib/swoc
AC_ARG_WITH(libswoc, [AS_HELP_STRING([--with-libswoc=DIR],[use a specific libswoc library])],
[
AC_MSG_CHECKING(checking libswoc)
# Check for override.
if test "x$withval" != "x"; then
has_libswoc=yes # inhibit internal build of libswoc
if test "$withval" = "no" ; then
AC_MSG_ERROR([libswoc is required internally, it cannot be disabled])
elif test "$withval" = "yes" ; then # assume libswoc is installed in a standard place
SWOC_INCLUDES=
SWOC_LIBS=-lswoc
SWOC_LDFLAGS=
AC_MSG_RESULT([ok])
else
swoc_pkg_cfg=""
# Defaults if pkg config not found.
SWOC_INCLUDES="-I${withval}/include"
SWOC_LIBS="-lswoc"
SWOC_LDFLAGS="-L${withval}/lib"
if test -n "$PKG_CONFIG" ; then # pkg-config binary was found
for pk in "lib/pkgconfig" "lib" "." ; do
if PKG_CONFIG_LIBDIR=${withval}/${pk} $PKG_CONFIG --exists libswoc ; then
swoc_pkg_cfg=" [pkg-config: ${pk}]"
SWOC_INCLUDES=$(PKG_CONFIG_LIBDIR=${withval}/${pk} $PKG_CONFIG --cflags libswoc)
SWOC_LIBS=$(PKG_CONFIG_LIBDIR=${withval}/${pk} $PKG_CONFIG --libs-only-l libswoc)
SWOC_LDFLAGS=$(PKG_CONFIG_LIBDIR=${withval}/${pk} $PKG_CONFIG --libs-only-L libswoc)
break
fi
done
fi

if test -d $swoc_include && test -d $swoc_ldflags && test -f $swoc_include/libswoc/swoc_version.h; then
AC_MSG_RESULT([ok])
else
AC_MSG_RESULT([not found])
fi
# time to see if things work

if test "$has_libswoc" != "no"; then
saved_ldflags=$LDFLAGS
saved_cppflags=$CPPFLAGS
swoc_CXXFLAGS="$CXXFLAGS"
swoc_LIBS="${LIBS}"
CXXFLAGS="$CXXFLAGS ${SWOC_INCLUDES}"
LIBS="${SWOC_LDFLAGS} ${SWOC_LIBS}"

SWOC_LIBS=-ltsswoc
if test "$libswoc_base_dir" != "/usr"; then
SWOC_INCLUDES=-I${swoc_include}
SWOC_LDFLAGS=-L${swoc_ldflags}
AC_LANG_PUSH(C++)
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <swoc/TextView.h>], [swoc::TextView tv{"Evil Dave Rulz"};])],
[AC_MSG_RESULT([ok${swoc_pkg_cfg}])],
[
AC_MSG_RESULT([failed${swoc_pkg_cfg}])
AC_MSG_ERROR([${withval} does not contain a valid libswoc.])
]
)
AC_LANG_POP

TS_ADDTO_RPATH(${swoc_ldflags})
fi
CXXFLAGS="${swoc_CXXFLAGS}"
LIBS="${swoc_LIBS}"

if test "$swoc_include" != "0"; then
SWOC_INCLUDES=-I${swoc_include}
else
has_libswoc=no
CPPFLAGS=$saved_cppflags
LDFLAGS=$saved_ldflags
fi
fi
],
[
has_libswoc=no
SWOC_INCLUDES=-I\${abs_top_srcdir}/lib/swoc/include
SWOC_LIBS=-ltsswoc
SWOC_LDFLAGS=-L\${abs_top_builddir}/lib/swoc
])
fi # valid override
fi # override provided

AC_SUBST([SWOC_INCLUDES])
AC_SUBST([SWOC_LIBS])
AC_SUBST([SWOC_LDFLAGS])
])

AC_SUBST([SWOC_INCLUDES])
AC_SUBST([SWOC_LIBS])
AC_SUBST([SWOC_LDFLAGS])

])

Expand All @@ -90,7 +99,11 @@ AC_DEFUN([TS_CHECK_SWOC_HEADERS_EXPORT], [
AC_MSG_CHECKING([whether to export libswoc headers])
AC_ARG_ENABLE([swoc-headers],
[AS_HELP_STRING([--enable-swoc-headers],[Export libswoc headers])],
[],
[
if test "x$has_libswoc" = "xyes" ; then
enable_swoc_headers="no - cannot export external headers"
fi
],
[enable_swoc_headers=no]
)
AC_MSG_RESULT([$enable_swoc_headers])
Expand Down
4 changes: 3 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ TS_ENABLE_LAYOUT(TrafficServer, [cachedir docdir])
# Reparse the configure arguments so we can override the layout.
TS_PARSE_ARGUMENTS

AC_PATH_PROG(PKG_CONFIG, pkg-config)

#
# Host detection
#
Expand Down Expand Up @@ -1476,7 +1478,7 @@ TS_CHECK_YAML_HEADERS_EXPORT
AM_CONDITIONAL([EXPORT_YAML_HEADERS], [test x"$enable_yaml_headers" = x"yes"])

TS_CHECK_LIBSWOC
AM_CONDITIONAL([BUILD_SWOC], [test x"$has_libswoc" = x"no"])
AM_CONDITIONAL([BUILD_SWOC], [test "$has_libswoc" = "no"])

TS_CHECK_SWOC_HEADERS_EXPORT
AM_CONDITIONAL([EXPORT_SWOC_HEADERS], [test x"$enable_swoc_headers" = x"yes"])
Expand Down
4 changes: 1 addition & 3 deletions proxy/logging/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,14 @@ AM_CPPFLAGS += \
$(iocore_include_dirs) \
-I$(abs_top_srcdir)/include \
-I$(abs_top_srcdir)/lib \
-I$(abs_top_srcdir)/lib/swoc/include \
-I$(abs_top_srcdir)/proxy \
-I$(abs_top_srcdir)/proxy/http \
-I$(abs_top_srcdir)/proxy/http/remap \
-I$(abs_top_srcdir)/proxy/hdrs \
-I$(abs_top_srcdir)/proxy/shared \
-I$(abs_top_srcdir)/mgmt \
-I$(abs_top_srcdir)/mgmt/utils \
$(TS_INCLUDES) \
@YAMLCPP_INCLUDES@
$(TS_INCLUDES) @SWOC_INCLUDES@ @YAMLCPP_INCLUDES@

EXTRA_DIST = LogStandalone.cc

Expand Down
1 change: 0 additions & 1 deletion src/records/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ include $(top_srcdir)/build/tidy.mk
check_PROGRAMS = test_librecords test_librecords_on_eventsystem

AM_CPPFLAGS += \
-I$(abs_top_srcdir)/lib/swoc/include \
-I$(abs_top_srcdir)/iocore/eventsystem \
-I$(abs_top_srcdir)/iocore/utils \
-I$(abs_top_srcdir)/include \
Expand Down