My build of nnn with minor changes
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

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