--- /dev/null
+configure: add option to enable/disable readline
+
+Add an option to control explicitly whether systemtap will look for and
+use readline, for reproducible builds.
+
+If not specified the behaviour is as before: look for readline and if it
+is found, use it. However if --with-readline is passed then readline
+must be present, and if --without-readline is passed then readline will
+not be used.
+
+Upstream-Status: Submitted [https://sourceware.org/pipermail/systemtap/2026q2/028333.html]
+Signed-off-by: Ross Burton <ross.burton@arm.com>
+
+diff --git i/configure.ac w/configure.ac
+index 6fb99da40..01457bafb 100644
+--- i/configure.ac
++++ w/configure.ac
+@@ -525,38 +525,47 @@ AC_CHECK_HEADERS([rpm/rpmcrypto.h], [
+ have_rpmcrypto_h=yes
+ AC_MSG_NOTICE([separate rpm/rpmcrypto.h])])
+
+-dnl Look for readline.
+-dnl
+-dnl First save the orignal value of LIBS.
+-LIBS_no_readline=$LIBS
+
+-dnl Check how for readline presence and how to link with it. On some
+-dnl systems you need to add a termcap compatible library.
+-have_libreadline="no"
+-AC_MSG_CHECKING([how to link readline libs])
+-for libtermcap in "" tinfo ncursesw ncurses curses termcap; do
+- if test -z "$libtermcap"; then
+- READLINE_LIBS="-lreadline"
++AC_ARG_WITH([readline],
++ AS_HELP_STRING([--without-readline],[disable use of readline]), [], [with_readline="check"])
++
++if test "$with_readline" != no; then
++ dnl Look for readline.
++ dnl
++ dnl First save the orignal value of LIBS.
++ LIBS_no_readline=$LIBS
++
++ have_libreadline="no"
++ dnl Check how for readline presence and how to link with it. On some
++ dnl systems you need to add a termcap compatible library.
++ AC_MSG_CHECKING([how to link readline libs])
++ for libtermcap in "" tinfo ncursesw ncurses curses termcap; do
++ if test -z "$libtermcap"; then
++ READLINE_LIBS="-lreadline"
++ else
++ READLINE_LIBS="-lreadline -l$libtermcap"
++ fi
++ LIBS="$READLINE_LIBS $LIBS_no_readline"
++ AC_LINK_IFELSE(
++ [AC_LANG_CALL([],[readline])],
++ [have_libreadline="yes"])
++ if test "$have_libreadline" = "yes"; then
++ break
++ fi
++ done
++
++ if test "$have_libreadline" = "no" -a "$with_readline" = "yes"; then
++ AC_MSG_ERROR([cannot find libreadline])
++ elif test "$have_libreadline" = "no" -a "$with_readline" = "check"; then
++ AC_MSG_RESULT([libreadline not found])
++ READLINE_LIBS=""
+ else
+- READLINE_LIBS="-lreadline -l$libtermcap"
++ AC_MSG_RESULT([$READLINE_LIBS])
++ AC_DEFINE(HAVE_LIBREADLINE, [1],
++ [Define if you have the readline library (-lreadline).])
+ fi
+- LIBS="$READLINE_LIBS $LIBS_no_readline"
+- AC_LINK_IFELSE(
+- [AC_LANG_CALL([],[readline])],
+- [have_libreadline="yes"])
+- if test "$have_libreadline" = "yes"; then
+- break
+- fi
+-done
+-if test "$have_libreadline" = "no"; then
+- AC_MSG_RESULT([none])
+- READLINE_LIBS=""
+-else
+- AC_MSG_RESULT([$READLINE_LIBS])
+- AC_DEFINE(HAVE_LIBREADLINE, [1],
+- [Define if you have the readline library (-lreadline).])
++ AC_SUBST([READLINE_LIBS])
+ fi
+-AC_SUBST([READLINE_LIBS])
+ AM_CONDITIONAL([HAVE_LIBREADLINE], [test "$have_libreadline" = "yes"])
+
+ dnl End of readline checks: restore LIBS