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.
 
 
 
 
 
 

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