My build of nnn with minor changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

101 lines
2.0 KiB

  1. VERSION = 2.7
  2. PREFIX ?= /usr/local
  3. MANPREFIX ?= $(PREFIX)/share/man
  4. STRIP ?= strip
  5. PKG_CONFIG ?= pkg-config
  6. INSTALL ?= install
  7. CP ?= cp
  8. CFLAGS_OPTIMIZATION ?= -O3
  9. O_DEBUG := 0
  10. O_NORL := 0 # no readline support
  11. O_NOLOC := 0 # no locale support
  12. # convert targets to flags for backwards compatibility
  13. ifneq ($(filter debug,$(MAKECMDGOALS)),)
  14. O_DEBUG := 1
  15. endif
  16. ifneq ($(filter norl,$(MAKECMDGOALS)),)
  17. O_NORL := 1
  18. endif
  19. ifneq ($(filter noloc,$(MAKECMDGOALS)),)
  20. O_NORL := 1
  21. O_NOLOC := 1
  22. endif
  23. ifeq ($(O_DEBUG),1)
  24. CPPFLAGS += -DDBGMODE
  25. CFLAGS += -g
  26. LDLIBS += -lrt
  27. endif
  28. ifeq ($(O_NORL),1)
  29. CPPFLAGS += -DNORL
  30. else
  31. LDLIBS += -lreadline
  32. endif
  33. ifeq ($(O_NOLOC),1)
  34. CPPFLAGS += -DNOLOCALE
  35. endif
  36. ifeq ($(shell $(PKG_CONFIG) ncursesw && echo 1),1)
  37. CFLAGS_CURSES ?= $(shell $(PKG_CONFIG) --cflags ncursesw)
  38. LDLIBS_CURSES ?= $(shell $(PKG_CONFIG) --libs ncursesw)
  39. else ifeq ($(shell $(PKG_CONFIG) ncurses && echo 1),1)
  40. CFLAGS_CURSES ?= $(shell $(PKG_CONFIG) --cflags ncurses)
  41. LDLIBS_CURSES ?= $(shell $(PKG_CONFIG) --libs ncurses)
  42. else
  43. LDLIBS_CURSES ?= -lncurses
  44. endif
  45. CFLAGS += -Wall -Wextra
  46. CFLAGS += $(CFLAGS_OPTIMIZATION)
  47. CFLAGS += $(CFLAGS_CURSES)
  48. LDLIBS += $(LDLIBS_CURSES)
  49. DISTFILES = src nnn.1 Makefile README.md LICENSE
  50. SRC = src/nnn.c
  51. HEADERS = src/nnn.h
  52. BIN = nnn
  53. all: $(BIN)
  54. $(BIN): $(SRC) $(HEADERS)
  55. $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
  56. # targets for backwards compatibility
  57. debug: $(BIN)
  58. norl: $(BIN)
  59. noloc: $(BIN)
  60. install: all
  61. $(INSTALL) -m 0755 -d $(DESTDIR)$(PREFIX)/bin
  62. $(INSTALL) -m 0755 $(BIN) $(DESTDIR)$(PREFIX)/bin
  63. $(INSTALL) -m 0755 -d $(DESTDIR)$(MANPREFIX)/man1
  64. $(INSTALL) -m 0644 $(BIN).1 $(DESTDIR)$(MANPREFIX)/man1
  65. uninstall:
  66. $(RM) $(DESTDIR)$(PREFIX)/bin/$(BIN)
  67. $(RM) $(DESTDIR)$(MANPREFIX)/man1/$(BIN).1
  68. strip: $(BIN)
  69. $(STRIP) $^
  70. dist:
  71. mkdir -p nnn-$(VERSION)
  72. $(CP) -r $(DISTFILES) nnn-$(VERSION)
  73. tar -cf nnn-$(VERSION).tar nnn-$(VERSION)
  74. gzip nnn-$(VERSION).tar
  75. $(RM) -r nnn-$(VERSION)
  76. clean:
  77. $(RM) -f $(BIN) nnn-$(VERSION).tar.gz
  78. skip: ;
  79. .PHONY: all debug install uninstall strip dist clean