diff options
author | Sage Weil <sage@inktank.com> | 2012-06-13 11:05:43 -0700 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2012-06-13 11:05:53 -0700 |
commit | 66553d25f09f0d0cea735a862a228060b72c0ce6 (patch) | |
tree | b988a877ba5582bd726f4c67df83898ad6a867f1 | |
parent | c4a607aa1fa8c07455d947a297c72521b4c7df7d (diff) | |
download | ceph-66553d25f09f0d0cea735a862a228060b72c0ce6.tar.gz |
Makefile: link gtest statically
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>
-rw-r--r-- | Makefile.am | 4 | ||||
-rw-r--r-- | src/Makefile.am | 5 | ||||
-rw-r--r-- | src/gtest/Makefile.am | 9 | ||||
-rwxr-xr-x | src/gtest/scripts/gtest-config.in | 2 |
4 files changed, 6 insertions, 14 deletions
diff --git a/Makefile.am b/Makefile.am index 3a73edfa6c2..b938f916d54 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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' diff --git a/src/Makefile.am b/src/Makefile.am index c02f4c31748..ea800587806 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 \ diff --git a/src/gtest/Makefile.am b/src/gtest/Makefile.am index 91858550283..4f97c6fff48 100644 --- a/src/gtest/Makefile.am +++ b/src/gtest/Makefile.am @@ -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. diff --git a/src/gtest/scripts/gtest-config.in b/src/gtest/scripts/gtest-config.in index 9c7263854b9..68712923c23 100755 --- a/src/gtest/scripts/gtest-config.in +++ b/src/gtest/scripts/gtest-config.in @@ -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 |