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.
 
 
 
 
 
 

153 lignes
3.8 KiB

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