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