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.
 
 
 
 
 
 

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