From 3b07623b38bcc1b48e012dd856676d9346a59a38 Mon Sep 17 00:00:00 2001 From: Valentin Bartenev Date: Fri, 26 Apr 2019 17:59:42 +0300 Subject: [PATCH] Support for building with GNU Readline library. --- auto/expect | 2 +- auto/make | 4 ++-- auto/{editline => readline} | 39 ++++++++++++++++++++++++++----------- configure | 2 +- njs/njs_shell.c | 3 +++ 5 files changed, 35 insertions(+), 15 deletions(-) rename auto/{editline => readline} (59%) diff --git a/auto/expect b/auto/expect index befb7fa8..5b4dc7b4 100644 --- a/auto/expect +++ b/auto/expect @@ -17,7 +17,7 @@ else $echo " not found" fi -if [ $nxt_found = yes -a $NXT_HAVE_LIBEDIT = YES ]; then +if [ $nxt_found = yes -a $NXT_HAVE_READLINE = YES ]; then cat << END >> $NXT_MAKEFILE njs_expect_test: njs njs/test/njs_expect_test.exp diff --git a/auto/make b/auto/make index 7c43d690..16c80e1a 100644 --- a/auto/make +++ b/auto/make @@ -178,10 +178,10 @@ $NXT_BUILD_DIR/njs: \\ njs/njs_shell.c \$(NXT_CC) -o $NXT_BUILD_DIR/njs \$(NXT_CFLAGS) \\ $NXT_LIB_AUX_CFLAGS \$(NXT_LIB_INCS) \\ - $NXT_EDITLINE_CFLAGS -Injs \\ + $NXT_READLINE_CFLAGS -Injs \\ njs/njs_shell.c \\ $NXT_BUILD_DIR/libnjs.a \\ - -lm $NXT_LIBS $NXT_LIB_AUX_LIBS $NXT_EDITLINE_LIB + -lm $NXT_LIBS $NXT_LIB_AUX_LIBS $NXT_READLINE_LIB END diff --git a/auto/editline b/auto/readline similarity index 59% rename from auto/editline rename to auto/readline index 9d49ca3d..2ab530b8 100644 --- a/auto/editline +++ b/auto/readline @@ -2,18 +2,19 @@ # Copyright (C) NGINX, Inc. -NXT_EDITLINE_CFLAGS= -NXT_EDITLINE_LIB= +NXT_READLINE_CFLAGS= +NXT_READLINE_LIB= nxt_found=no -nxt_feature="editline library in editline/readline.h" -nxt_feature_name=NXT_HAVE_EDITLINE +nxt_feature="GNU readline library" +nxt_feature_name=NXT_HAVE_GNU_READLINE nxt_feature_run=no nxt_feature_incs= -nxt_feature_libs="-ledit" +nxt_feature_libs="-lreadline" nxt_feature_test="#include - #include + #include + #include int main(void) { add_history(NULL); @@ -21,6 +22,20 @@ nxt_feature_test="#include }" . auto/feature +if [ $nxt_found = no ]; then + nxt_feature="editline library in editline/readline.h" + nxt_feature_name=NXT_HAVE_EDITLINE + nxt_feature_libs="-ledit" + nxt_feature_test="#include + #include + + int main(void) { + add_history(NULL); + return 0; + }" + . auto/feature +fi + if [ $nxt_found = no ]; then # FreeBSD port @@ -42,7 +57,7 @@ if [ $nxt_found = no ]; then # NetBSD - nxt_feature_name=NXT_HAVE_READLINE + nxt_feature_name=NXT_HAVE_NETBSD_READLINE nxt_feature="editline in readline/readline.h" nxt_feature_test="#include #include @@ -54,15 +69,17 @@ if [ $nxt_found = no ]; then . auto/feature fi + + NXT_DEFAULT_TARGET=libnjs if [ $nxt_found = yes ]; then - NXT_HAVE_LIBEDIT=YES - NXT_EDITLINE_CFLAGS=$nxt_feature_incs - NXT_EDITLINE_LIB=$nxt_feature_libs + NXT_HAVE_READLINE=YES + NXT_READLINE_CFLAGS=$nxt_feature_incs + NXT_READLINE_LIB=$nxt_feature_libs NXT_DEFAULT_TARGET="$NXT_DEFAULT_TARGET njs" else - NXT_HAVE_LIBEDIT=NO + NXT_HAVE_READLINE=NO $echo " - building interactive shell is not possible" fi diff --git a/configure b/configure index aa604dc0..ddf19a0a 100755 --- a/configure +++ b/configure @@ -52,7 +52,7 @@ NXT_LIBRT= . auto/getrandom . auto/explicit_bzero . auto/pcre -. auto/editline +. auto/readline . auto/sources NXT_LIB_AUX_CFLAGS="$NXT_PCRE_CFLAGS" diff --git a/njs/njs_shell.c b/njs/njs_shell.c index d92d8b0c..d5560f0a 100644 --- a/njs/njs_shell.c +++ b/njs/njs_shell.c @@ -23,6 +23,9 @@ #include #else #include +#if (NXT_HAVE_GNU_READLINE) +#include +#endif #endif -- 2.47.3