- zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
-util.o: util.c util.h
-cluster.o: redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
- zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
-ziplist.o: ziplist.c zmalloc.h ziplist.h
-zipmap.o: zipmap.c zmalloc.h
-zmalloc.o: zmalloc.c config.h
-
-dependencies:
- @echo $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)hiredis$(ENDCOLOR)
- @cd ../deps/hiredis && $(MAKE) static ARCH="$(ARCH)"
- @echo $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)linenoise$(ENDCOLOR)
- @cd ../deps/linenoise && $(MAKE) ARCH="$(ARCH)"
-
-redis-server: $(OBJ)
- @$(CC) -o $(PRGNAME) $(CCOPT) $(DEBUG) $(OBJ)
- @echo $(LINKCOLOR)LINK$(ENDCOLOR) $(BINCOLOR)$(@)$(ENDCOLOR)
-
-redis-benchmark: dependencies $(BENCHOBJ)
- @cd ../deps/hiredis && $(MAKE) static
- @$(CC) -o $(BENCHPRGNAME) $(CCOPT) $(DEBUG) $(BENCHOBJ) ../deps/hiredis/libhiredis.a
- @echo $(LINKCOLOR)LINK$(ENDCOLOR) $(BINCOLOR)$(@)$(ENDCOLOR)
-
-redis-benchmark.o:
- @$(CC) -c $(CFLAGS) -I../deps/hiredis $(DEBUG) $(COMPILE_TIME) $<
- @echo $(CCCOLOR)CC$(ENDCOLOR) $(SRCCOLOR)$(<)$(ENDCOLOR)
-
-redis-cli: dependencies $(CLIOBJ)
- @$(CC) -o $(CLIPRGNAME) $(CCOPT) $(DEBUG) $(CLIOBJ) ../deps/hiredis/libhiredis.a ../deps/linenoise/linenoise.o
- @echo $(LINKCOLOR)LINK$(ENDCOLOR) $(BINCOLOR)$(@)$(ENDCOLOR)
-
-redis-cli.o:
- @$(CC) -c $(CFLAGS) -I../deps/hiredis -I../deps/linenoise $(DEBUG) $(COMPILE_TIME) $<
- @echo $(CCCOLOR)CC$(ENDCOLOR) $(SRCCOLOR)$(<)$(ENDCOLOR)
-
-redis-check-dump: $(CHECKDUMPOBJ)
- @$(CC) -o $(CHECKDUMPPRGNAME) $(CCOPT) $(DEBUG) $(CHECKDUMPOBJ)
- @echo $(LINKCOLOR)LINK$(ENDCOLOR) $(BINCOLOR)$(@)$(ENDCOLOR)
-
-redis-check-aof: $(CHECKAOFOBJ)
- @$(CC) -o $(CHECKAOFPRGNAME) $(CCOPT) $(DEBUG) $(CHECKAOFOBJ)
- @echo $(LINKCOLOR)LINK$(ENDCOLOR) $(BINCOLOR)$(@)$(ENDCOLOR)
-
-.c.o:
- @$(CC) -c $(CFLAGS) $(DEBUG) $(COMPILE_TIME) $<
- @echo $(CCCOLOR)CC$(ENDCOLOR) $(SRCCOLOR)$(<)$(ENDCOLOR)
+ zmalloc.h anet.h ziplist.h intset.h version.h util.h rdb.h rio.h
+util.o: util.c fmacros.h util.h
+ziplist.o: ziplist.c zmalloc.h util.h ziplist.h endianconv.h
+zipmap.o: zipmap.c zmalloc.h endianconv.h
+zmalloc.o: zmalloc.c config.h zmalloc.h
+
+# Clean local objects when ARCH is different
+ifneq ($(shell sh -c '[ -f .make-arch ] && cat .make-arch'), $(ARCH))
+.make-arch: clean
+else
+.make-arch:
+endif
+
+.make-arch:
+ -(cd ../deps && $(MAKE) $(DEPENDENCY_TARGETS) ARCH="$(ARCH)")
+ -(echo $(ARCH) > .make-arch)
+
+# Clean local objects when allocator changes
+ifneq ($(shell sh -c '[ -f .make-malloc ] && cat .make-malloc'), $(MALLOC))
+.make-malloc: clean
+else
+.make-malloc:
+endif
+
+.make-malloc:
+ -(echo $(MALLOC) > .make-malloc)
+
+# Union of make-prerequisites
+.make-prerequisites: .make-arch .make-malloc
+ @touch $@
+
+redis-server: .make-prerequisites $(OBJ)
+ $(QUIET_LINK)$(CC) -o $(PRGNAME) $(CCOPT) $(DEBUG) $(OBJ) ../deps/lua/src/liblua.a $(CCLINK)
+
+redis-benchmark: .make-prerequisites $(BENCHOBJ)
+ $(QUIET_LINK)$(CC) -o $(BENCHPRGNAME) $(CCOPT) $(DEBUG) $(BENCHOBJ) ../deps/hiredis/libhiredis.a $(CCLINK)
+
+redis-benchmark.o: redis-benchmark.c .make-prerequisites
+ $(QUIET_CC)$(CC) -c $(CFLAGS) -I../deps/hiredis $(DEBUG) $(COMPILE_TIME) $<
+
+redis-cli: .make-prerequisites $(CLIOBJ)
+ $(QUIET_LINK)$(CC) -o $(CLIPRGNAME) $(CCOPT) $(DEBUG) $(CLIOBJ) ../deps/hiredis/libhiredis.a ../deps/linenoise/linenoise.o $(CCLINK)
+
+redis-cli.o: redis-cli.c .make-prerequisites
+ $(QUIET_CC)$(CC) -c $(CFLAGS) -I../deps/hiredis -I../deps/linenoise $(DEBUG) $(COMPILE_TIME) $<
+
+redis-check-dump: .make-prerequisites $(CHECKDUMPOBJ)
+ $(QUIET_LINK)$(CC) -o $(CHECKDUMPPRGNAME) $(CCOPT) $(DEBUG) $(CHECKDUMPOBJ) $(CCLINK)
+
+redis-check-aof: .make-prerequisites $(CHECKAOFOBJ)
+ $(QUIET_LINK)$(CC) -o $(CHECKAOFPRGNAME) $(CCOPT) $(DEBUG) $(CHECKAOFOBJ) $(CCLINK)
+
+# Because the jemalloc.h header is generated as a part of the jemalloc build
+# process, building it should complete before building any other object. Instead of
+# depending on a single artifact, simply build all dependencies first.
+%.o: %.c .make-prerequisites
+ $(QUIET_CC)$(CC) -c $(CFLAGS) $(DEBUG) $(COMPILE_TIME) -I../deps/lua/src $<
+
+.PHONY: all clean distclean