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.
 
 
 
 
 
 

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