]> Sergey Matveev's repositories - nnn.git/commitdiff
Add target norl to drop libreadline
authorArun Prakash Jana <engineerarun@gmail.com>
Fri, 22 Feb 2019 00:05:26 +0000 (05:35 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Fri, 22 Feb 2019 00:05:26 +0000 (05:35 +0530)
Makefile
README.md
src/nnn.c

index 07a7d5f7face9b536d3b70584dcb2e32b6051b82..4e35c6a85ff76e92631d7fc53547e397cf082bc5 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -22,7 +22,7 @@ CFLAGS += -Wall -Wextra -Wno-unused-parameter
 CFLAGS += $(CFLAGS_OPTIMIZATION)
 CFLAGS += $(CFLAGS_CURSES)
 
-LDLIBS += -lreadline $(LDLIBS_CURSES)
+LDLIBS += $(LDLIBS_CURSES)
 
 DISTFILES = src nnn.1 Makefile README.md LICENSE
 SRC = src/nnn.c
@@ -33,10 +33,14 @@ all: $(BIN)
 $(SRC): src/nnn.h
 
 $(BIN): $(SRC)
-       $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
+       $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS) -lreadline
 
 debug: $(SRC)
-       $(CC) -DDBGMODE -g $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $(BIN) $^ $(LDLIBS)
+       $(CC) -DDBGMODE -g $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $(BIN) $^ $(LDLIBS) -lreadline
+
+norl: $(SRC)
+       $(CC) -DNORL $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $(BIN) $^ $(LDLIBS)
+       $(STRIP) $(BIN)
 
 install: all
        $(INSTALL) -m 0755 -d $(DESTDIR)$(PREFIX)/bin
index acda89b33847a2bf83fb78737ffa12807b9a534a..e3166741d1cf5dddd8c934d3dc01a0fc8a0c386a 100644 (file)
--- a/README.md
+++ b/README.md
@@ -135,7 +135,7 @@ Intrigued? Find out [HOW](https://github.com/jarun/nnn/wiki/performance-factors)
 
 #### Library dependencies
 
-`nnn` needs a curses library with wide character support (like ncursesw), libreadline and standard libc.
+`nnn` needs a curses library with wide character support (like ncursesw), libreadline and standard libc. It's possible to drop libreadline using the Makefile target `norl`.
 
 #### Utility dependencies
 
index 10f9e6e9fc4df3265c69ffa12f845253d60e891a..89d7ded3dc0760dccd038317470fd2e6259d1b86 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
 #include <locale.h>
 #include <pwd.h>
 #include <stdio.h>
+#ifndef NORL
 #include <readline/history.h>
 #include <readline/readline.h>
+#endif
 #include <regex.h>
 #include <signal.h>
 #include <stdarg.h>
@@ -3879,11 +3881,14 @@ nochange:
                                }
                                break;
                        default: /* SEL_RUNCMD */
+#ifndef NORL
                                if (cfg.picker) {
                                        /* readline prompt breaks the interface, use stock */
+#endif
                                        tmp = xreadline(NULL, "> ");
                                        if (tmp[0])
                                                spawn(shell, "-c", tmp, path, F_NORMAL | F_SIGINT);
+#ifndef NORL
                                } else {
                                        exitcurses();
 
@@ -3909,6 +3914,7 @@ nochange:
                                                free(tmp);
                                        }
                                }
+#endif
                        }
 
                        /* Continue in navigate-as-you-type mode, if enabled */
@@ -4243,6 +4249,7 @@ int main(int argc, char *argv[])
        crc8init();
 #endif
 
+#ifndef NORL
        /* Bind TAB to cycling */
        rl_variable_bind("completion-ignore-case", "on");
 #ifdef __linux__
@@ -4251,6 +4258,7 @@ int main(int argc, char *argv[])
        rl_bind_key('\t', rl_complete);
 #endif
        read_history(NULL);
+#endif
 
 #ifdef DBGMODE
        enabledbg();
@@ -4261,7 +4269,9 @@ int main(int argc, char *argv[])
        browse(ipath);
        exitcurses();
 
+#ifndef NORL
        write_history(NULL);
+#endif
 
        if (cfg.pickraw) {
                if (copybufpos) {