From 002945b082c185739ff77256c98d3fdabe2e7674 Mon Sep 17 00:00:00 2001
From: Botond Baranyi <botond.baranyi@ericsson.com>
Date: Tue, 6 Oct 2020 16:07:09 +0200
Subject: [PATCH] Removed '-lbsd' flags and 'readline/readline.h' include (Bug
 565893)

Signed-off-by: Botond Baranyi <botond.baranyi@ericsson.com>
Change-Id: I3a603580a6f017a7b8f2156dee64f7d3ed104da2
---
 compiler2/makefile.c | 10 +++++-----
 core/DebuggerUI.cc   |  2 +-
 core/Makefile        | 14 +++++---------
 mctr2/cli/Cli.cc     |  5 +----
 mctr2/cli/Makefile   |  2 +-
 mctr2/mctr/Makefile  | 12 ++++++------
 6 files changed, 19 insertions(+), 26 deletions(-)

diff --git a/compiler2/makefile.c b/compiler2/makefile.c
index 05dc83d59..8dcfc02dd 100644
--- a/compiler2/makefile.c
+++ b/compiler2/makefile.c
@@ -3681,7 +3681,7 @@ static void print_makefile(struct makefile_struct *makefile)
     fputs(" -lresolv", fp);
 #endif
 #ifdef ADVANCED_DEBUGGER_UI
-    fputs(" -lcurses -lbsd -ledit", fp);
+    fputs(" -lcurses -ledit", fp);
 #endif
     if (makefile->solspeclibraries) {
       struct string_list* act_elem = makefile->solspeclibraries;
@@ -3699,7 +3699,7 @@ static void print_makefile(struct makefile_struct *makefile)
     fputs(" -lresolv", fp);
 #endif
 #ifdef ADVANCED_DEBUGGER_UI
-    fputs(" -lcurses -lbsd -ledit", fp);
+    fputs(" -lcurses -ledit", fp);
 #endif
     if (makefile->sol8speclibraries) {
       struct string_list* act_elem = makefile->sol8speclibraries;
@@ -3717,7 +3717,7 @@ static void print_makefile(struct makefile_struct *makefile)
     fputs(" -lpthread -lrt", fp);
 #endif
 #ifdef ADVANCED_DEBUGGER_UI
-    fputs(" -lncurses -lbsd -ledit", fp);
+    fputs(" -lncurses -ledit", fp);
 #endif
     if (makefile->linuxspeclibraries) {
       struct string_list* act_elem = makefile->linuxspeclibraries;
@@ -3732,7 +3732,7 @@ static void print_makefile(struct makefile_struct *makefile)
 
     fputs("FREEBSD_LIBS = -lxml2", fp);
 #ifdef ADVANCED_DEBUGGER_UI
-    fputs(" -lncurses -lbsd -ledit", fp);
+    fputs(" -lncurses -ledit", fp);
 #endif
     if (makefile->freebsdspeclibraries) {
       struct string_list* act_elem = makefile->freebsdspeclibraries;
@@ -3747,7 +3747,7 @@ static void print_makefile(struct makefile_struct *makefile)
 
     fputs("WIN32_LIBS = -lxml2", fp);
 #ifdef ADVANCED_DEBUGGER_UI
-    fputs(" -lncurses -lbsd -ledit", fp);
+    fputs(" -lncurses -ledit", fp);
 #endif
     if (makefile->win32speclibraries) {
       struct string_list* act_elem = makefile->win32speclibraries;
diff --git a/core/DebuggerUI.cc b/core/DebuggerUI.cc
index f95160e8f..c2c96dcca 100644
--- a/core/DebuggerUI.cc
+++ b/core/DebuggerUI.cc
@@ -18,7 +18,7 @@
 #include <ctype.h>
 
 #ifdef ADVANCED_DEBUGGER_UI
-#include <readline.h>
+#include <editline/readline.h>
 // use a different file, than the MCTR CLI, since not all commands are the same
 #define TTCN3_HISTORY_FILENAME ".ttcn3_history_single"
 #endif
diff --git a/core/Makefile b/core/Makefile
index 8cacb359c..0f7f65424 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -83,12 +83,12 @@ WIN32_LIBS     := -lxml2
 INTERIX_LIBS   := -lxml2
 	
 ifeq ($(ADVANCED_DEBUGGER_UI), yes)
-  SOLARIS_LIBS   += -lcurses -lbsd -ledit
-  SOLARIS8_LIBS  += -lcurses -lbsd -ledit
-  LINUX_LIBS     += -lncurses -lbsd -ledit
-  FREEBSD_LIBS   += -lncurses -lbsd -ledit
+  SOLARIS_LIBS   += -lcurses -ledit
+  SOLARIS8_LIBS  += -lcurses -ledit
+  LINUX_LIBS     += -lncurses -ledit
+  FREEBSD_LIBS   += -lncurses -ledit
   WIN32_LIBS     += -lncurses -ledit
-  INTERIX_LIBS   += -lncurses -lbsd -ledit
+  INTERIX_LIBS   += -lncurses -ledit
 endif
 
 ifeq ($(USAGE_STATS), yes)
@@ -151,10 +151,6 @@ ifeq ($(PLATFORM),INTERIX)
   CPPFLAGS += -I/usr/local/include
 endif
 
-ifeq ($(ADVANCED_DEBUGGER_UI), yes)
-  CPPFLAGS += -I/usr/include/editline -I/usr/include/readline
-endif
-
 
 OBJECTS := $(patsubst %.cc,%.o,$(patsubst %.c,%.o,$(SOURCES)))
 	
diff --git a/mctr2/cli/Cli.cc b/mctr2/cli/Cli.cc
index 551fb6c6b..03a514a4e 100644
--- a/mctr2/cli/Cli.cc
+++ b/mctr2/cli/Cli.cc
@@ -42,10 +42,7 @@
 #include "../../common/config_preproc.h"
 #include "../../core/DebugCommands.hh"
 
-#include <readline.h>
-#if RL_READLINE_VERSION == 0x0603
-#include <history.h>
-#endif
+#include <editline/readline.h>
 
 #define PROMPT "MC2> "
 #define CMTC_TEXT "cmtc"
diff --git a/mctr2/cli/Makefile b/mctr2/cli/Makefile
index ae27deb7c..5ef23033f 100644
--- a/mctr2/cli/Makefile
+++ b/mctr2/cli/Makefile
@@ -40,7 +40,7 @@ OBJECTS := $(patsubst %.cc,%.o,$(patsubst %.c,%.o,$(SOURCES)))
 
 DEPFILES := $(patsubst %.cc,%.d,$(patsubst %.c,%.d,$(SOURCES)))
 
-CPPFLAGS += -D_REENTRANT -I/usr/include/editline -I/usr/include/readline
+CPPFLAGS += -D_REENTRANT
 
 ifdef OPENSSL_DIR
 ifneq ($(OPENSSL_DIR), default)
diff --git a/mctr2/mctr/Makefile b/mctr2/mctr/Makefile
index 1bf5eccf0..b74594600 100644
--- a/mctr2/mctr/Makefile
+++ b/mctr2/mctr/Makefile
@@ -83,12 +83,12 @@ LINUX_LIBS := -lpthread
 FREEBSD_LIBS := -lpthread
 WIN32_LIBS := -lpthread
 
-SOLARIS_CLI_LIBS := -lcurses -lbsd -ledit
-SOLARIS8_CLI_LIBS := -lcurses -lbsd -ledit
-LINUX_CLI_LIBS := -lncurses -lbsd -ledit
-FREEBSD_CLI_LIBS := -lncurses -lbsd -ledit
-WIN32_CLI_LIBS := -lncurses -lbsd -ledit
-INTERIX_CLI_LIBS := -lncurses -lbsd -ledit
+SOLARIS_CLI_LIBS := -lcurses -ledit
+SOLARIS8_CLI_LIBS := -lcurses -ledit
+LINUX_CLI_LIBS := -lncurses -ledit
+FREEBSD_CLI_LIBS := -lncurses -ledit
+WIN32_CLI_LIBS := -lncurses -ledit
+INTERIX_CLI_LIBS := -lncurses -ledit
 
 all run: $(TARGETS)
 
-- 
GitLab