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.
 
 
 
 
 
 

139 lignes
3.4 KiB

  1. VERSION = $(shell grep -m1 VERSION $(SRC) | cut -f 2 -d'"')
  2. PREFIX ?= /usr/local
  3. MANPREFIX ?= $(PREFIX)/share/man
  4. STRIP ?= strip
  5. PKG_CONFIG ?= pkg-config
  6. INSTALL ?= install
  7. CP ?= cp
  8. CFLAGS_OPTIMIZATION ?= -O3
  9. O_DEBUG := 0
  10. O_NORL := 0 # no readline support
  11. O_NOLOC := 0 # no locale support
  12. # convert targets to flags for backwards compatibility
  13. ifneq ($(filter debug,$(MAKECMDGOALS)),)
  14. O_DEBUG := 1
  15. endif
  16. ifneq ($(filter norl,$(MAKECMDGOALS)),)
  17. O_NORL := 1
  18. endif
  19. ifneq ($(filter noloc,$(MAKECMDGOALS)),)
  20. O_NORL := 1
  21. O_NOLOC := 1
  22. endif
  23. ifeq ($(O_DEBUG),1)
  24. CPPFLAGS += -DDBGMODE
  25. CFLAGS += -g
  26. endif
  27. ifeq ($(O_NORL),1)
  28. CPPFLAGS += -DNORL
  29. else ifeq ($(O_STATIC),1)
  30. CPPFLAGS += -DNORL
  31. else
  32. LDLIBS += -lreadline
  33. endif
  34. ifeq ($(O_PCRE),1)
  35. CPPFLAGS += -DPCRE
  36. LDLIBS += -lpcre
  37. endif
  38. ifeq ($(O_NOLOC),1)
  39. CPPFLAGS += -DNOLOCALE
  40. endif
  41. ifeq ($(O_NOMOUSE),1)
  42. CPPFLAGS += -DNOMOUSE
  43. endif
  44. ifeq ($(O_NOBATCH),1)
  45. CPPFLAGS += -DNOBATCH
  46. endif
  47. ifeq ($(shell $(PKG_CONFIG) ncursesw && echo 1),1)
  48. CFLAGS_CURSES ?= $(shell $(PKG_CONFIG) --cflags ncursesw)
  49. LDLIBS_CURSES ?= $(shell $(PKG_CONFIG) --libs ncursesw)
  50. else ifeq ($(shell $(PKG_CONFIG) ncurses && echo 1),1)
  51. CFLAGS_CURSES ?= $(shell $(PKG_CONFIG) --cflags ncurses)
  52. LDLIBS_CURSES ?= $(shell $(PKG_CONFIG) --libs ncurses)
  53. else
  54. LDLIBS_CURSES ?= -lncurses
  55. endif
  56. CFLAGS += -Wall -Wextra
  57. CFLAGS += $(CFLAGS_OPTIMIZATION)
  58. CFLAGS += $(CFLAGS_CURSES)
  59. LDLIBS += $(LDLIBS_CURSES)
  60. # static compilation needs libgpm development package
  61. ifeq ($(O_STATIC),1)
  62. LDFLAGS += -static
  63. LDLIBS += -lgpm
  64. endif
  65. DISTFILES = src nnn.1 Makefile README.md LICENSE
  66. SRC = src/nnn.c
  67. HEADERS = src/nnn.h
  68. BIN = nnn
  69. all: $(BIN)
  70. $(BIN): $(SRC) $(HEADERS)
  71. $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
  72. # targets for backwards compatibility
  73. debug: $(BIN)
  74. norl: $(BIN)
  75. noloc: $(BIN)
  76. install: all
  77. $(INSTALL) -m 0755 -d $(DESTDIR)$(PREFIX)/bin
  78. $(INSTALL) -m 0755 $(BIN) $(DESTDIR)$(PREFIX)/bin
  79. $(INSTALL) -m 0755 -d $(DESTDIR)$(MANPREFIX)/man1
  80. $(INSTALL) -m 0644 $(BIN).1 $(DESTDIR)$(MANPREFIX)/man1
  81. uninstall:
  82. $(RM) $(DESTDIR)$(PREFIX)/bin/$(BIN)
  83. $(RM) $(DESTDIR)$(MANPREFIX)/man1/$(BIN).1
  84. strip: $(BIN)
  85. $(STRIP) $^
  86. static:
  87. make O_STATIC=1 strip
  88. mv $(BIN) $(BIN)-static
  89. dist:
  90. mkdir -p nnn-$(VERSION)
  91. $(CP) -r $(DISTFILES) nnn-$(VERSION)
  92. tar -cf - nnn-$(VERSION) | gzip > nnn-$(VERSION).tar.gz
  93. $(RM) -r nnn-$(VERSION)
  94. sign:
  95. git archive -o nnn-$(VERSION).tar.gz --format tar.gz --prefix=nnn-$(VERSION)/ v$(VERSION)
  96. gpg --detach-sign --yes nnn-$(VERSION).tar.gz
  97. rm -f nnn-$(VERSION).tar.gz
  98. upload-local: sign static
  99. $(eval ID=$(shell curl -s 'https://api.github.com/repos/jarun/nnn/releases/tags/v$(VERSION)' | jq .id))
  100. curl -XPOST 'https://uploads.github.com/repos/jarun/nnn/releases/$(ID)/assets?name=nnn-$(VERSION).tar.gz.sig' \
  101. -H 'Authorization: token $(NNN_SIG_UPLOAD_TOKEN)' -H 'Content-Type: application/pgp-signature' \
  102. --upload-file nnn-$(VERSION).tar.gz.sig
  103. tar -zcf $(BIN)-static-$(VERSION).x86-64.tar.gz $(BIN)-static
  104. curl -XPOST 'https://uploads.github.com/repos/jarun/nnn/releases/$(ID)/assets?name=$(BIN)-static-$(VERSION).x86-64.tar.gz' \
  105. -H 'Authorization: token $(NNN_SIG_UPLOAD_TOKEN)' -H 'Content-Type: application/x-sharedlib' \
  106. --upload-file $(BIN)-static-$(VERSION).x86-64.tar.gz
  107. clean:
  108. $(RM) -f $(BIN) nnn-$(VERSION).tar.gz *.sig $(BIN)-static $(BIN)-static-$(VERSION).x86-64.tar.gz
  109. skip: ;
  110. .PHONY: all install uninstall strip static dist sign upload-local clean