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.
 
 
 
 
 
 

148 lignes
3.7 KiB

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