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.
 
 
 
 
 
 

121 lignes
2.8 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. LDLIBS += -lrt
  27. endif
  28. ifeq ($(O_NORL),1)
  29. CPPFLAGS += -DNORL
  30. else
  31. LDLIBS += -lreadline
  32. endif
  33. ifeq ($(O_PCRE),1)
  34. CPPFLAGS += -DPCRE
  35. LDLIBS += -lpcre
  36. endif
  37. ifeq ($(O_NOLOC),1)
  38. CPPFLAGS += -DNOLOCALE
  39. endif
  40. ifeq ($(shell $(PKG_CONFIG) ncursesw && echo 1),1)
  41. CFLAGS_CURSES ?= $(shell $(PKG_CONFIG) --cflags ncursesw)
  42. LDLIBS_CURSES ?= $(shell $(PKG_CONFIG) --libs ncursesw)
  43. else ifeq ($(shell $(PKG_CONFIG) ncurses && echo 1),1)
  44. CFLAGS_CURSES ?= $(shell $(PKG_CONFIG) --cflags ncurses)
  45. LDLIBS_CURSES ?= $(shell $(PKG_CONFIG) --libs ncurses)
  46. else
  47. LDLIBS_CURSES ?= -lncurses
  48. endif
  49. CFLAGS += -Wall -Wextra
  50. CFLAGS += $(CFLAGS_OPTIMIZATION)
  51. CFLAGS += $(CFLAGS_CURSES)
  52. LDLIBS += $(LDLIBS_CURSES)
  53. # static compilation needs libgpm development package
  54. ifeq ($(O_STATIC),1)
  55. LDFLAGS += -static
  56. LDLIBS += -lgpm
  57. endif
  58. DISTFILES = src nnn.1 Makefile README.md LICENSE
  59. SRC = src/nnn.c
  60. HEADERS = src/nnn.h
  61. BIN = nnn
  62. all: $(BIN)
  63. $(BIN): $(SRC) $(HEADERS)
  64. $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
  65. # targets for backwards compatibility
  66. debug: $(BIN)
  67. norl: $(BIN)
  68. noloc: $(BIN)
  69. install: all
  70. $(INSTALL) -m 0755 -d $(DESTDIR)$(PREFIX)/bin
  71. $(INSTALL) -m 0755 $(BIN) $(DESTDIR)$(PREFIX)/bin
  72. $(INSTALL) -m 0755 -d $(DESTDIR)$(MANPREFIX)/man1
  73. $(INSTALL) -m 0644 $(BIN).1 $(DESTDIR)$(MANPREFIX)/man1
  74. uninstall:
  75. $(RM) $(DESTDIR)$(PREFIX)/bin/$(BIN)
  76. $(RM) $(DESTDIR)$(MANPREFIX)/man1/$(BIN).1
  77. strip: $(BIN)
  78. $(STRIP) $^
  79. dist:
  80. mkdir -p nnn-$(VERSION)
  81. $(CP) -r $(DISTFILES) nnn-$(VERSION)
  82. tar -cf - nnn-$(VERSION) | gzip > nnn-$(VERSION).tar.gz
  83. $(RM) -r nnn-$(VERSION)
  84. sign:
  85. git archive -o nnn-$(VERSION).tar.gz --format tar.gz --prefix=nnn-$(VERSION)/ v$(VERSION)
  86. gpg --detach-sign --yes nnn-$(VERSION).tar.gz
  87. rm -f nnn-$(VERSION).tar.gz
  88. $(eval ID=$(shell curl -s 'https://api.github.com/repos/jarun/nnn/releases/tags/v$(VERSION)' | jq .id))
  89. curl -XPOST 'https://uploads.github.com/repos/jarun/nnn/releases/$(ID)/assets?name=nnn-$(VERSION).tar.gz.sig' \
  90. -H 'Authorization: token $(NNN_SIG_UPLOAD_TOKEN)' -H 'Content-Type: application/pgp-signature' \
  91. --upload-file nnn-$(VERSION).tar.gz.sig
  92. clean:
  93. $(RM) -f $(BIN) nnn-$(VERSION).tar.gz *.sig
  94. skip: ;
  95. .PHONY: all install uninstall strip dist sign clean