Makefile 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. # Redis dependency Makefile
  2. uname_S:= $(shell sh -c 'uname -s 2>/dev/null || echo not')
  3. CCCOLOR="\033[34m"
  4. LINKCOLOR="\033[34;1m"
  5. SRCCOLOR="\033[33m"
  6. BINCOLOR="\033[37;1m"
  7. MAKECOLOR="\033[32;1m"
  8. ENDCOLOR="\033[0m"
  9. default:
  10. @echo "Explicit target required"
  11. .PHONY: default
  12. # Prerequisites target
  13. .make-prerequisites:
  14. @touch $@
  15. # Clean everything when CFLAGS is different
  16. ifneq ($(shell sh -c '[ -f .make-cflags ] && cat .make-cflags || echo none'), $(CFLAGS))
  17. .make-cflags: distclean
  18. -(echo "$(CFLAGS)" > .make-cflags)
  19. .make-prerequisites: .make-cflags
  20. endif
  21. # Clean everything when LDFLAGS is different
  22. ifneq ($(shell sh -c '[ -f .make-ldflags ] && cat .make-ldflags || echo none'), $(LDFLAGS))
  23. .make-ldflags: distclean
  24. -(echo "$(LDFLAGS)" > .make-ldflags)
  25. .make-prerequisites: .make-ldflags
  26. endif
  27. distclean:
  28. -(cd hiredis && $(MAKE) clean) > /dev/null || true
  29. -(cd linenoise && $(MAKE) clean) > /dev/null || true
  30. -(cd lua && $(MAKE) clean) > /dev/null || true
  31. -(cd jemalloc && [ -f Makefile ] && $(MAKE) distclean) > /dev/null || true
  32. -(cd hdr_histogram && $(MAKE) clean) > /dev/null || true
  33. -(rm -f .make-*)
  34. .PHONY: distclean
  35. ifeq ($(BUILD_TLS),yes)
  36. HIREDIS_MAKE_FLAGS = USE_SSL=1
  37. endif
  38. hiredis: .make-prerequisites
  39. @printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
  40. cd hiredis && $(MAKE) static $(HIREDIS_MAKE_FLAGS)
  41. .PHONY: hiredis
  42. linenoise: .make-prerequisites
  43. @printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
  44. cd linenoise && $(MAKE)
  45. .PHONY: linenoise
  46. hdr_histogram: .make-prerequisites
  47. @printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
  48. cd hdr_histogram && $(MAKE)
  49. .PHONY: hdr_histogram
  50. ifeq ($(uname_S),SunOS)
  51. # Make isinf() available
  52. LUA_CFLAGS= -D__C99FEATURES__=1
  53. endif
  54. LUA_CFLAGS+= -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP $(CFLAGS)
  55. LUA_LDFLAGS+= $(LDFLAGS)
  56. # lua's Makefile defines AR="ar rcu", which is unusual, and makes it more
  57. # challenging to cross-compile lua (and redis). These defines make it easier
  58. # to fit redis into cross-compilation environments, which typically set AR.
  59. AR=ar
  60. ARFLAGS=rc
  61. lua: .make-prerequisites
  62. @printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
  63. cd lua/src && $(MAKE) all CFLAGS="$(LUA_CFLAGS)" MYLDFLAGS="$(LUA_LDFLAGS)" AR="$(AR) $(ARFLAGS)"
  64. .PHONY: lua
  65. JEMALLOC_CFLAGS= -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops $(CFLAGS)
  66. JEMALLOC_LDFLAGS= $(LDFLAGS)
  67. ifneq ($(DEB_HOST_GNU_TYPE),)
  68. JEMALLOC_CONFIGURE_OPTS += --host=$(DEB_HOST_GNU_TYPE)
  69. endif
  70. jemalloc: .make-prerequisites
  71. @printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
  72. cd jemalloc && ./configure --with-version=5.2.1-0-g0 --with-lg-quantum=3 --with-jemalloc-prefix=je_ CFLAGS="$(JEMALLOC_CFLAGS)" LDFLAGS="$(JEMALLOC_LDFLAGS)" $(JEMALLOC_CONFIGURE_OPTS)
  73. cd jemalloc && $(MAKE) CFLAGS="$(JEMALLOC_CFLAGS)" LDFLAGS="$(JEMALLOC_LDFLAGS)" lib/libjemalloc.a
  74. .PHONY: jemalloc