Index: auto.def
==================================================================
--- auto.def
+++ auto.def
@@ -21,6 +21,7 @@
     with-see=0           => {Enable the SQLite Encryption Extension (SEE)}
     internal-sqlite=1    => {Don't use the internal SQLite, use the system one}
     static=0             => {Link a static executable}
+    lineedit=1           => {Disable line editing}
     fusefs=1             => {Disable the Fuse Filesystem}
     fossil-debug=0       => {Build with fossil debugging enabled}
     no-opt=0             => {Build without optimization}
@@ -274,6 +275,20 @@
     }
 }
 
+if {[opt-bool lineedit]} {
+    # Need readline-compatible line editing
+    cc-with {-includes stdio.h} {
+        if {[cc-check-includes readline/readline.h] && [cc-check-function-in-lib readline readline]} {
+            define-append EXTRA_CFLAGS -DHAVE_READLINE
+            msg-result "Using readline for line editing"
+        } elseif {[cc-check-includes editline/readline.h] && [cc-check-function-in-lib readline edit]} {
+            define-feature editline
+            define-append EXTRA_CFLAGS -DHAVE_EDITLINE
+            msg-result "Using editline for line editing"
+        }
+    }
+}
+
 set ssldirs [opt-val with-openssl]
 if {$ssldirs ne "none"} {
     if {[opt-bool with-miniz]} {
