Make advanced init function for test optional
authorDenis Samoylov <den@fb.com>
Fri, 29 Jan 2016 18:18:01 +0000 (10:18 -0800)
committerfacebook-github-bot-4 <folly-bot@fb.com>
Fri, 29 Jan 2016 19:20:26 +0000 (11:20 -0800)
Summary: In order to avoid mandatory dependncy on elf, dwarf, unwind made new init function optional

Reviewed By: markisaa

Differential Revision: D2878545

fb-gh-sync-id: f66d3884a531dcf56fc1432330325ab45b149d7f

README.md
folly/Makefile.am
folly/configure.ac
folly/test/Makefile.am

index ad8f49b..cfe1cb0 100644 (file)
--- a/README.md
+++ b/README.md
@@ -50,7 +50,13 @@ sudo apt-get install \
     zlib1g-dev \
     binutils-dev \
     libjemalloc-dev \
-    libssl-dev \
+    libssl-dev 
+```
+
+If advanced dubugging functionality for tests are required
+
+```
+sudo apt-get install \
     libunwind8-dev \
     libelf-dev \
     libdwarf-dev
@@ -166,6 +172,8 @@ Other Linux distributions
     - double-conversion-devel
     - openssl-devel
     - libevent-devel
+
+  Optional
     - libdwarf-dev
     - libelf-dev
     - libunwind8-dev
index 63edfd8..c10e1cf 100644 (file)
@@ -1,4 +1,4 @@
-if HAVE_LINUX
+if FOLLY_TESTMAIN
 SUBDIRS = . experimental init test
 else
 SUBDIRS = . test
index d7ddb65..2a815a0 100644 (file)
@@ -468,9 +468,21 @@ AC_CHECK_HEADER([snappy.h], AC_CHECK_LIB([snappy], [main]))
 AC_CHECK_HEADER([zlib.h], AC_CHECK_LIB([z], [main]))
 AC_CHECK_HEADER([lzma.h], AC_CHECK_LIB([lzma], [main]))
 AC_CHECK_HEADER([zstd.h], AC_CHECK_LIB([zstd], [main]))
-AC_CHECK_HEADERS([libdwarf.h dwarf.h],, AC_MSG_ERROR([Please install libdwarf development package]))
-AC_CHECK_HEADERS([libelf.h elf.h],, AC_MSG_ERROR([Please install libelf development package]))
-AC_CHECK_HEADERS(libunwind.h, ac_cv_have_libunwind_h=1, ac_cv_have_libunwind_h=0)
+
+AC_ARG_ENABLE([follytestmain],
+   AS_HELP_STRING([--enable-follytestmain], [enables using main function from folly for tests]),
+   [follytestmain=${enableval}], [follytestmain=no])
+
+use_follytestmain=yes
+if test "x${follytestmain}" = "xyes"; then
+   AC_CHECK_HEADERS([libdwarf.h dwarf.h],, AC_MSG_ERROR([Please install libdwarf development package]))
+   AC_CHECK_HEADERS([libelf.h elf.h],, AC_MSG_ERROR([Please install libelf development package]))
+   AC_CHECK_HEADERS([libunwind.h],, AC_MSG_ERROR([Please install libinwind development package]))
+else
+   AC_CHECK_HEADERS([libdwarf.h dwarf.h],, [use_follytestmain=no])
+   AC_CHECK_HEADERS([libelf.h elf.h],, [use_follytestmain=no])
+   AC_CHECK_HEADERS([libunwind.h],, [use_follytestmain=no])
+fi
 
 # Include directory that contains "folly" so #include <folly/Foo.h> works
 AM_CPPFLAGS='-I$(top_srcdir)/..'
@@ -493,6 +505,7 @@ AM_CONDITIONAL([HAVE_WEAK_SYMBOLS],
 AM_CONDITIONAL([HAVE_BITS_FUNCTEXCEPT], [test "$ac_cv_header_bits_functexcept_h" = "yes"])
 AM_CONDITIONAL([HAVE_EXTRANDOM_SFMT19937],
                [test "$folly_cv_prog_cc_have_extrandom_sfmt19937" = "yes"])
+AM_CONDITIONAL([FOLLY_TESTMAIN], [test "x${use_follytestmain}" = "xyes"])
 
 # Output
 AC_CONFIG_FILES([Makefile
index 11d6815..641c98c 100644 (file)
@@ -20,7 +20,7 @@ check_PROGRAMS =
 libgtest_la_CPPFLAGS = -Igtest-1.7.0 -Igtest-1.7.0/src
 libgtest_la_SOURCES = gtest-1.7.0/src/gtest-all.cc
 
-if HAVE_LINUX
+if FOLLY_TESTMAIN
 libfollytestmain_la_CPPFLAGS = $(AM_CPPFLAGS) $(libgtest_la_CPPFLAGS)
 libfollytestmain_la_SOURCES = $(libgtest_la_SOURCES) common/TestMain.cpp
 libfollytestmain_la_LIBADD = $(top_builddir)/init/libfollyinit.la $(top_builddir)/libfolly.la