File linphone-build-readline.patch of Package linphone

Index: liblinphone-5.3.4/cmake/FindReadline.cmake
===================================================================
--- /dev/null
+++ liblinphone-5.3.4/cmake/FindReadline.cmake
@@ -0,0 +1,58 @@
+############################################################################
+# FindReadline.cmake
+# Copyright (C) 2014  Belledonne Communications, Grenoble France
+#
+############################################################################
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+#
+############################################################################
+#
+# - Find the readline include file and library
+#
+#  READLINE_FOUND - system has readline
+#  READLINE_INCLUDE_DIRS - the readline include directory
+#  READLINE_LIBRARIES - The libraries needed to use readline
+
+if(APPLE AND NOT IOS)
+	set(READLINE_HINTS "/usr")
+endif()
+if(READLINE_HINTS)
+	set(READLINE_LIBRARIES_HINTS "${READLINE_HINTS}/lib")
+endif()
+
+find_path(READLINE_INCLUDE_DIRS
+	NAMES readline.h
+	HINTS "${READLINE_HINTS}"
+	PATH_SUFFIXES include/readline
+)
+
+if(READLINE_INCLUDE_DIRS)
+	set(HAVE_READLINE_H 1)
+	set(HAVE_HISTORY_H 1)
+endif()
+
+find_library(READLINE_LIBRARIES
+	NAMES readline
+	HINTS "${READLINE_LIBRARIES_HINTS}"
+)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(Readline
+	DEFAULT_MSG
+	READLINE_INCLUDE_DIRS READLINE_LIBRARIES HAVE_READLINE_H HAVE_HISTORY_H
+)
+
+mark_as_advanced(READLINE_INCLUDE_DIRS READLINE_LIBRARIES HAVE_READLINE_H HAVE_HISTORY_H)
Index: liblinphone-5.3.4/CMakeLists.txt
===================================================================
--- liblinphone-5.3.4.orig/CMakeLists.txt
+++ liblinphone-5.3.4/CMakeLists.txt
@@ -77,6 +77,7 @@ option(ENABLE_SRTP "Build with the SRTP
 cmake_dependent_option(ENABLE_ZRTP "Build with ZRTP support." YES "ENABLE_SRTP" NO)
 cmake_dependent_option(ENABLE_GOCLEAR "Build with ZRTP GoClear message support (RFC 6189 - section 5.11)." YES "ENABLE_ZRTP" NO)
 cmake_dependent_option(ENABLE_QRCODE "Enable QRCode support" YES "ENABLE_VIDEO" NO)
+cmake_dependent_option(ENABLE_READLINE "Enable readline support." YES "ENABLE_CONSOLE_UI" NO)
 
 
 set(CMAKE_CXX_STANDARD 17)
@@ -163,6 +164,16 @@ if(ZLIB_FOUND)
 	set(HAVE_ZLIB 1)
 endif()
 
+if(ENABLE_READLINE)
+ find_package(Readline)
+ if(READLINE_FOUND)
+   set(HAVE_READLINE 1)
+ else()
+   message(WARNING "Could not find the readline library!")
+   set(ENABLE_READLINE OFF CACHE BOOL "Enable readline support." FORCE)
+ endif()
+endif()
+
 if(ENABLE_TUNNEL)
 	find_package(Tunnel 0.7.0)
 	if(NOT Tunnel_FOUND)
@@ -288,7 +299,7 @@ else()
 	if (SUGGEST_OVERRIDE)
 		list(APPEND STRICT_OPTIONS_CXX "-Wsuggest-override" "-Wno-error=suggest-override" )
 	endif ()
-	list(APPEND STRICT_OPTIONS_C "-Wstrict-prototypes" "-Werror=strict-prototypes")
+	list(APPEND STRICT_OPTIONS_C "-Wstrict-prototypes")
 	if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
 		list(APPEND STRICT_OPTIONS_C "-fno-inline-small-functions")
 	endif()
Index: liblinphone-5.3.4/config.h.cmake
===================================================================
--- liblinphone-5.3.4.orig/config.h.cmake
+++ liblinphone-5.3.4/config.h.cmake
@@ -54,6 +54,9 @@
 #define SOCI_LOCAL_PLUGINS_LOCATION "${CMAKE_BINARY_DIR}/lib"
 
 #cmakedefine HAVE_ZLIB 1
+#cmakedefine HAVE_READLINE
+#cmakedefine HAVE_READLINE_H
+#cmakedefine HAVE_HISTORY_H
 #cmakedefine HAVE_CU_GET_SUITE 1
 #cmakedefine HAVE_CU_CURSES 1
 #cmakedefine HAVE_LIBUDEV_H 0
Index: liblinphone-5.3.4/console/CMakeLists.txt
===================================================================
--- liblinphone-5.3.4.orig/console/CMakeLists.txt
+++ liblinphone-5.3.4/console/CMakeLists.txt
@@ -41,6 +41,10 @@ add_executable(linphonec ${LINPHONEC_SOU
 target_link_libraries(linphonec PRIVATE ${LINPHONE_LIBS_FOR_TOOLS} ${Mediastreamer2_TARGET} ${Ortp_TARGET} ${BCToolbox_TARGET} ${XSD_LIBRARIES})
 set_target_properties(linphonec PROPERTIES LINKER_LANGUAGE CXX)
 
+if(READLINE_FOUND)
+	target_include_directories(linphonec PUBLIC ${READLINE_INCLUDE_DIRS})
+	target_link_libraries(linphonec ${READLINE_LIBRARIES})
+endif()
 if(INTL_FOUND)
 	target_link_libraries(linphonec ${INTL_LIBRARIES})
 endif()
@@ -48,6 +52,10 @@ endif()
 if(WIN32)
 	add_executable(linphoned WIN32 ${LINPHONEC_SOURCE_FILES})
 	target_link_libraries(linphoned PRIVATE ${LINPHONE_LIBS_FOR_TOOLS} ${Mediastreamer2_TARGET} ${Ortp_TARGET} ${BCToolbox_TARGET} ${XSD_LIBRARIES})
+ if(READLINE_FOUND)
+   target_include_directories(linphoned PUBLIC ${READLINE_INCLUDE_DIRS})
+   target_link_libraries(linphoned ${READLINE_LIBRARIES})
+ endif()
 	if(INTL_FOUND)
 		target_link_libraries(linphoned PRIVATE ${INTL_LIBRARIES})
 	endif()
@@ -57,6 +65,11 @@ add_executable(linphonecsh ${LINPHONECSH
 target_link_libraries(linphonecsh PRIVATE ${LINPHONE_LIBS_FOR_TOOLS} ${Ortp_TARGET} ${BCToolbox_TARGET})
 set_target_properties(linphonecsh PROPERTIES LINKER_LANGUAGE CXX)
 
+if(READLINE_FOUND)
+	target_include_directories(linphonecsh PUBLIC ${READLINE_INCLUDE_DIRS})
+	target_link_libraries(linphonecsh ${READLINE_LIBRARIES})
+endif()
+
 set(INSTALL_TARGETS linphonec linphonecsh)
 if(WIN32)
 	list(APPEND INSTALL_TARGETS linphoned)
Index: liblinphone-5.3.4/daemon/CMakeLists.txt
===================================================================
--- liblinphone-5.3.4.orig/daemon/CMakeLists.txt
+++ liblinphone-5.3.4/daemon/CMakeLists.txt
@@ -132,6 +132,11 @@ if(APPLE)
 	target_link_libraries(linphone-daemon PRIVATE "-framework AppKit")
 endif()
 
+if(READLINE_FOUND)
+	target_include_directories(linphone-daemon PUBLIC ${READLINE_INCLUDE_DIRS})
+	target_link_libraries(linphone-daemon ${READLINE_LIBRARIES})
+endif()
+
 add_executable(linphone-daemon-pipetest ${DAEMON_PIPETEST_SOURCE_FILES})
 target_link_libraries(linphone-daemon-pipetest PRIVATE ${LINPHONE_LIBS_FOR_TOOLS} ${Mediastreamer2_TARGET} ${Ortp_TARGET})
 set_target_properties(linphone-daemon-pipetest PROPERTIES LINKER_LANGUAGE CXX)
Index: liblinphone-5.3.4/daemon/daemon.cc
===================================================================
--- liblinphone-5.3.4.orig/daemon/daemon.cc
+++ liblinphone-5.3.4/daemon/daemon.cc
@@ -32,11 +32,6 @@
 #include <limits>
 #include <sstream>
 
-#ifdef HAVE_READLINE
-#include <readline/history.h>
-#include <readline/readline.h>
-#endif
-
 #ifndef _WIN32
 #include <poll.h>
 #endif
openSUSE Build Service is sponsored by