libebook-contacts: Always use the C linker
authorMathias Hasselmann <mathias@openismus.com>
Thu, 7 Mar 2013 11:23:29 +0000 (12:23 +0100)
committerMathias Hasselmann <mathias@openismus.com>
Thu, 7 Mar 2013 13:05:09 +0000 (14:05 +0100)
Ensure that libebook-contacts always gets linked using the C linker,
instead of the C++ automake would prefer, because of the optional
e-phone-number-private.cpp file. Without this change linking with
explicitly disabled phone number support (--without-phonenumber)
would fail because no C++ linker is know. Similarly the library
would depend on the C++ standard library if phone number was
disabled automatically, because libphonenumber was not found.

addressbook/libebook-contacts/Makefile.am
configure.ac

index 05fd112..863a4c9 100644 (file)
@@ -17,6 +17,11 @@ MARSHAL_GENERATED = e-book-contacts-marshal.c e-book-contacts-marshal.h
 
 # The library
 lib_LTLIBRARIES = libebook-contacts-1.2.la
+noinst_LTLIBRARIES =
+
+if ENABLE_PHONENUMBER
+noinst_LTLIBRARIES += libephonenumber-private.la
+endif # ENABLE_PHONENUMBER
 
 libebook_contacts_1_2_la_CPPFLAGS = \
        $(AM_CPPFLAGS)                                  \
@@ -52,12 +57,6 @@ libebook_contacts_1_2_la_LIBADD =                                    \
        $(EVOLUTION_ADDRESSBOOK_LIBS)                           \
        $(CAMEL_LIBS)
 
-if ENABLE_PHONENUMBER
-libebook_contacts_1_2_la_SOURCES += e-phone-number-private.cpp
-libebook_contacts_1_2_la_CPPFLAGS += $(PHONENUMBER_INCLUDES)
-libebook_contacts_1_2_la_LIBADD += $(PHONENUMBER_LIBS)
-endif # ENABLE_PHONENUMBER
-
 libebook_contacts_1_2_la_LDFLAGS =                                                     \
        -version-info $(LIBEBOOK_CONTACTS_CURRENT):$(LIBEBOOK_CONTACTS_REVISION):$(LIBEBOOK_CONTACTS_AGE) $(NO_UNDEFINED) \
        $(CODE_COVERAGE_LDFLAGS) \
@@ -77,6 +76,18 @@ libebookcontactsinclude_HEADERS =                    \
        e-phone-number.h                                \
        e-source-backend-summary-setup.h
 
+if ENABLE_PHONENUMBER
+
+# We put the C++ code into a separate static library, so that we can use
+# the C linker for libebook-contacts. This avoids that libebook-contacts
+# depends on the C++ Standard Library, even if phone number support is
+# disabled.
+libephonenumber_private_la_SOURCES = e-phone-number-private.cpp
+libephonenumber_private_la_CPPFLAGS = $(libebook_contacts_1_2_la_CPPFLAGS) $(PHONENUMBER_INCLUDES)
+libebook_contacts_1_2_la_LIBADD += @predeps_CXX@ libephonenumber-private.la $(PHONENUMBER_LIBS) @postdeps_CXX@
+
+endif # ENABLE_PHONENUMBER
+
 %-$(API_VERSION).pc: %.pc
         cp $< $@
 
index 88d1c22..511d03b 100644 (file)
@@ -231,6 +231,10 @@ else
        am__fastdepCXX_FALSE=
 fi
 
+dnl Permits linking of C++ based libraries using the C linker if needed.
+AC_SUBST([predeps_CXX])
+AC_SUBST([postdeps_CXX])
+
 dnl *******************************
 dnl Check for --enable-strict
 dnl *******************************