Make folly pkg-config more usable on OS X
authorJacob Bower <jbower@fb.com>
Thu, 22 Dec 2016 06:10:37 +0000 (22:10 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 22 Dec 2016 06:18:35 +0000 (22:18 -0800)
Summary:
As part of open-sourcing the Watchman C++ client I'm adding an (optional) dependency in Watchman to Folly. When I tried to build this client with Folly on OS X I ran into some problems using the libfolly pkg-config file. This diff addresses these issues:

1. When using `build/bootstrap-osx-homebrew.sh`, the compile config for gflags and OpenSSL are overriden. If present, these custom flags will now be propagated to `libfolly.pc`.
2. I changed the the package requirements in `libfolly.pc` from `Requires.private` to just `Requires`.

Both of these changes are needed as much of Folly's implementation is in header files. As such, consumers of libfolly need to use the same library/include paths when building.

Reviewed By: yfeldblum

Differential Revision: D4332720

fbshipit-source-id: 6a051ae318ac10bdeb4dc383a16de81f1c0327bb

folly/build/bootstrap-osx-homebrew.sh
folly/configure.ac
folly/libfolly.pc.in

index af8c20111b5bdea1f5bbc465a9efbaf1a2c98f9b..14a02670500c3ddf4e67cfbc89ddf0b36267c880 100755 (executable)
@@ -30,9 +30,9 @@ export_flags() {
        OPT_GFLAGS=$(brew --prefix gflags)
        OPT_OPENSSL=$(brew --prefix openssl)
 
-       # export LDFLAGS
+       # export flags
        export LDFLAGS=-L${OPT_OPENSSL}/lib
-       export CPPFLAGS=-I${OPT_OPENSSL}/include
+       export OPENSSL_INCLUDES=-I${OPT_OPENSSL}/include
        export GFLAGS_LIBS=-L${OPT_GFLAGS}/lib
        export GFLAGS_CFLAGS=-I${OPT_GFLAGS}/include
 }
index 6da4404843540312b23287141254da166f3c8209..14bff8b984b491017309215c4a8bf6600cd448bc 100644 (file)
@@ -130,8 +130,18 @@ if test "$folly_cv_prog_cc_glog" != "yes"; then
 fi
 FB_CHECK_PKG_CONFIG([GLOG], [libglog])
 
-AX_CHECK_OPENSSL([],
-        [AC_MSG_ERROR(["Error: libssl required"])])
+AS_IF(
+  [test "x$OPENSSL_INCLUDES" = "x"],
+  [
+    AX_CHECK_OPENSSL([], [AC_MSG_ERROR(["Error: libssl required"])])
+  ],
+  [
+    # AX_CHECK_OPENSSL doesn't seem to play nice with builds started
+    # via build/bootstrap-osx-homebrew.sh
+    AC_MSG_WARN(["Using existing OpenSSL flags from environment."])
+    PKG_CXXFLAGS="$PKG_CXXFLAGS $OPENSSL_INCLUDES"
+  ]
+)
 FB_CHECK_PKG_CONFIG([OPENSSL], [openssl])
 
 # check for boost libs
@@ -602,7 +612,7 @@ AS_IF([test "x${mobile}" = "xyes"], [
 
 # Include directory that contains "folly" so #include <folly/Foo.h> works
 AM_CPPFLAGS='-I$(top_srcdir)/..'
-AM_CPPFLAGS="$AM_CPPFLAGS $BOOST_CPPFLAGS"
+AM_CPPFLAGS="$AM_CPPFLAGS $BOOST_CPPFLAGS $OPENSSL_INCLUDES"
 AM_LDFLAGS="$AM_LDFLAGS $BOOST_CONTEXT_LIB $BOOST_PROGRAM_OPTIONS_LIB"
 AM_LDFLAGS="$AM_LDFLAGS $BOOST_THREAD_LIB $BOOST_FILESYSTEM_LIB"
 AM_LDFLAGS="$AM_LDFLAGS $BOOST_SYSTEM_LIB $BOOST_REGEX_LIB -lpthread"
index db81ca7bce75036f2cb382baa819c4e54e0da0b0..6fb90a2b125e6085a6b8e62dd1b15928fce2df7d 100644 (file)
@@ -6,7 +6,7 @@ includedir=@includedir@
 Name: libfolly
 Description: Facebook (Folly) C++ library
 Version: @PKG_VERSION@
-Requires.private: @PKG_DEPS@
+Requires: @PKG_DEPS@
 Libs.private: @PKG_LIBS@
 Libs: -L${libdir} -lfolly
 Cflags: -I${includedir} @PKG_CXXFLAGS@