]> git.saurik.com Git - redis.git/blob - src/Makefile
Take a pointer to the relevant entry of the command table in the client structure...
[redis.git] / src / Makefile
1 # Redis Makefile
2 # Copyright (C) 2009 Salvatore Sanfilippo <antirez at gmail dot com>
3 # This file is released under the BSD license, see the COPYING file
4
5 release_hdr := $(shell sh -c './mkreleasehdr.sh')
6 uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
7 OPTIMIZATION?=-O2
8
9 ifeq ($(uname_S),Linux)
10 ifneq ($(FORCE_LIBC_MALLOC),yes)
11 USE_JEMALLOC=yes
12 endif
13 endif
14
15 ifeq ($(uname_S),SunOS)
16 CFLAGS?=-std=c99 -pedantic $(OPTIMIZATION) -Wall -W -D__EXTENSIONS__ -D_XPG6
17 CCLINK?=-ldl -lnsl -lsocket -lm -lpthread
18 DEBUG?=-g -ggdb
19 else
20 CFLAGS?=-std=c99 -pedantic $(OPTIMIZATION) -Wall -W $(ARCH) $(PROF)
21 CCLINK?=-lm -pthread
22 DEBUG?=-g -rdynamic -ggdb
23 endif
24
25 ifeq ($(USE_TCMALLOC),yes)
26 ALLOD_DEPS=
27 ALLOC_LINK=-ltcmalloc
28 ALLOC_FLAGS=-DUSE_TCMALLOC
29 endif
30
31 ifeq ($(USE_TCMALLOC_MINIMAL),yes)
32 ALLOD_DEPS=
33 ALLOC_LINK=-ltcmalloc_minimal
34 ALLOC_FLAGS=-DUSE_TCMALLOC
35 endif
36
37 ifeq ($(USE_JEMALLOC),yes)
38 ALLOC_DEP=../deps/jemalloc/lib/libjemalloc.a
39 ALLOC_LINK=$(ALLOC_DEP) -ldl
40 ALLOC_FLAGS=-DUSE_JEMALLOC -I../deps/jemalloc/include
41 endif
42
43 CCLINK+= $(ALLOC_LINK)
44 CFLAGS+= $(ALLOC_FLAGS)
45
46 CCOPT= $(CFLAGS) $(ARCH) $(PROF)
47
48 PREFIX= /usr/local
49 INSTALL_BIN= $(PREFIX)/bin
50 INSTALL= cp -p
51
52 CCCOLOR="\033[34m"
53 LINKCOLOR="\033[34;1m"
54 SRCCOLOR="\033[33m"
55 BINCOLOR="\033[37;1m"
56 MAKECOLOR="\033[32;1m"
57 ENDCOLOR="\033[0m"
58
59 ifndef V
60 QUIET_CC = @printf ' %b %b\n' $(CCCOLOR)CC$(ENDCOLOR) $(SRCCOLOR)$@$(ENDCOLOR);
61 QUIET_LINK = @printf ' %b %b\n' $(LINKCOLOR)LINK$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR);
62 endif
63
64 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 pubsub.o multi.o debug.o sort.o intset.o syncio.o cluster.o crc16.o endian.o slowlog.o
65 BENCHOBJ = ae.o anet.o redis-benchmark.o sds.o adlist.o zmalloc.o
66 CLIOBJ = anet.o sds.o adlist.o redis-cli.o zmalloc.o release.o
67 CHECKDUMPOBJ = redis-check-dump.o lzf_c.o lzf_d.o
68 CHECKAOFOBJ = redis-check-aof.o
69
70 PRGNAME = redis-server
71 BENCHPRGNAME = redis-benchmark
72 CLIPRGNAME = redis-cli
73 CHECKDUMPPRGNAME = redis-check-dump
74 CHECKAOFPRGNAME = redis-check-aof
75
76 all: redis-benchmark redis-cli redis-check-dump redis-check-aof redis-server
77 @echo ""
78 @echo "Hint: To run 'make test' is a good idea ;)"
79 @echo ""
80
81 # Deps (use make dep to generate this)
82 adlist.o: adlist.c adlist.h zmalloc.h
83 ae.o: ae.c ae.h zmalloc.h config.h ae_kqueue.c
84 ae_epoll.o: ae_epoll.c
85 ae_kqueue.o: ae_kqueue.c
86 ae_select.o: ae_select.c
87 anet.o: anet.c fmacros.h anet.h
88 aof.o: aof.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
89 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h util.h slowlog.h
90 cluster.o: cluster.c redis.h fmacros.h config.h ae.h sds.h dict.h \
91 adlist.h zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h util.h \
92 slowlog.h
93 config.o: config.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
94 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h util.h slowlog.h
95 crc16.o: crc16.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
96 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h util.h slowlog.h
97 db.o: db.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 util.h slowlog.h
99 debug.o: debug.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 util.h slowlog.h \
101 sha1.h
102 dict.o: dict.c fmacros.h dict.h zmalloc.h
103 endian.o: endian.c
104 intset.o: intset.c intset.h zmalloc.h endian.h
105 lzf_c.o: lzf_c.c lzfP.h
106 lzf_d.o: lzf_d.c lzfP.h
107 multi.o: multi.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 util.h slowlog.h
109 networking.o: networking.c redis.h fmacros.h config.h ae.h sds.h dict.h \
110 adlist.h zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h util.h \
111 slowlog.h
112 object.o: object.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
113 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h util.h slowlog.h
114 pqsort.o: pqsort.c
115 pubsub.o: pubsub.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
116 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h util.h slowlog.h
117 rdb.o: rdb.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
118 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h util.h slowlog.h \
119 lzf.h
120 redis-benchmark.o: redis-benchmark.c fmacros.h ae.h \
121 ../deps/hiredis/hiredis.h sds.h adlist.h zmalloc.h
122 redis-check-aof.o: redis-check-aof.c fmacros.h config.h
123 redis-check-dump.o: redis-check-dump.c lzf.h
124 redis-cli.o: redis-cli.c fmacros.h version.h ../deps/hiredis/hiredis.h \
125 sds.h zmalloc.h ../deps/linenoise/linenoise.h help.h
126 redis.o: redis.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 util.h slowlog.h \
128 asciilogo.h
129 release.o: release.c release.h
130 replication.o: replication.c redis.h fmacros.h config.h ae.h sds.h dict.h \
131 adlist.h zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h util.h \
132 slowlog.h
133 sds.o: sds.c sds.h zmalloc.h
134 sha1.o: sha1.c sha1.h config.h
135 slowlog.o: slowlog.c redis.h fmacros.h config.h ae.h sds.h dict.h \
136 adlist.h zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h util.h \
137 slowlog.h
138 sort.o: sort.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
139 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h util.h slowlog.h \
140 pqsort.h
141 syncio.o: syncio.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
142 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h util.h slowlog.h
143 t_hash.o: t_hash.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
144 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h util.h slowlog.h
145 t_list.o: t_list.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
146 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h util.h slowlog.h
147 t_set.o: t_set.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
148 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h util.h slowlog.h
149 t_string.o: t_string.c redis.h fmacros.h config.h ae.h sds.h dict.h \
150 adlist.h zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h util.h \
151 slowlog.h
152 t_zset.o: t_zset.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
153 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h util.h slowlog.h
154 util.o: util.c fmacros.h util.h
155 ziplist.o: ziplist.c zmalloc.h util.h ziplist.h endian.h
156 zipmap.o: zipmap.c zmalloc.h endian.h
157 zmalloc.o: zmalloc.c config.h zmalloc.h
158
159 .PHONY: dependencies
160
161 dependencies:
162 @printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)hiredis$(ENDCOLOR)
163 @cd ../deps/hiredis && $(MAKE) static ARCH="$(ARCH)"
164 @printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)linenoise$(ENDCOLOR)
165 @cd ../deps/linenoise && $(MAKE) ARCH="$(ARCH)"
166
167 ../deps/jemalloc/lib/libjemalloc.a:
168 cd ../deps/jemalloc && ./configure $(JEMALLOC_CFLAGS) --with-jemalloc-prefix=je_ --enable-cc-silence && $(MAKE) lib/libjemalloc.a
169
170 redis-server: $(OBJ)
171 $(QUIET_CC)$(CC) -o $(PRGNAME) $(CCOPT) $(DEBUG) $(OBJ) $(CCLINK) $(ALLOC_LINK)
172
173 redis-benchmark: dependencies $(BENCHOBJ)
174 @cd ../deps/hiredis && $(MAKE) static
175 $(QUIET_LINK)$(CC) -o $(BENCHPRGNAME) $(CCOPT) $(DEBUG) $(BENCHOBJ) ../deps/hiredis/libhiredis.a $(CCLINK) $(ALLOC_LINK)
176
177 redis-benchmark.o:
178 $(QUIET_CC)$(CC) -c $(CFLAGS) -I../deps/hiredis $(DEBUG) $(COMPILE_TIME) $<
179
180 redis-cli: dependencies $(CLIOBJ)
181 $(QUIET_LINK)$(CC) -o $(CLIPRGNAME) $(CCOPT) $(DEBUG) $(CLIOBJ) ../deps/hiredis/libhiredis.a ../deps/linenoise/linenoise.o $(CCLINK) $(ALLOC_LINK)
182
183 redis-cli.o:
184 $(QUIET_CC)$(CC) -c $(CFLAGS) -I../deps/hiredis -I../deps/linenoise $(DEBUG) $(COMPILE_TIME) $<
185
186 redis-check-dump: $(CHECKDUMPOBJ)
187 $(QUIET_LINK)$(CC) -o $(CHECKDUMPPRGNAME) $(CCOPT) $(DEBUG) $(CHECKDUMPOBJ) $(CCLINK) $(ALLOC_LINK)
188
189 redis-check-aof: $(CHECKAOFOBJ)
190 $(QUIET_LINK)$(CC) -o $(CHECKAOFPRGNAME) $(CCOPT) $(DEBUG) $(CHECKAOFOBJ) $(CCLINK) $(ALLOC_LINK)
191
192 # Because the jemalloc.h header is generated as a part of the jemalloc build
193 # process, building it should complete before building any other object.
194 %.o: %.c $(ALLOC_DEP)
195 $(QUIET_CC)$(CC) -c $(CFLAGS) $(DEBUG) $(COMPILE_TIME) $<
196
197 clean:
198 rm -rf $(PRGNAME) $(BENCHPRGNAME) $(CLIPRGNAME) $(CHECKDUMPPRGNAME) $(CHECKAOFPRGNAME) *.o *.gcda *.gcno *.gcov
199
200 dep:
201 $(CC) -MM *.c -I ../deps/hiredis -I ../deps/linenoise
202
203 test: redis-server
204 @(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.")
205
206 bench:
207 ./redis-benchmark
208
209 log:
210 git log '--pretty=format:%ad %s (%cn)' --date=short > ../Changelog
211
212 32bit:
213 @echo ""
214 @echo "WARNING: if it fails under Linux you probably need to install libc6-dev-i386"
215 @echo ""
216 $(MAKE) ARCH="-m32" JEMALLOC_CFLAGS='CFLAGS="-std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -m32"'
217
218 gprof:
219 $(MAKE) PROF="-pg"
220
221 gcov:
222 $(MAKE) PROF="-fprofile-arcs -ftest-coverage"
223
224 noopt:
225 $(MAKE) OPTIMIZATION=""
226
227 32bitgprof:
228 $(MAKE) PROF="-pg" ARCH="-arch i386"
229
230 install: all
231 mkdir -p $(INSTALL_BIN)
232 $(INSTALL) $(PRGNAME) $(INSTALL_BIN)
233 $(INSTALL) $(BENCHPRGNAME) $(INSTALL_BIN)
234 $(INSTALL) $(CLIPRGNAME) $(INSTALL_BIN)
235 $(INSTALL) $(CHECKDUMPPRGNAME) $(INSTALL_BIN)
236 $(INSTALL) $(CHECKAOFPRGNAME) $(INSTALL_BIN)