My build of nnn with minor changes
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

132 wiersze
3.3 KiB

  1. VERSION = $(shell grep -m1 VERSION $(SRC) | cut -f 2 -d'"')
  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. endif
  27. ifeq ($(O_NORL),1)
  28. CPPFLAGS += -DNORL
  29. else ifeq ($(O_STATIC),1)
  30. CPPFLAGS += -DNORL
  31. else
  32. LDLIBS += -lreadline
  33. endif
  34. ifeq ($(O_PCRE),1)
  35. CPPFLAGS += -DPCRE
  36. LDLIBS += -lpcre
  37. endif
  38. ifeq ($(O_NOLOC),1)
  39. CPPFLAGS += -DNOLOCALE
  40. endif
  41. ifeq ($(shell $(PKG_CONFIG) ncursesw && echo 1),1)
  42. CFLAGS_CURSES ?= $(shell $(PKG_CONFIG) --cflags ncursesw)
  43. LDLIBS_CURSES ?= $(shell $(PKG_CONFIG) --libs ncursesw)
  44. else ifeq ($(shell $(PKG_CONFIG) ncurses && echo 1),1)
  45. CFLAGS_CURSES ?= $(shell $(PKG_CONFIG) --cflags ncurses)
  46. LDLIBS_CURSES ?= $(shell $(PKG_CONFIG) --libs ncurses)
  47. else
  48. LDLIBS_CURSES ?= -lncurses
  49. endif
  50. CFLAGS += -Wall -Wextra
  51. CFLAGS += $(CFLAGS_OPTIMIZATION)
  52. CFLAGS += $(CFLAGS_CURSES)
  53. LDLIBS += $(LDLIBS_CURSES)
  54. # static compilation needs libgpm development package
  55. ifeq ($(O_STATIC),1)
  56. LDFLAGS += -static
  57. LDLIBS += -lgpm
  58. endif
  59. DISTFILES = src nnn.1 Makefile README.md LICENSE
  60. SRC = src/nnn.c
  61. HEADERS = src/nnn.h
  62. BIN = nnn
  63. all: $(BIN)
  64. $(BIN): $(SRC) $(HEADERS)
  65. $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
  66. # targets for backwards compatibility
  67. debug: $(BIN)
  68. norl: $(BIN)
  69. noloc: $(BIN)
  70. install: all
  71. $(INSTALL) -m 0755 -d $(DESTDIR)$(PREFIX)/bin
  72. $(INSTALL) -m 0755 $(BIN) $(DESTDIR)$(PREFIX)/bin
  73. $(INSTALL) -m 0755 -d $(DESTDIR)$(MANPREFIX)/man1
  74. $(INSTALL) -m 0644 $(BIN).1 $(DESTDIR)$(MANPREFIX)/man1
  75. uninstall:
  76. $(RM) $(DESTDIR)$(PREFIX)/bin/$(BIN)
  77. $(RM) $(DESTDIR)$(MANPREFIX)/man1/$(BIN).1
  78. strip: $(BIN)
  79. $(STRIP) $^
  80. static:
  81. make O_STATIC=1 strip
  82. mv $(BIN) $(BIN)-static
  83. dist:
  84. mkdir -p nnn-$(VERSION)
  85. $(CP) -r $(DISTFILES) nnn-$(VERSION)
  86. tar -cf - nnn-$(VERSION) | gzip > nnn-$(VERSION).tar.gz
  87. $(RM) -r nnn-$(VERSION)
  88. sign:
  89. git archive -o nnn-$(VERSION).tar.gz --format tar.gz --prefix=nnn-$(VERSION)/ v$(VERSION)
  90. gpg --detach-sign --yes nnn-$(VERSION).tar.gz
  91. rm -f nnn-$(VERSION).tar.gz
  92. upload-local: sign static
  93. $(eval ID=$(shell curl -s 'https://api.github.com/repos/jarun/nnn/releases/tags/v$(VERSION)' | jq .id))
  94. curl -XPOST 'https://uploads.github.com/repos/jarun/nnn/releases/$(ID)/assets?name=nnn-$(VERSION).tar.gz.sig' \
  95. -H 'Authorization: token $(NNN_SIG_UPLOAD_TOKEN)' -H 'Content-Type: application/pgp-signature' \
  96. --upload-file nnn-$(VERSION).tar.gz.sig
  97. tar -cf $(BIN)-static-$(VERSION).x86-64.tar.gz $(BIN)-static
  98. curl -XPOST 'https://uploads.github.com/repos/jarun/nnn/releases/$(ID)/assets?name=nnn-$(VERSION)-static' \
  99. -H 'Authorization: token $(NNN_SIG_UPLOAD_TOKEN)' -H 'Content-Type: application/x-sharedlib' \
  100. --upload-file $(BIN)-static-$(VERSION).x86-64.tar.gz
  101. clean:
  102. $(RM) -f $(BIN) nnn-$(VERSION).tar.gz *.sig \
  103. $(BIN)-static $(BIN)-static-$(VERSION).x86-64.tar.gz
  104. skip: ;
  105. .PHONY: all install uninstall strip static dist sign upload-local clean