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 2.5 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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
  31. LDLIBS += -lreadline
  32. endif
  33. ifeq ($(O_NOLOC),1)
  34. CPPFLAGS += -DNOLOCALE
  35. endif
  36. ifeq ($(shell $(PKG_CONFIG) ncursesw && echo 1),1)
  37. CFLAGS_CURSES ?= $(shell $(PKG_CONFIG) --cflags ncursesw)
  38. LDLIBS_CURSES ?= $(shell $(PKG_CONFIG) --libs ncursesw)
  39. else ifeq ($(shell $(PKG_CONFIG) ncurses && echo 1),1)
  40. CFLAGS_CURSES ?= $(shell $(PKG_CONFIG) --cflags ncurses)
  41. LDLIBS_CURSES ?= $(shell $(PKG_CONFIG) --libs ncurses)
  42. else
  43. LDLIBS_CURSES ?= -lncurses
  44. endif
  45. ifeq ($(shell uname -s), Haiku)
  46. LDLIBS_HAIKU ?= -lstdc++ -lbe
  47. SRC_HAIKU ?= misc/haiku/nm.cpp
  48. OBJS_HAIKU ?= misc/haiku/nm.o
  49. endif
  50. CFLAGS += -Wall -Wextra
  51. CFLAGS += $(CFLAGS_OPTIMIZATION)
  52. CFLAGS += $(CFLAGS_CURSES)
  53. LDLIBS += $(LDLIBS_CURSES) $(LDLIBS_HAIKU)
  54. DISTFILES = src nnn.1 Makefile README.md LICENSE
  55. SRC = src/nnn.c
  56. HEADERS = src/nnn.h
  57. BIN = nnn
  58. OBJS := nnn.o $(OBJS_HAIKU)
  59. all: $(BIN)
  60. ifeq ($(shell uname -s), Haiku)
  61. $(OBJS_HAIKU): $(SRC_HAIKU)
  62. $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
  63. endif
  64. nnn.o: $(SRC) $(HEADERS)
  65. $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
  66. $(BIN): $(OBJS)
  67. $(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
  68. # targets for backwards compatibility
  69. debug: $(BIN)
  70. norl: $(BIN)
  71. noloc: $(BIN)
  72. install: all
  73. $(INSTALL) -m 0755 -d $(DESTDIR)$(PREFIX)/bin
  74. $(INSTALL) -m 0755 $(BIN) $(DESTDIR)$(PREFIX)/bin
  75. $(INSTALL) -m 0755 -d $(DESTDIR)$(MANPREFIX)/man1
  76. $(INSTALL) -m 0644 $(BIN).1 $(DESTDIR)$(MANPREFIX)/man1
  77. uninstall:
  78. $(RM) $(DESTDIR)$(PREFIX)/bin/$(BIN)
  79. $(RM) $(DESTDIR)$(MANPREFIX)/man1/$(BIN).1
  80. strip: $(BIN)
  81. $(STRIP) $^
  82. dist:
  83. mkdir -p nnn-$(VERSION)
  84. $(CP) -r $(DISTFILES) nnn-$(VERSION)
  85. mkdir -p nnn-$(VERSION)/misc
  86. $(CP) -r misc/haiku nnn-$(VERSION)/misc
  87. tar -cf - nnn-$(VERSION) | gzip > nnn-$(VERSION).tar.gz
  88. $(RM) -r nnn-$(VERSION)
  89. clean:
  90. $(RM) -f $(BIN) $(OBJS) nnn-$(VERSION).tar.gz
  91. skip: ;
  92. .PHONY: all debug install uninstall strip dist clean