--- ./cmdline/Makefile.am.orig
+++ ./cmdline/Makefile.am
@@ -7,8 +7,8 @@
 
 afpcmd_SOURCES = cmdline_afp.c  cmdline_main.c cmdline_testafp.c
 
-afpcmd_LDADD = -lreadline -lncurses  $(top_builddir)/lib/libafpclient.la
-afpcmd_CFLAGS = -I$(top_srcdir)/include -D_FILE_OFFSET_BITS=64 @CFLAGS@ 
+afpcmd_LDADD = $(libedit_LIBS) -lncurses  $(top_builddir)/lib/libafpclient.la
+afpcmd_CFLAGS = $(libedit_CFLAGS) -I$(top_srcdir)/include -D_FILE_OFFSET_BITS=64 @CFLAGS@ 
 
 install-data-hook:
 	mkdir -p $(DESTDIR)/$(mandir)/man1
--- ./cmdline/cmdline_main.c.orig
+++ ./cmdline/cmdline_main.c
@@ -12,8 +12,8 @@
 #include <string.h>
 #include <termios.h>
 #include <unistd.h>
-#include <readline/readline.h>
-#include <readline/history.h>
+#include <readline.h>
+#include <histedit.h>
 #include <getopt.h>
 #include <ctype.h>
 #include <signal.h>
--- ./configure.ac.orig
+++ ./configure.ac
@@ -16,8 +16,8 @@
 # Checks for libraries.
 # FIXME: Replace `main' with a function in `-lncurses':
 AC_CHECK_LIB([ncurses], [main])
-AC_CHECK_LIB([readline],[readline])
 AC_CHECK_LIB([pthread], [pthread_create])
++PKG_CHECK_MODULES([libedit], [libedit])
 
 
 
