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.2 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. # convert targets to flags for backwards compatibility
  19. ifneq ($(filter debug,$(MAKECMDGOALS)),)
  20. O_DEBUG := 1
  21. endif
  22. ifneq ($(filter norl,$(MAKECMDGOALS)),)
  23. O_NORL := 1
  24. endif
  25. ifneq ($(filter noloc,$(MAKECMDGOALS)),)
  26. O_NORL := 1
  27. O_NOLOC := 1
  28. endif
  29. ifeq ($(O_DEBUG),1)
  30. CPPFLAGS += -DDBGMODE
  31. CFLAGS += -g
  32. LDLIBS += -lrt
  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 ($(O_ICONS),1)
  61. CPPFLAGS += -DICONS
  62. endif
  63. ifeq ($(shell $(PKG_CONFIG) ncursesw && echo 1),1)
  64. CFLAGS_CURSES ?= $(shell $(PKG_CONFIG) --cflags ncursesw)
  65. LDLIBS_CURSES ?= $(shell $(PKG_CONFIG) --libs ncursesw)
  66. else ifeq ($(shell $(PKG_CONFIG) ncurses && echo 1),1)
  67. CFLAGS_CURSES ?= $(shell $(PKG_CONFIG) --cflags ncurses)
  68. LDLIBS_CURSES ?= $(shell $(PKG_CONFIG) --libs ncurses)
  69. else
  70. LDLIBS_CURSES ?= -lncurses
  71. endif
  72. ifeq ($(shell uname -s), Haiku)
  73. LDLIBS_HAIKU ?= -lstdc++ -lbe
  74. SRC_HAIKU ?= misc/haiku/nm.cpp
  75. OBJS_HAIKU ?= misc/haiku/nm.o
  76. endif
  77. CFLAGS += -Wall -Wextra
  78. CFLAGS += $(CFLAGS_OPTIMIZATION)
  79. CFLAGS += $(CFLAGS_CURSES)
  80. LDLIBS += $(LDLIBS_CURSES) $(LDLIBS_HAIKU)
  81. # static compilation needs libgpm development package
  82. ifeq ($(O_STATIC),1)
  83. LDFLAGS += -static
  84. LDLIBS += -lgpm
  85. endif
  86. DISTFILES = src nnn.1 Makefile README.md LICENSE
  87. SRC = src/nnn.c
  88. HEADERS = src/nnn.h
  89. BIN = nnn
  90. OBJS := nnn.o $(OBJS_HAIKU)
  91. all: $(BIN)
  92. ifeq ($(shell uname -s), Haiku)
  93. $(OBJS_HAIKU): $(SRC_HAIKU)
  94. $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
  95. endif
  96. nnn.o: $(SRC) $(HEADERS)
  97. $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
  98. $(BIN): $(OBJS)
  99. $(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
  100. # targets for backwards compatibility
  101. debug: $(BIN)
  102. norl: $(BIN)
  103. noloc: $(BIN)
  104. install: all
  105. $(INSTALL) -m 0755 -d $(DESTDIR)$(PREFIX)/bin
  106. $(INSTALL) -m 0755 $(BIN) $(DESTDIR)$(PREFIX)/bin
  107. $(INSTALL) -m 0755 -d $(DESTDIR)$(MANPREFIX)/man1
  108. $(INSTALL) -m 0644 $(BIN).1 $(DESTDIR)$(MANPREFIX)/man1
  109. uninstall:
  110. $(RM) $(DESTDIR)$(PREFIX)/bin/$(BIN)
  111. $(RM) $(DESTDIR)$(MANPREFIX)/man1/$(BIN).1
  112. strip: $(BIN)
  113. $(STRIP) $^
  114. static:
  115. make O_STATIC=1 strip
  116. mv $(BIN) $(BIN)-static
  117. dist:
  118. mkdir -p nnn-$(VERSION)
  119. $(CP) -r $(DISTFILES) nnn-$(VERSION)
  120. mkdir -p nnn-$(VERSION)/misc
  121. $(CP) -r misc/haiku nnn-$(VERSION)/misc
  122. tar -cf - nnn-$(VERSION) | gzip > nnn-$(VERSION).tar.gz
  123. $(RM) -r nnn-$(VERSION)
  124. sign:
  125. git archive -o nnn-$(VERSION).tar.gz --format tar.gz --prefix=nnn-$(VERSION)/ v$(VERSION)
  126. gpg --detach-sign --yes nnn-$(VERSION).tar.gz
  127. rm -f nnn-$(VERSION).tar.gz
  128. upload-local: sign static
  129. $(eval ID=$(shell curl -s 'https://api.github.com/repos/jarun/nnn/releases/tags/v$(VERSION)' | jq .id))
  130. curl -XPOST 'https://uploads.github.com/repos/jarun/nnn/releases/$(ID)/assets?name=nnn-$(VERSION).tar.gz.sig' \
  131. -H 'Authorization: token $(NNN_SIG_UPLOAD_TOKEN)' -H 'Content-Type: application/pgp-signature' \
  132. --upload-file nnn-$(VERSION).tar.gz.sig
  133. tar -zcf $(BIN)-static-$(VERSION).x86_64.tar.gz $(BIN)-static
  134. curl -XPOST 'https://uploads.github.com/repos/jarun/nnn/releases/$(ID)/assets?name=$(BIN)-static-$(VERSION).x86_64.tar.gz' \
  135. -H 'Authorization: token $(NNN_SIG_UPLOAD_TOKEN)' -H 'Content-Type: application/x-sharedlib' \
  136. --upload-file $(BIN)-static-$(VERSION).x86_64.tar.gz
  137. clean:
  138. $(RM) -f $(BIN) nnn-$(VERSION).tar.gz *.sig $(BIN)-static $(BIN)-static-$(VERSION).x86_64.tar.gz
  139. skip: ;
  140. .PHONY: all install uninstall strip static dist sign upload-local clean