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.

Makefile 5.0 KiB

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