My build of nnn with minor changes
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 
 

190 строки
5.0 KiB

  1. VERSION = $(shell grep -m1 VERSION $(SRC) | cut -f 2 -d'"')
  2. PREFIX ?= /usr/local
  3. MANPREFIX ?= $(PREFIX)/share/man
  4. DESKTOPPREFIX ?= $(PREFIX)/share/applications
  5. DESKTOPICONPREFIX ?= $(PREFIX)/share/icons/hicolor
  6. STRIP ?= strip
  7. PKG_CONFIG ?= pkg-config
  8. INSTALL ?= install
  9. CP ?= cp
  10. CFLAGS_OPTIMIZATION ?= -O3
  11. O_DEBUG := 0 # debug binary
  12. O_NORL := 0 # no readline support
  13. O_PCRE := 0 # link with PCRE library
  14. O_NOLOC := 0 # no locale support
  15. O_NOMOUSE := 0 # no mouse support
  16. O_NOBATCH := 0 # no built-in batch renamer
  17. O_NOFIFO := 0 # no FIFO previewer support
  18. O_CTX8 := 0 # enable 8 contexts
  19. O_ICONS := 0 # support icons-in-terminal
  20. O_NERD := 0 # support icons-nerdfont
  21. O_QSORT := 0 # use Alexey Tourbin's QSORT implementation
  22. O_BENCH := 0 # benchmark mode (stops at first user input)
  23. # convert targets to flags for backwards compatibility
  24. ifneq ($(filter debug,$(MAKECMDGOALS)),)
  25. O_DEBUG := 1
  26. endif
  27. ifneq ($(filter norl,$(MAKECMDGOALS)),)
  28. O_NORL := 1
  29. endif
  30. ifneq ($(filter noloc,$(MAKECMDGOALS)),)
  31. O_NORL := 1
  32. O_NOLOC := 1
  33. endif
  34. ifeq ($(O_DEBUG),1)
  35. CPPFLAGS += -DDBGMODE
  36. CFLAGS += -g
  37. endif
  38. ifeq ($(O_NORL),1)
  39. CPPFLAGS += -DNORL
  40. else ifeq ($(O_STATIC),1)
  41. CPPFLAGS += -DNORL
  42. else
  43. LDLIBS += -lreadline
  44. endif
  45. ifeq ($(O_PCRE),1)
  46. CPPFLAGS += -DPCRE
  47. LDLIBS += -lpcre
  48. endif
  49. ifeq ($(O_NOLOC),1)
  50. CPPFLAGS += -DNOLOCALE
  51. endif
  52. ifeq ($(O_NOMOUSE),1)
  53. CPPFLAGS += -DNOMOUSE
  54. endif
  55. ifeq ($(O_NOBATCH),1)
  56. CPPFLAGS += -DNOBATCH
  57. endif
  58. ifeq ($(O_NOFIFO),1)
  59. CPPFLAGS += -DNOFIFO
  60. endif
  61. ifeq ($(O_CTX8),1)
  62. CPPFLAGS += -DCTX8
  63. endif
  64. ifeq ($(O_ICONS),1)
  65. CPPFLAGS += -DICONS
  66. endif
  67. ifeq ($(O_NERD),1)
  68. CPPFLAGS += -DNERD
  69. endif
  70. ifeq ($(O_QSORT),1)
  71. CPPFLAGS += -DTOURBIN_QSORT
  72. endif
  73. ifeq ($(O_BENCH),1)
  74. CPPFLAGS += -DBENCH
  75. endif
  76. ifeq ($(shell $(PKG_CONFIG) ncursesw && echo 1),1)
  77. CFLAGS_CURSES ?= $(shell $(PKG_CONFIG) --cflags ncursesw)
  78. LDLIBS_CURSES ?= $(shell $(PKG_CONFIG) --libs ncursesw)
  79. else ifeq ($(shell $(PKG_CONFIG) ncurses && echo 1),1)
  80. CFLAGS_CURSES ?= $(shell $(PKG_CONFIG) --cflags ncurses)
  81. LDLIBS_CURSES ?= $(shell $(PKG_CONFIG) --libs ncurses)
  82. else
  83. LDLIBS_CURSES ?= -lncurses
  84. endif
  85. CFLAGS += -std=c11 -Wall -Wextra -Wshadow
  86. CFLAGS += $(CFLAGS_OPTIMIZATION)
  87. CFLAGS += $(CFLAGS_CURSES)
  88. LDLIBS += $(LDLIBS_CURSES)
  89. # static compilation needs libgpm development package
  90. ifeq ($(O_STATIC),1)
  91. LDFLAGS += -static
  92. LDLIBS += -lgpm
  93. endif
  94. DISTFILES = src nnn.1 Makefile README.md LICENSE
  95. SRC = src/nnn.c
  96. HEADERS = src/nnn.h
  97. BIN = nnn
  98. DESKTOPFILE = misc/desktop/nnn.desktop
  99. LOGOSVG = misc/logo/logo.svg
  100. LOGO64X64 = misc/logo/logo-64x64.png
  101. all: $(BIN)
  102. $(BIN): $(SRC) $(HEADERS)
  103. $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
  104. # targets for backwards compatibility
  105. debug: $(BIN)
  106. norl: $(BIN)
  107. noloc: $(BIN)
  108. install-desktop: $(DESKTOPFILE)
  109. $(INSTALL) -m 0755 -d $(DESTDIR)$(DESKTOPPREFIX)
  110. $(INSTALL) -m 0644 $(DESKTOPFILE) $(DESTDIR)$(DESKTOPPREFIX)
  111. $(INSTALL) -m 0755 -d $(DESTDIR)$(DESKTOPICONPREFIX)/scalable/apps
  112. $(INSTALL) -m 0644 $(LOGOSVG) $(DESTDIR)$(DESKTOPICONPREFIX)/scalable/apps/nnn.svg
  113. $(INSTALL) -m 0755 -d $(DESTDIR)$(DESKTOPICONPREFIX)/64x64/apps
  114. $(INSTALL) -m 0644 $(LOGO64X64) $(DESTDIR)$(DESKTOPICONPREFIX)/64x64/apps/nnn.png
  115. uninstall-desktop:
  116. $(RM) $(DESTDIR)$(DESKTOPPREFIX)/$(DESKTOPFILE)
  117. $(RM) $(DESTDIR)$(DESKTOPICONPREFIX)/scalable/apps/nnn.svg
  118. $(RM) $(DESTDIR)$(DESKTOPICONPREFIX)/64x64/apps/nnn.png
  119. install: all
  120. $(INSTALL) -m 0755 -d $(DESTDIR)$(PREFIX)/bin
  121. $(INSTALL) -m 0755 $(BIN) $(DESTDIR)$(PREFIX)/bin
  122. $(INSTALL) -m 0755 -d $(DESTDIR)$(MANPREFIX)/man1
  123. $(INSTALL) -m 0644 $(BIN).1 $(DESTDIR)$(MANPREFIX)/man1
  124. uninstall:
  125. $(RM) $(DESTDIR)$(PREFIX)/bin/$(BIN)
  126. $(RM) $(DESTDIR)$(MANPREFIX)/man1/$(BIN).1
  127. strip: $(BIN)
  128. $(STRIP) $^
  129. static:
  130. make O_STATIC=1 strip
  131. mv $(BIN) $(BIN)-static
  132. dist:
  133. mkdir -p nnn-$(VERSION)
  134. $(CP) -r $(DISTFILES) nnn-$(VERSION)
  135. tar -cf - nnn-$(VERSION) | gzip > nnn-$(VERSION).tar.gz
  136. $(RM) -r nnn-$(VERSION)
  137. sign:
  138. git archive -o nnn-$(VERSION).tar.gz --format tar.gz --prefix=nnn-$(VERSION)/ v$(VERSION)
  139. gpg --detach-sign --yes nnn-$(VERSION).tar.gz
  140. rm -f nnn-$(VERSION).tar.gz
  141. upload-local: sign static
  142. $(eval ID=$(shell curl -s 'https://api.github.com/repos/jarun/nnn/releases/tags/v$(VERSION)' | jq .id))
  143. curl -XPOST 'https://uploads.github.com/repos/jarun/nnn/releases/$(ID)/assets?name=nnn-$(VERSION).tar.gz.sig' \
  144. -H 'Authorization: token $(NNN_SIG_UPLOAD_TOKEN)' -H 'Content-Type: application/pgp-signature' \
  145. --upload-file nnn-$(VERSION).tar.gz.sig
  146. tar -zcf $(BIN)-static-$(VERSION).x86_64.tar.gz $(BIN)-static
  147. curl -XPOST 'https://uploads.github.com/repos/jarun/nnn/releases/$(ID)/assets?name=$(BIN)-static-$(VERSION).x86_64.tar.gz' \
  148. -H 'Authorization: token $(NNN_SIG_UPLOAD_TOKEN)' -H 'Content-Type: application/x-sharedlib' \
  149. --upload-file $(BIN)-static-$(VERSION).x86_64.tar.gz
  150. clean:
  151. $(RM) -f $(BIN) nnn-$(VERSION).tar.gz *.sig $(BIN)-static $(BIN)-static-$(VERSION).x86_64.tar.gz
  152. skip: ;
  153. .PHONY: all install uninstall strip static dist sign upload-local clean install-desktop uninstall-desktop