Skip to content

Commit

Permalink
Fix conditional compile for libreadline
Browse files Browse the repository at this point in the history
  • Loading branch information
nikias committed Nov 5, 2024
1 parent 2405a80 commit 7a5e619
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
5 changes: 4 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,14 @@ AC_ARG_WITH([tools],
[with_tools=yes])

AS_IF([test "x$with_tools" = "xyes"], [
have_readline=no
AC_DEFINE(BUILD_TOOLS, 1, [Define if we are building irecovery tools])
AC_CHECK_HEADERS([readline/readline.h],
[AC_DEFINE(HAVE_READLINE, 1, [Define if readline is available])],
[AC_DEFINE(HAVE_READLINE, 1, [Define if readline is available])
have_readline=yes],
[AC_MSG_NOTICE([NOTE: Building without readline support. If you want readline support, install its development package.])]
)
AM_CONDITIONAL(HAVE_READLINE, test "x$have_readline" = "xyes")
])
AM_CONDITIONAL(BUILD_TOOLS, test "x$with_tools" = "xyes")

Expand Down
5 changes: 4 additions & 1 deletion tools/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ if BUILD_TOOLS
AM_CPPFLAGS = -I$(top_srcdir)/include

AM_CFLAGS = $(GLOBAL_CFLAGS) $(libusb_CFLAGS)
AM_LDFLAGS = $(libusb_LIBS) -lreadline
AM_LDFLAGS = $(libusb_LIBS)

bin_PROGRAMS = irecovery

irecovery_SOURCES = irecovery.c
irecovery_CFLAGS = $(AM_CFLAGS)
irecovery_LDFLAGS = $(AM_LDFLAGS)
if HAVE_READLINE
irecovery_LDFLAGS += -lreadline
endif
irecovery_LDADD = $(top_builddir)/src/libirecovery-1.0.la
endif
6 changes: 5 additions & 1 deletion tools/irecovery.c
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,11 @@ int main(int argc, char* argv[])
return 0;

case 'V':
printf("%s %s\n", TOOL_NAME, PACKAGE_VERSION);
printf("%s %s", TOOL_NAME, PACKAGE_VERSION);
#ifdef HAVE_READLINE
printf(" (readline)");
#endif
printf("\n");
return 0;

default:
Expand Down

0 comments on commit 7a5e619

Please sign in to comment.