My build of nnn with minor changes
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

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