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