--- a/m4/lftp_lib_readline.m4
+++ b/m4/lftp_lib_readline.m4
@@ -107,7 +107,7 @@
 	if test -f "$readline_include_dir/readline/readline.h"; then
 	    readline_include_dir="$readline_include_dir/readline"
 	fi
-        readline_ld_flags="-L$readline_prefix/lib"
+        readline_ld_flags="-L$libdir"
         if test -z "$readline_lib_flags"; then
             readline_lib_flags="-lreadline"
         fi
