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.8 KiB

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