My build of nnn with minor changes
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

202 řádky
4.9 KiB

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