Fix the dependency nightmare that is libreadline

refs #8091
This commit is contained in:
Gunnar Beutner 2014-12-17 09:47:03 +01:00
parent 3436dbc697
commit c90c8919ca
6 changed files with 15 additions and 7 deletions

View File

@ -153,6 +153,7 @@ check_function_exists(nice HAVE_NICE)
check_library_exists(dl dladdr "dlfcn.h" HAVE_DLADDR) check_library_exists(dl dladdr "dlfcn.h" HAVE_DLADDR)
check_library_exists(execinfo backtrace_symbols "" HAVE_LIBEXECINFO) check_library_exists(execinfo backtrace_symbols "" HAVE_LIBEXECINFO)
check_library_exists(readline readline "" HAVE_LIBREADLINE) check_library_exists(readline readline "" HAVE_LIBREADLINE)
check_library_exists(ncurses attroff "" HAVE_LIBNCURSES)
check_include_file_cxx(cxxabi.h HAVE_CXXABI_H) check_include_file_cxx(cxxabi.h HAVE_CXXABI_H)
if(HAVE_LIBEXECINFO) if(HAVE_LIBEXECINFO)

View File

@ -28,6 +28,7 @@ parentheses):
* recommended: libexecinfo on FreeBSD (automatically used when Icinga 2 is * recommended: libexecinfo on FreeBSD (automatically used when Icinga 2 is
installed via port or package) installed via port or package)
* recommended: GNU readline (readline-devel on RHEL, libreadline-dev on Debian) * recommended: GNU readline (readline-devel on RHEL, libreadline-dev on Debian)
* recommended: ncurses (ncurses-devel on RHEL, libncurses-dev on Debian)
* optional: MySQL (mysql-devel on RHEL, libmysqlclient-dev on Debian); set CMake * optional: MySQL (mysql-devel on RHEL, libmysqlclient-dev on Debian); set CMake
variable `ICINGA2_WITH_MYSQL` to disable this module variable `ICINGA2_WITH_MYSQL` to disable this module
* optional: PostgreSQL (postgresql-devel on RHEL, libpq-dev on Debian); set CMake * optional: PostgreSQL (postgresql-devel on RHEL, libpq-dev on Debian); set CMake

View File

@ -10,6 +10,7 @@
#cmakedefine HAVE_CXXABI_H #cmakedefine HAVE_CXXABI_H
#cmakedefine HAVE_NICE #cmakedefine HAVE_NICE
#cmakedefine HAVE_LIBREADLINE #cmakedefine HAVE_LIBREADLINE
#cmakedefine HAVE_LIBNCURSES
#cmakedefine ICINGA2_UNITY_BUILD #cmakedefine ICINGA2_UNITY_BUILD

View File

@ -98,6 +98,7 @@ BuildRequires: flex >= 2.5.35
BuildRequires: bison BuildRequires: bison
BuildRequires: make BuildRequires: make
BuildRequires: readline-devel BuildRequires: readline-devel
BuildRequires: ncurses-devel
%if "%{_vendor}" == "redhat" && (0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5") %if "%{_vendor}" == "redhat" && (0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5")
# el5 requires packages.icinga.org # el5 requires packages.icinga.org

View File

@ -38,7 +38,11 @@ add_library(cli SHARED ${cli_SOURCES})
target_link_libraries(cli ${Boost_LIBRARIES} base config remote) target_link_libraries(cli ${Boost_LIBRARIES} base config remote)
if(HAVE_LIBREADLINE) if(HAVE_LIBREADLINE)
target_link_libraries(cli readline termcap) target_link_libraries(cli readline)
endif()
if(HAVE_LIBNCURSES)
target_link_libraries(cli ncurses)
endif() endif()
set_target_properties ( set_target_properties (

View File

@ -28,12 +28,12 @@
#include "base/networkstream.hpp" #include "base/networkstream.hpp"
#include <iostream> #include <iostream>
#ifdef HAVE_LIBREADLINE #if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBNCURSES)
extern "C" { extern "C" {
#include <readline/readline.h> #include <readline/readline.h>
#include <readline/history.h> #include <readline/history.h>
} }
#endif /* HAVE_LIBREADLINE */ #endif /* HAVE_LIBREADLINE && HAVE_LIBNCURSES */
using namespace icinga; using namespace icinga;
namespace po = boost::program_options; namespace po = boost::program_options;
@ -92,7 +92,7 @@ int ReplCommand::Run(const po::variables_map& vm, const std::vector<std::string>
String fileName = "<" + Convert::ToString(next_line) + ">"; String fileName = "<" + Convert::ToString(next_line) + ">";
next_line++; next_line++;
#ifdef HAVE_LIBREADLINE #if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBNCURSES)
ConsoleType type = Console::GetType(std::cout); ConsoleType type = Console::GetType(std::cout);
std::stringstream prompt_sbuf; std::stringstream prompt_sbuf;
@ -102,15 +102,15 @@ int ReplCommand::Run(const po::variables_map& vm, const std::vector<std::string>
<< RL_PROMPT_START_IGNORE << ConsoleColorTag(Console_ForegroundRed, type) << RL_PROMPT_START_IGNORE << ConsoleColorTag(Console_ForegroundRed, type)
<< RL_PROMPT_END_IGNORE << " => " << RL_PROMPT_END_IGNORE << " => "
<< RL_PROMPT_START_IGNORE << ConsoleColorTag(Console_Normal, type); << RL_PROMPT_START_IGNORE << ConsoleColorTag(Console_Normal, type);
#else /* HAVE_LIBREADLINE */ #else /* HAVE_LIBREADLINE && HAVE_LIBNCURSES */
std::cout << ConsoleColorTag(Console_ForegroundCyan) std::cout << ConsoleColorTag(Console_ForegroundCyan)
<< fileName << fileName
<< ConsoleColorTag(Console_ForegroundRed) << ConsoleColorTag(Console_ForegroundRed)
<< " => " << " => "
<< ConsoleColorTag(Console_Normal); << ConsoleColorTag(Console_Normal);
#endif /* HAVE_LIBREADLINE */ #endif /* HAVE_LIBREADLINE && HAVE_LIBNCURSES */
#ifdef HAVE_LIBREADLINE #if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBNCURSES)
String prompt = prompt_sbuf.str(); String prompt = prompt_sbuf.str();
char *rline = readline(prompt.CStr()); char *rline = readline(prompt.CStr());