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.
 
 
 
 
 
 

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