Commit 4786b768 authored by Steve Muir's avatar Steve Muir Committed by Facebook Github Bot

Generate a pkg-config file for Folly

Summary: First cut at autoconf rules for generating a pkg-config file for Folly. The only interesting part is that we want to handle packages that provide their own .pc files as dependencies rather than just stuffing them into the list of libraries required from packages that don't provide .pc.

Reviewed By: simpkins

Differential Revision: D3556611

fbshipit-source-id: d1c5f89416d1d96d2cdf5ccdc5bd7117fb822a82
parent 6a3ea696
......@@ -530,3 +530,7 @@ CLEANFILES += FingerprintTables.cpp
libfollybenchmark_la_SOURCES = Benchmark.cpp
libfollybenchmark_la_LIBADD = libfolly.la
libfollybenchmark_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LT_VERSION)
# install pkg-config metadata file
pkgconfigdir = $(libdir)/pkgconfig
nodist_pkgconfig_DATA = libfolly.pc
......@@ -12,6 +12,13 @@ AC_INIT([folly], m4_translit(folly_version_str, [:], [.]), [folly@fb.com])
LT_VERSION=folly_version_str:0
AC_SUBST([LT_VERSION])
#declare pkg-config variables
PKG_VERSION=m4_join([.], m4_reverse(m4_translit(folly_version_str, [:], [,])))
AC_SUBST([PKG_VERSION])
AC_SUBST([PKG_CXXFLAGS])
AC_SUBST([PKG_DEPS])
AC_SUBST([PKG_LIBS])
AC_CONFIG_SRCDIR([Likely.h])
AC_CONFIG_HEADERS([config.h])
AX_PREFIX_CONFIG_H([folly-config.h], [folly], [config.h])
......@@ -53,6 +60,9 @@ fi
CXXFLAGS="$STD $CXXFLAGS"
# expose required -std option via pkg-config
PKG_CXXFLAGS=$STD
# Checks for glog and gflags
# There are no symbols with C linkage, so we do a try-run
AC_HAVE_LIBRARY([gflags],[],[AC_MSG_ERROR(
......@@ -77,6 +87,7 @@ AC_CACHE_CHECK(
if test "$folly_cv_prog_cc_gflags" != "yes"; then
AC_MSG_ERROR(["libgflags invalid, see config.log for details"])
fi
FB_CHECK_PKG_CONFIG([GFLAGS], [libgflags])
AC_HAVE_LIBRARY([glog],[],[AC_MSG_ERROR(
[Please install google-glog library])])
......@@ -100,11 +111,13 @@ AC_CACHE_CHECK(
if test "$folly_cv_prog_cc_glog" != "yes"; then
AC_MSG_ERROR(["libglog invalid, see config.log for details"])
fi
FB_CHECK_PKG_CONFIG([GLOG], [libglog])
AC_CHECK_LIB(ssl,
SSL_ctrl,
[],
[AC_MSG_ERROR(["Error: libssl required"])])
FB_CHECK_PKG_CONFIG([OPENSSL], [openssl])
# check for boost libs
AX_BOOST_BASE([1.51.0], [], [AC_MSG_ERROR(
......@@ -131,6 +144,7 @@ AC_CHECK_LIB([double-conversion],[ceil],[],[AC_MSG_ERROR(
[Please install double-conversion library])])
AC_CHECK_LIB([event], [event_set], [], [AC_MSG_ERROR([Unable to find libevent])])
FB_CHECK_PKG_CONFIG([EVENT], [libevent])
AC_CHECK_LIB([jemalloc], [xallocx])
......@@ -559,8 +573,13 @@ AM_CONDITIONAL([HAVE_EXTRANDOM_SFMT19937],
AM_CONDITIONAL([FOLLY_TESTMAIN], [test "x${use_follytestmain}" = "xyes"])
AM_CONDITIONAL([HAVE_BOOST_CONTEXT], [test "x${ax_cv_boost_context}" = "xyes"])
# remove pkg-config deps from dependent libraries
# (at least for pkg-config file purposes)
FB_FILTER_PKG_LIBS([$AM_LDFLAGS $LIBS])
# Output
AC_CONFIG_FILES([Makefile
libfolly.pc
test/Makefile
test/function_benchmark/Makefile
experimental/Makefile
......
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: libfolly
Description: Facebook (Folly) C++ library
Version: @PKG_VERSION@
Requires.private: @PKG_DEPS@
Libs.private: @PKG_LIBS@
Libs: -L${libdir} -lfolly
Cflags: -I${includedir} @PKG_CXXFLAGS@
AC_DEFUN([FB_CHECK_PKG_CONFIG],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
PKG_CHECK_MODULES($1, $2,
[PKG_DEPS="$PKG_DEPS $2"],
[AC_MSG_NOTICE([$2.pc not found, treating as legacy dependency])]
)
]
)
AC_DEFUN([FB_FILTER_PKG_LIBS],
[AC_REQUIRE([AC_PROG_SED])
deps_=`for p in $PKG_DEPS; do pkg-config --libs $p; done`
filter_=`for l in $deps_;dnl
do echo $l | $SED -e 's%\(-l.*\)%-e s/\1//%' -e '/^-L/d';dnl
done`
PKG_LIBS=`echo $1 | $SED $filter_`
]
)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment