2 # Copyright (C) 2009 Salvatore Sanfilippo <antirez at gmail dot com>
3 # This file is released under the BSD license, see the COPYING file
5 release_hdr := $(shell sh -c './mkreleasehdr.sh')
6 uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
8 ifeq ($(uname_S),SunOS)
9 CFLAGS?= -std=c99 -pedantic $(OPTIMIZATION) -Wall -W -D__EXTENSIONS__ -D_XPG6
10 CCLINK?= -ldl -lnsl -lsocket -lm -lpthread
13 CFLAGS?= -std=c99 -pedantic $(OPTIMIZATION) -Wall -W $(ARCH) $(PROF)
15 DEBUG?= -g -rdynamic -ggdb
18 ifeq ($(USE_TCMALLOC),yes)
20 ALLOC_FLAGS=-DUSE_TCMALLOC
23 ifeq ($(USE_TCMALLOC_MINIMAL),yes)
24 ALLOC_LINK=-ltcmalloc_minimal
25 ALLOC_FLAGS=-DUSE_TCMALLOC
28 ifeq ($(USE_JEMALLOC),yes)
30 ALLOC_FLAGS=-DUSE_JEMALLOC
33 CCLINK+= $(ALLOC_LINK)
34 CFLAGS+= $(ALLOC_FLAGS)
36 CCOPT= $(CFLAGS) $(CCLINK) $(ARCH) $(PROF)
39 INSTALL_BIN= $(PREFIX)/bin
44 LINKCOLOR="\033[34;1m"
47 MAKECOLOR="\033[32;1m"
50 OBJ = adlist.o ae.o anet.o dict.o redis.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o ziplist.o release.o networking.o util.o object.o db.o replication.o rdb.o t_string.o t_list.o t_set.o t_zset.o t_hash.o config.o aof.o dscache.o pubsub.o multi.o debug.o sort.o intset.o syncio.o diskstore.o cluster.o crc16.o endian.o
51 BENCHOBJ = ae.o anet.o redis-benchmark.o sds.o adlist.o zmalloc.o
52 CLIOBJ = anet.o sds.o adlist.o redis-cli.o zmalloc.o release.o
53 CHECKDUMPOBJ = redis-check-dump.o lzf_c.o lzf_d.o
54 CHECKAOFOBJ = redis-check-aof.o
56 PRGNAME = redis-server
57 BENCHPRGNAME = redis-benchmark
58 CLIPRGNAME = redis-cli
59 CHECKDUMPPRGNAME = redis-check-dump
60 CHECKAOFPRGNAME = redis-check-aof
62 all: redis-benchmark redis-cli redis-check-dump redis-check-aof redis-server
64 @echo "Hint: To run 'make test' is a good idea ;)"
67 # Deps (use make dep to generate this)
68 adlist.o: adlist.c adlist.h zmalloc.h
69 ae.o: ae.c ae.h zmalloc.h config.h ae_kqueue.c
70 ae_epoll.o: ae_epoll.c
71 ae_kqueue.o: ae_kqueue.c
72 ae_select.o: ae_select.c
73 anet.o: anet.c fmacros.h anet.h
74 aof.o: aof.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
75 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
76 config.o: config.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
77 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
78 db.o: db.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
79 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
80 debug.o: debug.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
81 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h sha1.h
82 dict.o: dict.c fmacros.h dict.h zmalloc.h
83 diskstore.o: diskstore.c redis.h fmacros.h config.h ae.h sds.h dict.h \
84 adlist.h zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
85 dscache.o: dscache.c redis.h fmacros.h config.h ae.h sds.h dict.h \
86 adlist.h zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
87 intset.o: intset.c intset.h zmalloc.h
88 lzf_c.o: lzf_c.c lzfP.h
89 lzf_d.o: lzf_d.c lzfP.h
90 multi.o: multi.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
91 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
92 networking.o: networking.c redis.h fmacros.h config.h ae.h sds.h dict.h \
93 adlist.h zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
94 object.o: object.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
95 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
97 pubsub.o: pubsub.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
98 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
99 rdb.o: rdb.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
100 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h lzf.h
101 redis-benchmark.o: redis-benchmark.c fmacros.h ae.h \
102 ../deps/hiredis/hiredis.h sds.h adlist.h zmalloc.h
103 redis-check-aof.o: redis-check-aof.c fmacros.h config.h
104 redis-check-dump.o: redis-check-dump.c lzf.h
105 redis-cli.o: redis-cli.c fmacros.h version.h ../deps/hiredis/hiredis.h \
106 sds.h zmalloc.h ../deps/linenoise/linenoise.h help.h
107 redis.o: redis.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
108 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h asciilogo.h
109 release.o: release.c release.h
110 replication.o: replication.c redis.h fmacros.h config.h ae.h sds.h dict.h \
111 adlist.h zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
112 sds.o: sds.c sds.h zmalloc.h
113 sha1.o: sha1.c sha1.h
114 sort.o: sort.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
115 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h pqsort.h
116 syncio.o: syncio.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
117 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
118 t_hash.o: t_hash.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
119 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
120 t_list.o: t_list.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
121 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
122 t_set.o: t_set.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
123 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
124 t_string.o: t_string.c redis.h fmacros.h config.h ae.h sds.h dict.h \
125 adlist.h zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
126 t_zset.o: t_zset.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
127 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
128 util.o: util.c util.h
129 cluster.o: redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
130 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
131 ziplist.o: ziplist.c zmalloc.h ziplist.h
132 zipmap.o: zipmap.c zmalloc.h
133 zmalloc.o: zmalloc.c config.h
136 @echo $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)hiredis$(ENDCOLOR)
137 @cd ../deps/hiredis && $(MAKE) static ARCH="$(ARCH)"
138 @echo $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)linenoise$(ENDCOLOR)
139 @cd ../deps/linenoise && $(MAKE) ARCH="$(ARCH)"
142 @$(CC) -o $(PRGNAME) $(CCOPT) $(DEBUG) $(OBJ)
143 @echo $(LINKCOLOR)LINK$(ENDCOLOR) $(BINCOLOR)$(@)$(ENDCOLOR)
145 redis-benchmark: dependencies $(BENCHOBJ)
146 @cd ../deps/hiredis && $(MAKE) static
147 @$(CC) -o $(BENCHPRGNAME) $(CCOPT) $(DEBUG) $(BENCHOBJ) ../deps/hiredis/libhiredis.a
148 @echo $(LINKCOLOR)LINK$(ENDCOLOR) $(BINCOLOR)$(@)$(ENDCOLOR)
151 @$(CC) -c $(CFLAGS) -I../deps/hiredis $(DEBUG) $(COMPILE_TIME) $<
152 @echo $(CCCOLOR)CC$(ENDCOLOR) $(SRCCOLOR)$(<)$(ENDCOLOR)
154 redis-cli: dependencies $(CLIOBJ)
155 @$(CC) -o $(CLIPRGNAME) $(CCOPT) $(DEBUG) $(CLIOBJ) ../deps/hiredis/libhiredis.a ../deps/linenoise/linenoise.o
156 @echo $(LINKCOLOR)LINK$(ENDCOLOR) $(BINCOLOR)$(@)$(ENDCOLOR)
159 @$(CC) -c $(CFLAGS) -I../deps/hiredis -I../deps/linenoise $(DEBUG) $(COMPILE_TIME) $<
160 @echo $(CCCOLOR)CC$(ENDCOLOR) $(SRCCOLOR)$(<)$(ENDCOLOR)
162 redis-check-dump: $(CHECKDUMPOBJ)
163 @$(CC) -o $(CHECKDUMPPRGNAME) $(CCOPT) $(DEBUG) $(CHECKDUMPOBJ)
164 @echo $(LINKCOLOR)LINK$(ENDCOLOR) $(BINCOLOR)$(@)$(ENDCOLOR)
166 redis-check-aof: $(CHECKAOFOBJ)
167 @$(CC) -o $(CHECKAOFPRGNAME) $(CCOPT) $(DEBUG) $(CHECKAOFOBJ)
168 @echo $(LINKCOLOR)LINK$(ENDCOLOR) $(BINCOLOR)$(@)$(ENDCOLOR)
171 @$(CC) -c $(CFLAGS) $(DEBUG) $(COMPILE_TIME) $<
172 @echo $(CCCOLOR)CC$(ENDCOLOR) $(SRCCOLOR)$(<)$(ENDCOLOR)
175 rm -rf $(PRGNAME) $(BENCHPRGNAME) $(CLIPRGNAME) $(CHECKDUMPPRGNAME) $(CHECKAOFPRGNAME) *.o *.gcda *.gcno *.gcov
178 $(CC) -MM *.c -I ../deps/hiredis -I ../deps/linenoise
181 @(cd ..; (which tclsh >/dev/null && tclsh tests/test_helper.tcl --tags "${TAGS}" --file "${FILE}") || echo "You need to install Tcl in order to run tests.")
187 git log '--pretty=format:%ad %s (%cn)' --date=short > ../Changelog
191 @echo "WARNING: if it fails under Linux you probably need to install libc6-dev-i386"
199 $(MAKE) PROF="-fprofile-arcs -ftest-coverage"
202 $(MAKE) OPTIMIZATION=""
205 $(MAKE) PROF="-pg" ARCH="-arch i386"
208 mkdir -p $(INSTALL_BIN)
209 $(INSTALL) $(PRGNAME) $(INSTALL_BIN)
210 $(INSTALL) $(BENCHPRGNAME) $(INSTALL_BIN)
211 $(INSTALL) $(CLIPRGNAME) $(INSTALL_BIN)
212 $(INSTALL) $(CHECKDUMPPRGNAME) $(INSTALL_BIN)
213 $(INSTALL) $(CHECKAOFPRGNAME) $(INSTALL_BIN)