Makefile 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. -(rm -f .make-*)
  33. .PHONY: distclean
  34. ifeq ($(BUILD_TLS),yes)
  35. HIREDIS_MAKE_FLAGS = USE_SSL=1
  36. endif
  37. hiredis: .make-prerequisites
  38. @printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
  39. cd hiredis && $(MAKE) static $(HIREDIS_MAKE_FLAGS)
  40. .PHONY: hiredis
  41. linenoise: .make-prerequisites
  42. @printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
  43. cd linenoise && $(MAKE)
  44. .PHONY: linenoise
  45. ifeq ($(uname_S),SunOS)
  46. # Make isinf() available
  47. LUA_CFLAGS= -D__C99FEATURES__=1
  48. endif
  49. LUA_CFLAGS+= -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' $(CFLAGS)
  50. LUA_LDFLAGS+= $(LDFLAGS)
  51. # lua's Makefile defines AR="ar rcu", which is unusual, and makes it more
  52. # challenging to cross-compile lua (and redis). These defines make it easier
  53. # to fit redis into cross-compilation environments, which typically set AR.
  54. AR=ar
  55. ARFLAGS=rcu
  56. lua: .make-prerequisites
  57. @printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
  58. cd lua/src && $(MAKE) all CFLAGS="$(LUA_CFLAGS)" MYLDFLAGS="$(LUA_LDFLAGS)" AR="$(AR) $(ARFLAGS)"
  59. .PHONY: lua
  60. JEMALLOC_CFLAGS= -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops $(CFLAGS)
  61. JEMALLOC_LDFLAGS= $(LDFLAGS)
  62. jemalloc: .make-prerequisites
  63. @printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
  64. cd jemalloc && ./configure --with-version=5.1.0-0-g0 --with-lg-quantum=3 --with-jemalloc-prefix=je_ --enable-cc-silence CFLAGS="$(JEMALLOC_CFLAGS)" LDFLAGS="$(JEMALLOC_LDFLAGS)"
  65. cd jemalloc && $(MAKE) CFLAGS="$(JEMALLOC_CFLAGS)" LDFLAGS="$(JEMALLOC_LDFLAGS)" lib/libjemalloc.a
  66. .PHONY: jemalloc