diff --git a/configure.in b/configure.in index 55ec5782..40fd10c0 100644 --- a/configure.in +++ b/configure.in @@ -314,6 +314,14 @@ AM_CONDITIONAL(HAVE_PCSCLITE, test "x$ac_cv_lib_pcsclite_SCardEstablishContext" AC_SUBST(LIBDL) AC_CHECK_LIB(dl, dlopen, [LIBDL="$LIBDL -ldl" ac_cv_func_dlopen_ldl=yes], ac_cv_func_dlopen_ldl=no) +AC_SUBST(LIBREADLINE) +AC_CHECK_LIB(readline, readline, [LIBREADLINE="$LIBREADLINE -lreadline" ac_cv_func_readline_lreadline=yes], ac_cv_func_readline_lreadline=no) + +saved_LIBS="$LIBS" +LIBS="$LIBS $LIBREADLINE" +AC_CHECK_FUNCS(readline) +LIBS="$saved_LIBS" + dnl The big search for OpenSSL AC_ARG_WITH(ssl-dir, [ --with-ssl-dir=PATH Specify path to OpenSSL installation], diff --git a/src/tools/Makefile.am b/src/tools/Makefile.am index 1c96ff83..0308b8d2 100644 --- a/src/tools/Makefile.am +++ b/src/tools/Makefile.am @@ -13,8 +13,7 @@ bin_PROGRAMS = opensc-tool opensc-explorer pkcs15-crypt pkcs15-tool \ opensc_tool_SOURCES = opensc-tool.c util.c opensc_tool_LDADD = @GETOPTSRC@ opensc_explorer_SOURCES = opensc-explorer.c util.c -## FIXME: conditionally add -lreadline -opensc_explorer_LDADD = @GETOPTSRC@ +opensc_explorer_LDADD = @GETOPTSRC@ @LIBREADLINE@ pkcs15_tool_SOURCES = pkcs15-tool.c util.c pkcs15_tool_LDADD = @GETOPTSRC@ pkcs15_crypt_SOURCES = pkcs15-crypt.c util.c diff --git a/src/tools/cryptoflex-tool.c b/src/tools/cryptoflex-tool.c index b2815b1a..6c8020f4 100644 --- a/src/tools/cryptoflex-tool.c +++ b/src/tools/cryptoflex-tool.c @@ -18,6 +18,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H +#include +#endif #include "util.h" #include #include diff --git a/src/tools/opensc-explorer.c b/src/tools/opensc-explorer.c index 8436fe93..968850ae 100644 --- a/src/tools/opensc-explorer.c +++ b/src/tools/opensc-explorer.c @@ -18,17 +18,16 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include +#ifdef HAVE_CONFIG_H +#include +#endif #include #include #include - -#undef USE_READLINE - -#ifdef USE_READLINE +#include +#ifdef HAVE_READLINE #include #endif - #include "util.h" int opt_reader = 0, opt_debug = 0; @@ -804,7 +803,7 @@ static int parse_line(char *in, char **argv) return argc; } -#ifndef USE_READLINE +#ifndef HAVE_READLINE char * readline(const char *prompt) { static char buf[128]; diff --git a/src/tools/opensc-tool.c b/src/tools/opensc-tool.c index 22119a17..bb29cacc 100644 --- a/src/tools/opensc-tool.c +++ b/src/tools/opensc-tool.c @@ -18,6 +18,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H +#include +#endif #include "util.h" #include #include diff --git a/src/tools/pkcs15-crypt.c b/src/tools/pkcs15-crypt.c index 54802814..aada1762 100644 --- a/src/tools/pkcs15-crypt.c +++ b/src/tools/pkcs15-crypt.c @@ -18,6 +18,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H +#include +#endif #include "util.h" #include #include diff --git a/src/tools/pkcs15-gpk.c b/src/tools/pkcs15-gpk.c index bb21c661..56d1a1be 100644 --- a/src/tools/pkcs15-gpk.c +++ b/src/tools/pkcs15-gpk.c @@ -4,6 +4,9 @@ * Copyright (C) 2002 Olaf Kirch */ +#ifdef HAVE_CONFIG_H +#include +#endif #include #include #include diff --git a/src/tools/pkcs15-init.c b/src/tools/pkcs15-init.c index d497faa6..eba18a79 100644 --- a/src/tools/pkcs15-init.c +++ b/src/tools/pkcs15-init.c @@ -15,6 +15,9 @@ * Copyright (C) 2002, Olaf Kirch */ +#ifdef HAVE_CONFIG_H +#include +#endif #include #include #include diff --git a/src/tools/pkcs15-tool.c b/src/tools/pkcs15-tool.c index 891c2d71..e3047334 100644 --- a/src/tools/pkcs15-tool.c +++ b/src/tools/pkcs15-tool.c @@ -18,6 +18,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H +#include +#endif #include "util.h" #include diff --git a/src/tools/profile.c b/src/tools/profile.c index a8ed8379..0ac139f7 100644 --- a/src/tools/profile.c +++ b/src/tools/profile.c @@ -4,6 +4,9 @@ * Copyright (C) 2002 Olaf Kirch */ +#ifdef HAVE_CONFIG_H +#include +#endif #include #include #include diff --git a/src/tools/util.c b/src/tools/util.c index 713df0da..e02ae774 100644 --- a/src/tools/util.c +++ b/src/tools/util.c @@ -5,7 +5,6 @@ #include #include #include - #include "util.h" void print_binary(FILE *f, const u8 *buf, int count)