summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2009-08-20 18:47:46 +0200
committerMatthias Schiffer <matthias@gamezock.de>2009-08-20 19:06:12 +0200
commit6666bbf908b3f2a61a9ec1959e975de54dc23b0d (patch)
treed0d619da5220c9386c1c90284be18f4d840b0dbc
parent36792c7b489c984db95e2384660f1933c0498db0 (diff)
downloadmad-6666bbf908b3f2a61a9ec1959e975de54dc23b0d.tar
mad-6666bbf908b3f2a61a9ec1959e975de54dc23b0d.zip
madc: Added support for BSD editline
-rw-r--r--CMakeLists.txt7
-rw-r--r--FindEditline.cmake17
-rw-r--r--config.h.in2
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/madc.cpp10
5 files changed, 34 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d859809..729ff76 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,12 +4,17 @@ project(MAD)
set(CMAKE_MODULE_PATH ${MAD_SOURCE_DIR})
find_package(LibXml2 REQUIRED)
-find_package(Readline REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(Boost REQUIRED date_time filesystem regex signals system thread)
find_package(MySQL)
find_package(KRB5 COMPONENTS krb5 kadm-client)
+find_package(Editline)
+if(NOT EDITLINE_FOUND)
+ find_package(Readline REQUIRED)
+ set(EDITLINE_LIBRARY ${READLINE_LIBRARY})
+endif(NOT EDITLINE_FOUND)
+
if(WIN32)
add_definitions(-DWINVER=0x0501 -D_WIN32_WINNT=0x0501)
diff --git a/FindEditline.cmake b/FindEditline.cmake
new file mode 100644
index 0000000..21c8208
--- /dev/null
+++ b/FindEditline.cmake
@@ -0,0 +1,17 @@
+FIND_PATH(EDITLINE_INCLUDE_DIR editline/readline.h)
+FIND_LIBRARY(EDITLINE_LIBRARY NAMES edit)
+
+IF (EDITLINE_INCLUDE_DIR AND EDITLINE_LIBRARY)
+ SET(EDITLINE_FOUND TRUE)
+ENDIF (EDITLINE_INCLUDE_DIR AND EDITLINE_LIBRARY)
+
+IF (EDITLINE_FOUND)
+ IF (NOT Editline_FIND_QUIETLY)
+ MESSAGE(STATUS "Found BSD editline: ${EDITLINE_LIBRARY}")
+ ENDIF (NOT Editline_FIND_QUIETLY)
+ELSE (EDITLINE_FOUND)
+ IF (Editline_FIND_REQUIRED)
+ MESSAGE(FATAL_ERROR "Could not find BSD editline")
+ ENDIF (Editline_FIND_REQUIRED)
+ENDIF (EDITLINE_FOUND)
+
diff --git a/config.h.in b/config.h.in
index 5e7ba50..b60fc25 100644
--- a/config.h.in
+++ b/config.h.in
@@ -1,3 +1,5 @@
#define MODULE_SUFFIX "${CMAKE_SHARED_MODULE_SUFFIX}"
#define DEFAULT_PORT 6666
+
+#cmakedefine EDITLINE_FOUND \ No newline at end of file
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 72ed248..b705a89 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -25,4 +25,4 @@ add_executable(mad mad.cpp)
target_link_libraries(mad Daemon Common Net Core)
add_executable(madc madc.cpp)
-target_link_libraries(madc Client Common Net Core ${READLINE_LIBRARY})
+target_link_libraries(madc Client Common Net Core ${EDITLINE_LIBRARY})
diff --git a/src/madc.cpp b/src/madc.cpp
index 0500c0f..c55fd3e 100644
--- a/src/madc.cpp
+++ b/src/madc.cpp
@@ -17,6 +17,8 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "config.h"
+
#include "Core/ConfigManager.h"
#include "Common/ClientConnection.h"
@@ -31,8 +33,12 @@
#include <iostream>
-#include <readline/readline.h>
-#include <readline/history.h>
+#ifdef EDITLINE_FOUND
+# include <editline/readline.h>
+#else
+# include <readline/readline.h>
+# include <readline/history.h>
+#endif
using namespace Mad;