2
0

Makefile 2.4 KB

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