From 8a859540c3cb306844288144a06028dc302408d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Sat, 23 Feb 2019 16:35:21 +0100 Subject: Use system libdir when searching for dynamically loaded libraries. This prevents finding an incorrect architecture on multi-arch systems. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Slávek Banko --- CMakeLists.txt | 12 +++++++++ config.h.cmake | 1 + tdecore/ksocks.cpp | 8 +++--- tdeio/kssl/kopenssl.cc | 41 ++++++----------------------- tdeprint/cups/cupsdconf2/cupsdconf.cpp | 13 ++++++--- tdespell2/plugins/ispell/CMakeLists.txt | 1 + tdespell2/plugins/ispell/ispell_checker.cpp | 4 +++ tdeui/ksconfig.cpp | 29 +++++++++++--------- 8 files changed, 56 insertions(+), 53 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d28a2ad6b..0b3541bde 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -141,6 +141,18 @@ if( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" ) endif( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" ) +##### get the system's default path for libraries + +tde_save_and_set( CMAKE_INSTALL_PREFIX "/usr" ) +include( GNUInstallDirs OPTIONAL ) +if( CMAKE_INSTALL_LIBDIR ) + set( SYSTEM_LIBDIR "${CMAKE_INSTALL_LIBDIR}" ) +else( ) + set( SYSTEM_LIBDIR "lib${LIB_SUFFIX}" ) +endif( ) +tde_restore( CMAKE_INSTALL_PREFIX ) + + ##### check for compiler capabilities ########### include( CheckCXXCompilerFlag ) diff --git a/config.h.cmake b/config.h.cmake index 668ecdbcb..da39e9912 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -790,6 +790,7 @@ /* Suffix for lib directories */ #define KDELIBSUFF "@KDELIBSUFF@" +#define SYSTEM_LIBDIR "@SYSTEM_LIBDIR@" /* The compiled in system configuration prefix */ #define KDESYSCONFDIR "@CONFIG_INSTALL_DIR@" diff --git a/tdecore/ksocks.cpp b/tdecore/ksocks.cpp index a6ecc37d2..6fac3179e 100644 --- a/tdecore/ksocks.cpp +++ b/tdecore/ksocks.cpp @@ -254,13 +254,13 @@ KSocks::KSocks(TDEConfigBase *config) : _socksLib(0L), _st(0L) { return; _libPaths << "" - << "/usr/lib" KDELIBSUFF "/" + << "/usr/" SYSTEM_LIBDIR "/" << "/usr/lib/" - << "/usr/local/lib" KDELIBSUFF "/" + << "/usr/local/" SYSTEM_LIBDIR "/" << "/usr/local/lib/" - << "/usr/local/socks5/lib" KDELIBSUFF "/" + << "/usr/local/socks5/" SYSTEM_LIBDIR "/" << "/usr/local/socks5/lib/" - << "/opt/socks5/lib" KDELIBSUFF "/" + << "/opt/socks5/" SYSTEM_LIBDIR "/" << "/opt/socks5/lib/"; _libNames << "libsocks.so" // Dante << "libdsocksd.so.0" // Dante 1.1.14-2 on diff --git a/tdeio/kssl/kopenssl.cc b/tdeio/kssl/kopenssl.cc index ded836fde..9c6d47ad4 100644 --- a/tdeio/kssl/kopenssl.cc +++ b/tdeio/kssl/kopenssl.cc @@ -28,7 +28,6 @@ #include #include #include -#include #include #include @@ -324,7 +323,7 @@ TDEConfig *cfg; #ifdef __OpenBSD__ { - TQString libname = findMostRecentLib("/usr/lib" KDELIBSUFF, "crypto"); + TQString libname = findMostRecentLib("/usr/" SYSTEM_LIBDIR, "crypto"); if (!libname.isNull()) _cryptoLib = ll->globalLibrary(libname.latin1()); } @@ -349,13 +348,13 @@ TDEConfig *cfg; #ifdef _AIX << "/opt/freeware/lib/" #endif - << "/usr/lib" KDELIBSUFF "/" - << "/usr/ssl/lib" KDELIBSUFF "/" - << "/usr/local/lib" KDELIBSUFF "/" - << "/usr/local/openssl/lib" KDELIBSUFF "/" - << "/usr/local/ssl/lib" KDELIBSUFF "/" - << "/opt/openssl/lib" KDELIBSUFF "/" - << "/lib" KDELIBSUFF "/" + << "/usr/" SYSTEM_LIBDIR "/" + << "/usr/ssl/" SYSTEM_LIBDIR "/" + << "/usr/local/" SYSTEM_LIBDIR "/" + << "/usr/local/openssl/" SYSTEM_LIBDIR "/" + << "/usr/local/ssl/" SYSTEM_LIBDIR "/" + << "/opt/openssl/" SYSTEM_LIBDIR "/" + << "/" SYSTEM_LIBDIR "/" << ""; // FIXME: #define here for the various OS types to optimize @@ -408,18 +407,6 @@ TDEConfig *cfg; tmpStr.replace(TQRegExp("\\(.*\\)"), ""); if (!access(tmpStr.latin1(), R_OK)) _cryptoLib = ll->globalLibrary(alib.latin1()); - if (!_cryptoLib) { - // Multiarch triplet search - TQDir madir (*it); - TQStringList multiarchdirs = madir.entryList("*-*-*", TQDir::Dirs); - for (TQStringList::Iterator mait = multiarchdirs.begin(); mait != multiarchdirs.end(); ++mait ) { - TQString malib = *it + *mait + "/" + *shit; - TQString tmpStr(malib.latin1()); - tmpStr.replace(TQRegExp("\\(.*\\)"), ""); - if (!access(tmpStr.latin1(), R_OK)) - _cryptoLib = ll->globalLibrary(malib.latin1()); - } - } if (_cryptoLib) break; } if (_cryptoLib) break; @@ -611,18 +598,6 @@ TDEConfig *cfg; tmpStr.replace(TQRegExp("\\(.*\\)"), ""); if (!access(tmpStr.latin1(), R_OK)) _sslLib = ll->globalLibrary(alib.latin1()); - if (!_sslLib) { - // Multiarch triplet search - TQDir madir (*it); - TQStringList multiarchdirs = madir.entryList("*-*-*", TQDir::Dirs); - for (TQStringList::Iterator mait = multiarchdirs.begin(); mait != multiarchdirs.end(); ++mait ) { - TQString malib = *it + *mait + "/" + *shit; - TQString tmpStr(malib.latin1()); - tmpStr.replace(TQRegExp("\\(.*\\)"), ""); - if (!access(tmpStr.latin1(), R_OK)) - _sslLib = ll->globalLibrary(malib.latin1()); - } - } if (_sslLib) break; } if (_sslLib) break; diff --git a/tdeprint/cups/cupsdconf2/cupsdconf.cpp b/tdeprint/cups/cupsdconf2/cupsdconf.cpp index 2c5610411..5cfab057d 100644 --- a/tdeprint/cups/cupsdconf2/cupsdconf.cpp +++ b/tdeprint/cups/cupsdconf2/cupsdconf.cpp @@ -71,10 +71,15 @@ CupsdConf::CupsdConf() //fontpath_ << (datadir_+"/fonts"); requestdir_ = findDir(TQStringList("/var/spool/cups") << "/var/cups"); - serverbin_ = findDir(TQStringList("/usr/lib" KDELIBSUFF "/cups") - << "/usr/local/lib" KDELIBSUFF "/cups" - << "/opt/lib" KDELIBSUFF "/cups" - << "/opt/local/lib" KDELIBSUFF "/cups"); + serverbin_ = findDir(TQStringList() + << "/usr/" SYSTEM_LIBDIR "/cups" + << "/usr/lib/cups" + << "/usr/local/" SYSTEM_LIBDIR "/cups" + << "/usr/local/lib/cups" + << "/opt/" SYSTEM_LIBDIR "/cups" + << "/opt/lib/cups" + << "/opt/local/" SYSTEM_LIBDIR "/cups" + << "/opt/local/lib/cups"); serverfiles_ = findDir(TQStringList("/etc/cups") << "/usr/local/etc/cups"); tmpfiles_ = requestdir_+"/tmp"; diff --git a/tdespell2/plugins/ispell/CMakeLists.txt b/tdespell2/plugins/ispell/CMakeLists.txt index c8e5a4ec6..62b12a1a1 100644 --- a/tdespell2/plugins/ispell/CMakeLists.txt +++ b/tdespell2/plugins/ispell/CMakeLists.txt @@ -12,6 +12,7 @@ include_directories( ${TQT_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/tdecore ${CMAKE_SOURCE_DIR}/tdespell2 ${CMAKE_SOURCE_DIR}/tdecore diff --git a/tdespell2/plugins/ispell/ispell_checker.cpp b/tdespell2/plugins/ispell/ispell_checker.cpp index c07d9a55f..387997444 100644 --- a/tdespell2/plugins/ispell/ispell_checker.cpp +++ b/tdespell2/plugins/ispell/ispell_checker.cpp @@ -29,6 +29,8 @@ * do so, delete this exception statement from your version. */ +#include + #include #include #include @@ -53,7 +55,9 @@ typedef struct str_ispell_map } IspellMap; static const char *ispell_dirs [] = { + "/usr/" SYSTEM_LIBDIR "/ispell", "/usr/lib/ispell", + "/usr/local/" SYSTEM_LIBDIR "/ispell", "/usr/local/lib/ispell", "/usr/local/share/ispell", "/usr/share/ispell", diff --git a/tdeui/ksconfig.cpp b/tdeui/ksconfig.cpp index 234882939..6ae9e3d5f 100644 --- a/tdeui/ksconfig.cpp +++ b/tdeui/ksconfig.cpp @@ -444,20 +444,25 @@ void KSpellConfig::getAvailDictsIspell () { dictcombo->insertItem( i18n("ISpell Default") ); // dictionary path - TQFileInfo dir ("/usr/lib" KDELIBSUFF "/ispell"); - if (!dir.exists() || !dir.isDir()) - dir.setFile ("/usr/local/lib" KDELIBSUFF "/ispell"); - if (!dir.exists() || !dir.isDir()) - dir.setFile ("/usr/local/share/ispell"); - if (!dir.exists() || !dir.isDir()) - dir.setFile ("/usr/share/ispell"); - if (!dir.exists() || !dir.isDir()) - dir.setFile ("/usr/pkg/lib"); + TQFileInfo dir; + TQStringList dirs; + dirs + << "/usr/" SYSTEM_LIBDIR "/ispell" + << "/usr/lib/ispell" + << "/usr/local/" SYSTEM_LIBDIR "/ispell" + << "/usr/local/lib/ispell" + << "/usr/local/share/ispell" + << "/usr/share/ispell" + << "/usr/pkg/lib"; + for (TQStringList::ConstIterator it=dirs.begin(); it != dirs.end(); ++it) { + dir.setFile(*it); + if (dir.exists() && dir.isDir()) { + break; + } + } /* TODO get them all instead of just one of them. * If /usr/local/lib exists, it skips the rest - if (!dir.exists() || !dir.isDir()) - dir.setFile ("/usr/local/lib"); - */ + */ if (!dir.exists() || !dir.isDir()) return; kdDebug(750) << "KSpellConfig::getAvailDictsIspell " -- cgit v1.2.3