From 66b9557833485285e21462f0bcf47533b50e35ea Mon Sep 17 00:00:00 2001 From: AsamK Date: Sat, 5 Sep 2015 23:48:24 +0200 Subject: [PATCH] Use PKGCONFIG instead of manually specifying LIBS for Linux - The advantage is that this method automatically includes additional dependencies of LIBS (e.g. libupnp needs -lixml). - Also if some distribution moves headers to non default locations the correct locations get added by PKGCONFIG --- libbitdht/src/libbitdht.pro | 2 -- libresapi/src/libresapi.pro | 8 +++++++ libretroshare/src/libretroshare.pro | 26 +++++++++-------------- plugins/FeedReader/FeedReader.pro | 8 ++----- plugins/VOIP/VOIP.pro | 7 +++--- retroshare-gui/src/retroshare-gui.pro | 12 +++++------ retroshare-nogui/src/retroshare-nogui.pro | 4 ++-- supportlibs/pegmarkdown/pegmarkdown.pro | 5 +++-- 8 files changed, 34 insertions(+), 38 deletions(-) diff --git a/libbitdht/src/libbitdht.pro b/libbitdht/src/libbitdht.pro index 7d6dca1d6..fcc6eb473 100644 --- a/libbitdht/src/libbitdht.pro +++ b/libbitdht/src/libbitdht.pro @@ -168,5 +168,3 @@ SOURCES += \ bitdht/bdquerymgr.cc \ util/bdbloom.cc \ bitdht/bdfriendlist.cc \ - - diff --git a/libresapi/src/libresapi.pro b/libresapi/src/libresapi.pro index a45255e45..d814219db 100644 --- a/libresapi/src/libresapi.pro +++ b/libresapi/src/libresapi.pro @@ -2,8 +2,10 @@ TEMPLATE = lib CONFIG += staticlib +CONFIG += create_prl CONFIG -= qt TARGET = resapi +TARGET_PRL = libresapi DESTDIR = lib CONFIG += libmicrohttpd @@ -26,6 +28,12 @@ win32{ } libmicrohttpd{ + linux { + CONFIG += link_pkgconfig + PKGCONFIG *= libmicrohttpd + } else { + LIBS *= -lmicrohttpd + } SOURCES += \ api/ApiServerMHD.cpp diff --git a/libretroshare/src/libretroshare.pro b/libretroshare/src/libretroshare.pro index 57ae12601..b814503cf 100644 --- a/libretroshare/src/libretroshare.pro +++ b/libretroshare/src/libretroshare.pro @@ -120,8 +120,7 @@ HEADERS += $$PUBLIC_HEADERS ################################# Linux ########################################## linux-* { - # These two lines fixe compilation on ubuntu natty. Probably a ubuntu packaging error. - INCLUDEPATH += $$system(pkg-config --cflags glib-2.0 | sed -e "s/-I//g") + CONFIG += link_pkgconfig OPENPGPSDK_DIR = ../../openpgpsdk/src DEPENDPATH *= $${OPENPGPSDK_DIR} ../openpgpsdk @@ -131,17 +130,12 @@ linux-* { QMAKE_CXXFLAGS *= -Wall -D_FILE_OFFSET_BITS=64 QMAKE_CC = g++ - SSL_DIR = /usr/include/openssl - UPNP_DIR = /usr/include/upnp - DEPENDPATH += . $${SSL_DIR} $${UPNP_DIR} - INCLUDEPATH += . $${SSL_DIR} $${UPNP_DIR} - contains(CONFIG, NO_SQLCIPHER) { DEFINES *= NO_SQLCIPHER - LIBS *= -lsqlite3 + PKGCONFIG *= sqlite3 } else { - SQLCIPHER_OK = $$system(pkg-config --exists sqlcipher && echo yes) - isEmpty(SQLCIPHER_OK) { + SQLCIPHER_OK = $$system(pkg-config --exists sqlcipher && echo yes) + isEmpty(SQLCIPHER_OK) { # We need a explicit path here, to force using the home version of sqlite3 that really encrypts the database. exists(../../../lib/sqlcipher/.libs/libsqlcipher.a) { LIBS += ../../../lib/sqlcipher/.libs/libsqlcipher.a @@ -151,7 +145,7 @@ linux-* { error("libsqlcipher is not installed and libsqlcipher.a not found. SQLCIPHER is necessary for encrypted database, to build with unencrypted database, run: qmake CONFIG+=NO_SQLCIPHER") } } else { - LIBS *= -lsqlcipher + PKGCONFIG *= sqlcipher } } @@ -163,7 +157,7 @@ linux-* { CONFIG += upnp_libupnp # Check if the systems libupnp has been Debian-patched - system(grep -E 'char[[:space:]]+PublisherUrl' $${UPNP_DIR}/upnp.h >/dev/null 2>&1) { + system(grep -E 'char[[:space:]]+PublisherUrl' /usr/include/upnp/upnp.h >/dev/null 2>&1) { # Normal libupnp } else { # Patched libupnp or new unreleased version @@ -171,10 +165,10 @@ linux-* { } DEFINES *= UBUNTU - INCLUDEPATH += /usr/include/glib-2.0/ /usr/lib/glib-2.0/include - LIBS *= -lgnome-keyring - LIBS *= -lssl -lupnp -lixml - LIBS *= -lcrypto -lz -lpthread + PKGCONFIG *= gnome-keyring-1 + PKGCONFIG *= libssl libupnp + PKGCONFIG *= libcrypto zlib + LIBS *= -lpthread -ldl } unix { diff --git a/plugins/FeedReader/FeedReader.pro b/plugins/FeedReader/FeedReader.pro index 4cebc5f48..b415b5711 100644 --- a/plugins/FeedReader/FeedReader.pro +++ b/plugins/FeedReader/FeedReader.pro @@ -81,12 +81,9 @@ TRANSLATIONS += \ lang/FeedReader_zh_CN.ts linux-* { - LIBXML2_DIR = /usr/include/libxml2 + CONFIG += link_pkgconfig - DEPENDPATH += $${LIBXML2_DIR} - INCLUDEPATH += $${LIBXML2_DIR} - - LIBS += -lcurl -lxml2 -lxslt + PKGCONFIG *= libcurl libxml-2.0 libxslt } win32 { @@ -102,4 +99,3 @@ openbsd-* { LIBS += -lcurl -lxml2 -lxslt } - diff --git a/plugins/VOIP/VOIP.pro b/plugins/VOIP/VOIP.pro index 013a5c39e..dde97ea93 100644 --- a/plugins/VOIP/VOIP.pro +++ b/plugins/VOIP/VOIP.pro @@ -21,10 +21,11 @@ INCLUDEPATH += ../../retroshare-gui/src/temp/ui ../../libretroshare/src linux-* { CONFIG += link_pkgconfig - # Necessary for openSUSE PKGCONFIG += libavcodec libavutil - + PKGCONFIG += speex speexdsp PKGCONFIG += opencv +} else { + LIBS += -lspeex -lspeexdsp -lavcodec -lavutil } win32 { @@ -103,5 +104,3 @@ TRANSLATIONS += \ lang/VOIP_sv.ts \ lang/VOIP_tr.ts \ lang/VOIP_zh_CN.ts - -LIBS += -lspeex -lspeexdsp -lavcodec -lavutil diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index db03e2df5..2af6d874f 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -1,8 +1,10 @@ !include("../../retroshare.pri"): error("Could not include file ../../retroshare.pri") +TEMPLATE = app QT += network xml CONFIG += qt gui uic qrc resources idle bitdht CONFIG += link_prl +TARGET = RetroShare06 # Plz never commit the .pro with these flags enabled. # Use this flag when developping new features only. @@ -34,9 +36,6 @@ CONFIG += gxsgui #CONFIG += framecatcher #CONFIG += blogs -TEMPLATE = app -TARGET = RetroShare06 - DEFINES += RS_RELEASE_VERSION RCC_DIR = temp/qrc UI_DIR = temp/ui @@ -61,15 +60,16 @@ INCLUDEPATH *= retroshare-gui ################################# Linux ########################################## # Put lib dir in QMAKE_LFLAGS so it appears before -L/usr/lib linux-* { + CONFIG += link_pkgconfig #CONFIG += version_detail_bash_script QMAKE_CXXFLAGS *= -D_FILE_OFFSET_BITS=64 PRE_TARGETDEPS *= ../../libretroshare/src/lib/libretroshare.a LIBS += ../../libretroshare/src/lib/libretroshare.a - LIBS *= -lX11 -lXss + PKGCONFIG *= x11 xscrnsaver - LIBS *= -rdynamic -ldl + LIBS *= -rdynamic DEFINES *= HAVE_XSS # for idle time, libx screensaver extensions DEFINES *= UBUNTU } @@ -289,7 +289,7 @@ wikipoos { DEPENDPATH += ../../libresapi/src INCLUDEPATH += ../../libresapi/src PRE_TARGETDEPS *= ../../libresapi/src/lib/libresapi.a -LIBS += ../../libresapi/src/lib/libresapi.a -lmicrohttpd +LIBS += ../../libresapi/src/lib/libresapi.a # Input HEADERS += rshare.h \ diff --git a/retroshare-nogui/src/retroshare-nogui.pro b/retroshare-nogui/src/retroshare-nogui.pro index cb4b79bac..201896155 100644 --- a/retroshare-nogui/src/retroshare-nogui.pro +++ b/retroshare-nogui/src/retroshare-nogui.pro @@ -27,7 +27,7 @@ linux-* { QMAKE_CXXFLAGS *= -D_FILE_OFFSET_BITS=64 LIBS += ../../libretroshare/src/lib/libretroshare.a - LIBS *= -rdynamic -ldl + LIBS *= -rdynamic } unix { @@ -169,7 +169,7 @@ introserver { webui { DEFINES *= ENABLE_WEBUI PRE_TARGETDEPS *= ../../libresapi/src/lib/libresapi.a - LIBS += ../../libresapi/src/lib/libresapi.a -lmicrohttpd + LIBS += ../../libresapi/src/lib/libresapi.a DEPENDPATH += ../../libresapi/src INCLUDEPATH += ../../libresapi/src HEADERS += \ diff --git a/supportlibs/pegmarkdown/pegmarkdown.pro b/supportlibs/pegmarkdown/pegmarkdown.pro index ca818cc39..e43e0c1ad 100644 --- a/supportlibs/pegmarkdown/pegmarkdown.pro +++ b/supportlibs/pegmarkdown/pegmarkdown.pro @@ -15,8 +15,9 @@ debug { ################################# Linux ########################################## linux-* { - DESTDIR = lib - LIBS *= -lglib-2.0 + CONFIG += link_pkgconfig + + PKGCONFIG *= glib-2.0 } linux-g++ {