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