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.
 
 
 
 
 
 

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