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.

Makefile 3.4 KiB

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