[PATCH v2] Try to read the libdivecomputer.la file (created by GNU libtool)

Thiago Macieira thiago at macieira.org
Wed Oct 9 17:40:25 UTC 2013


Getting dependency information for static libraries requires extra
files. Libtool creates .la files, which are "industry standard". qmake
has its own .prl files, but it can create .la in a pinch if necessary.

This change allows us to get the actual dependency information from
libdivecomputer, without having to guess whether it linked to something
else or not. If it changes in the future, we shouldn't have to do
anything.

Signed-off-by: Thiago Macieira <thiago at macieira.org>
---
 subsurface-configure.pri | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/subsurface-configure.pri b/subsurface-configure.pri
index d75af3c..dc98867 100644
--- a/subsurface-configure.pri
+++ b/subsurface-configure.pri
@@ -42,20 +42,28 @@ PKG_CONFIG_OUT = $$system(pkg-config --version 2> $$NUL)
     # find it next to our sources
     INCLUDEPATH += ../libdivecomputer/include
     LIBS += ../libdivecomputer/src/.libs/libdivecomputer.a
+    LIBDC_LA = ../libdivecomputer/src/libdivecomputer.la
 } else:exists(/usr/local/lib/libdivecomputer.a) {
     LIBS += /usr/local/lib/libdivecomputer.a
+    LIBDC_LA = /usr/local/lib/libdivecomputer.la
 } else:exists(/usr/local/lib64/libdivecomputer.a) {
     LIBS += /usr/local/lib64/libdivecomputer.a
+    LIBDC_LA = /usr/local/lib64/libdivecomputer.la
 } else:link_pkgconfig {
-    # find it via pkg-config
-    PKGCONFIG += libdivecomputer
+    # find it via pkg-config, but we need to pass the --static flag,
+    # so we can't use the PKGCONFIG variable.
+    LIBS += $$system("pkg-config --static --libs libdivecomputer")
+    LIBDC_CFLAGS = $$system("pkg-config --static --cflags libdivecomputer")
+    QMAKE_CFLAGS += $$LIBDC_CFLAGS
+    QMAKE_CXXFLAGS += $$LIBDC_CFLAGS
+    unset(LIBDC_CFLAGS)
 }
 
-# Libusb-1.0 is only required if libdivecomputer was built with it.
-# And libdivecomputer is only built with it if libusb-1.0 is
-# installed. So get libusb if it exists, but don't complain
-# about it if it doesn't.
-link_pkgconfig: packagesExist(libusb-1.0): PKGCONFIG += libusb-1.0
+!isEmpty(LIBDC_LA):exists($$LIBDC_LA) {
+    # Source the libtool .la file to get the dependent libs
+    LIBS += $$system(". $$LIBDC_LA && echo \$dependency_libs")
+    unset(LIBDC_LA)
+}
 
 #
 # Find libxml2 and libxslt
-- 
1.7.11.7



More information about the subsurface mailing list