From 3f8fe4095f3672aa84269ff7c2b01560eed7a50d Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Sat, 5 Nov 2016 00:04:13 +0000 Subject: [PATCH] make NSL build dependency Signed-off-by: Ivailo Monev --- CMakeLists.txt | 15 +++++++++++++++ README | 2 +- src/gui/CMakeLists.txt | 8 ++++++++ src/gui/kernel/qcursor_x11.cpp | 2 -- src/gui/painting/qprinterinfo_unix.cpp | 35 +++++++++++++++------------------- src/gui/styles/qgtkstyle.cpp | 1 - 6 files changed, 39 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 520c8cbb3..d40dcde37 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -127,6 +127,9 @@ add_feature_info(sqlite WITH_SQLITE "the world's most popular open source databa option(WITH_RESOLV "Build resolv support" ON) add_feature_info(resolv WITH_RESOLV "an open source something") +option(WITH_NSL "Build nsl support" ON) +add_feature_info(nsl WITH_NSL "an open source something") + option(WITH_X11 "Build X11/X.Org support" ON) add_feature_info(x11 WITH_X11 "an open source something") @@ -443,6 +446,14 @@ set_package_properties(Resolv PROPERTIES TYPE RECOMMENDED ) +find_package(NSL) +set_package_properties(NSL PROPERTIES + PURPOSE "Required for printing information support" + DESCRIPTION "" + URL "" + TYPE RECOMMENDED +) + if(NOT KATIE_BOOTSTRAP) set(CMAKE_THREAD_PREFER_PTHREAD TRUE) @@ -555,6 +566,10 @@ if(NOT WITH_RESOLV OR NOT RESOLV_FOUND) katie_definition(-DQT_NO_RESOLV) endif() +if(NOT WITH_NSL OR NOT NSL_FOUND) + katie_definition(-DQT_NO_NSL) +endif() + # conditional features if(NOT WITH_ACCESSIBILITY) katie_definition(-DQT_NO_ACCESSIBILITY) diff --git a/README b/README index 118a29f71..4bc4b9af7 100644 --- a/README +++ b/README @@ -18,7 +18,7 @@ There are several things you should be aware before considering Katie: - QIconEngineFactoryInterfaceV{2} classes and interfaces have been merged - QKeyEventEx and QKeyEvent classes have been merged - zlib and OpenSSL are required for building - - OpenSSL, D-Bus, CUPS, GTK2, GConf2 and resolv cannot be runtime + - OpenSSL, D-Bus, CUPS, GTK2, GConf2, resolv and NSL cannot be runtime dependencies, they must be linked to during build - QtUiTools is build as shared library by default - moc, uic, rcc, lrelease and idc are linked to components diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index f0f98a3bd..195021cca 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -524,6 +524,14 @@ else() ) endif() +if(WITH_NSL AND NSL_FOUND) + include_directories(${NSL_INCLUDES}) + set(EXTRA_GUI_LIBS + ${EXTRA_GUI_LIBS} + ${NSL_LIBRARIES} + ) +endif() + add_library(KtGui ${KATIE_TYPE} ${KtGui_SOURCES}) target_link_libraries(KtGui ${EXTRA_GUI_LIBS}) set_target_properties(KtGui PROPERTIES diff --git a/src/gui/kernel/qcursor_x11.cpp b/src/gui/kernel/qcursor_x11.cpp index 622620128..a5d3e60b5 100644 --- a/src/gui/kernel/qcursor_x11.cpp +++ b/src/gui/kernel/qcursor_x11.cpp @@ -48,8 +48,6 @@ #include #include -#include - #ifndef QT_NO_XCURSOR # include #endif // QT_NO_XCURSOR diff --git a/src/gui/painting/qprinterinfo_unix.cpp b/src/gui/painting/qprinterinfo_unix.cpp index 89d5347d0..f688c2632 100644 --- a/src/gui/painting/qprinterinfo_unix.cpp +++ b/src/gui/painting/qprinterinfo_unix.cpp @@ -46,7 +46,6 @@ #include #include #include -#include #include #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) @@ -55,6 +54,10 @@ # include #endif +#ifndef QT_NO_NSL +#include +#endif + #include QT_BEGIN_NAMESPACE @@ -439,31 +442,23 @@ int qt_pd_foreach(int /*status */, char * /*key */, int /*keyLen */, int qt_retrieveNisPrinters(QList *printers) { -#ifndef QT_NO_LIBRARY +#ifndef QT_NO_NSL typedef int (*WildCast)(int, char *, int, char *, int, char *); char printersConfByname[] = "printers.conf.byname"; char *domain; int err; - QLibrary lib(QLatin1String("nsl")); - typedef int (*ypGetDefaultDomain)(char **); - ypGetDefaultDomain _ypGetDefaultDomain = (ypGetDefaultDomain)lib.resolve("yp_get_default_domain"); - typedef int (*ypAll)(const char *, const char *, const struct ypall_callback *); - ypAll _ypAll = (ypAll)lib.resolve("yp_all"); - - if (_ypGetDefaultDomain && _ypAll) { - err = _ypGetDefaultDomain(&domain); - if (err == 0) { - ypall_callback cb; - // wild cast to support K&R-style system headers - (WildCast &) cb.foreach = (WildCast) qt_pd_foreach; - cb.data = (char *) printers; - err = _ypAll(domain, printersConfByname, &cb); - } - if (!err) - return Success; + err = yp_get_default_domain(&domain); + if (err == 0) { + ypall_callback cb; + // wild cast to support K&R-style system headers + (WildCast &) cb.foreach = (WildCast) qt_pd_foreach; + cb.data = (char *) printers; + err = yp_all(domain, printersConfByname, &cb); } -#endif //QT_NO_LIBRARY + if (!err) + return Success; +#endif //QT_NO_NSL return Unavail; } diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp index 59d5dbaab..8ff7f38cd 100644 --- a/src/gui/styles/qgtkstyle.cpp +++ b/src/gui/styles/qgtkstyle.cpp @@ -43,7 +43,6 @@ #if !defined(QT_NO_STYLE_GTK) #include -#include #include #include #include -- 2.11.0