]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Makefile: link gtest statically
authorSage Weil <sage@inktank.com>
Wed, 13 Jun 2012 18:05:43 +0000 (11:05 -0700)
committerSage Weil <sage@inktank.com>
Wed, 13 Jun 2012 18:05:53 +0000 (11:05 -0700)
The problem:

 - the unittests link against gtest, and gtest is not installed.  that's
   normally fine, but...
 - rbd and rados api unit tests link against gtest, and are installed
   by 'make install'.  they are needed for teuthology runs, etc.
 - if we build gtest as an .la library, we can only control whether *all*
   or *no* .la libraries are linked statically.
 - we want librados to be linked dynamically.

The solution:

 - build gtest as .a instead of a libtool library
 - link it statically, always.

Unit test binaries are bigger now.  Oh well...

Fixes: #2331
Signed-off-by: Sage Weil <sage@inktank.com>
Makefile.am
src/Makefile.am
src/gtest/Makefile.am
src/gtest/scripts/gtest-config.in

index 3a73edfa6c25fa11eb2ca5b3d8af8bd8a7c34fd4..b938f916d54fd88bc96fd7829f44e411effc4e7b 100644 (file)
@@ -15,13 +15,13 @@ all-local:
 if WITH_DEBUG
 #      We need gtest to build the rados-api tests. We only build those in
 #      a debug build, though.
-       @cd src/gtest && $(MAKE) $(AM_MAKEFLAGS) lib/libgtest.la lib/libgtest_main.la lib/libgtest.a lib/libgtest_main.a
+       @cd src/gtest && $(MAKE) $(AM_MAKEFLAGS) lib/libgtest.a lib/libgtest_main.a
 endif
 
 check-local:
 #      We build gtest this way, instead of using SUBDIRS, because with that,
 #      gtest's own tests would be run and that would slow us down.
-       @cd src/gtest && $(MAKE) $(AM_MAKEFLAGS) lib/libgtest.la lib/libgtest_main.la
+       @cd src/gtest && $(MAKE) $(AM_MAKEFLAGS) lib/libgtest.a lib/libgtest_main.a
 #      exercise cli tools
        $(srcdir)/src/test/run-cli-tests '$(top_builddir)/src/test'
 
index c02f4c317489cbcc5242c1464a1579ceab94985a..ea800587806ec17566d5b9bfe9389fe2809802fc 100644 (file)
@@ -504,14 +504,11 @@ unittests:: $(check_PROGRAMS)
 UNITTEST_CXXFLAGS = \
        -I$(top_srcdir)/src/gtest/include \
        -I$(top_builddir)/src/gtest/include
-UNITTEST_LDADD = \
-       $(top_builddir)/src/gtest/lib/libgtest.la \
-       $(top_builddir)/src/gtest/lib/libgtest_main.la \
-       $(PTHREAD_LIBS)
 UNITTEST_STATIC_LDADD = \
        $(top_builddir)/src/gtest/lib/libgtest.a \
        $(top_builddir)/src/gtest/lib/libgtest_main.a \
        $(PTHREAD_LIBS)
+UNITTEST_LDADD = ${UNITTEST_STATIC_LDADD}
 
 unittest_encoding_SOURCES = test/encoding.cc
 unittest_encoding_LDADD = libcephfs.la librados.la $(PTHREAD_LIBS) -lm \
index 91858550283e0d2f909c4d725656b39ce667802c..4f97c6fff4894499d6a254a7d4685ef158069dd6 100644 (file)
@@ -179,10 +179,8 @@ else
 endif
 
 # Build rules for libraries.
-lib_LTLIBRARIES = lib/libgtest.la lib/libgtest_main.la
-lib_LTLIBRARIES += lib/libgtest.a lib/libgtest_main.a
+lib_LIBRARIES = lib/libgtest.a lib/libgtest_main.a
 
-lib_libgtest_la_SOURCES = src/gtest-all.cc
 lib_libgtest_a_SOURCES = src/gtest-all.cc
 
 pkginclude_HEADERS = include/gtest/gtest.h \
@@ -208,9 +206,6 @@ pkginclude_internal_HEADERS = \
   include/gtest/internal/gtest-tuple.h \
   include/gtest/internal/gtest-type-util.h
 
-lib_libgtest_main_la_SOURCES = src/gtest_main.cc
-lib_libgtest_main_la_LIBADD = lib/libgtest.la
-
 lib_libgtest_main_a_SOURCES = src/gtest_main.cc
 lib_libgtest_main_a_LIBADD = lib/libgtest.a
 
@@ -247,7 +242,7 @@ samples_sample1_unittest_LDADD = lib/libgtest_main.la \
 TESTS += samples/sample10_unittest
 check_PROGRAMS += samples/sample10_unittest
 samples_sample10_unittest_SOURCES = samples/sample10_unittest.cc
-samples_sample10_unittest_LDADD = lib/libgtest.la
+samples_sample10_unittest_LDADD = lib/libgtest.a
 
 # This tests most constructs of gtest and verifies that libgtest_main
 # works.
index 9c7263854b9f863b618c708de1efe0e8b1f7280a..68712923c236a166f842a46eaeb2b818dbc1cd29 100755 (executable)
@@ -214,7 +214,7 @@ if test "${this_bindir}" = "${this_bindir%${bindir}}"; then
   # TODO(chandlerc@google.com): This is a dangerous dependency on libtool, we
   # should work to remove it, and/or remove libtool altogether, replacing it
   # with direct references to the library and a link path.
-  gtest_libs="${build_dir}/lib/libgtest.la @PTHREAD_CFLAGS@ @PTHREAD_LIBS@"
+  gtest_libs="${build_dir}/lib/libgtest.a @PTHREAD_CFLAGS@ @PTHREAD_LIBS@"
   gtest_ldflags=""
 
   # We provide hooks to include from either the source or build dir, where the