]>
Commit | Line | Data |
---|---|---|
ed9b544e | 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 | ||
73287b2b | 5 | release_hdr := $(shell sh -c './mkreleasehdr.sh') |
325d1eb4 | 6 | uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not') |
25fd2cb2 | 7 | OPTIMIZATION?=-O2 |
4b8a6394 | 8 | DEPENDENCY_TARGETS=hiredis linenoise lua |
b83e9583 | 9 | |
325d1eb4 | 10 | ifeq ($(uname_S),SunOS) |
9e62dc17 | 11 | CFLAGS?=-std=c99 -pedantic $(OPTIMIZATION) -Wall -W -D__EXTENSIONS__ -D_XPG6 |
12 | CCLINK?=-ldl -lnsl -lsocket -lm -lpthread | |
13 | DEBUG?=-g -ggdb | |
325d1eb4 | 14 | else |
9e62dc17 | 15 | CFLAGS?=-std=c99 -pedantic $(OPTIMIZATION) -Wall -W $(ARCH) $(PROF) |
16 | CCLINK?=-lm -pthread | |
17 | DEBUG?=-g -rdynamic -ggdb | |
325d1eb4 | 18 | endif |
0a802bd7 | 19 | |
5bb2c88e PN |
20 | # Default allocator |
21 | ifeq ($(uname_S),Linux) | |
22 | MALLOC?=jemalloc | |
23 | else | |
24 | MALLOC?=libc | |
25 | endif | |
26 | ||
27 | # Backwards compatibility for selecting an allocator | |
0a802bd7 | 28 | ifeq ($(USE_TCMALLOC),yes) |
5bb2c88e PN |
29 | MALLOC=tcmalloc |
30 | endif | |
31 | ||
32 | ifeq ($(USE_TCMALLOC_MINIMAL),yes) | |
33 | MALLOC=tcmalloc_minimal | |
34 | endif | |
35 | ||
36 | ifeq ($(USE_JEMALLOC),yes) | |
37 | MALLOC=jemalloc | |
38 | endif | |
39 | ||
40 | ifeq ($(MALLOC),tcmalloc) | |
52825621 PN |
41 | ALLOC_LINK=-ltcmalloc |
42 | ALLOC_FLAGS=-DUSE_TCMALLOC | |
0a802bd7 | 43 | endif |
52825621 | 44 | |
5bb2c88e | 45 | ifeq ($(MALLOC),tcmalloc_minimal) |
52825621 PN |
46 | ALLOC_LINK=-ltcmalloc_minimal |
47 | ALLOC_FLAGS=-DUSE_TCMALLOC | |
48 | endif | |
49 | ||
5bb2c88e | 50 | ifeq ($(MALLOC),jemalloc) |
4b8a6394 | 51 | ALLOC_LINK=../deps/jemalloc/lib/libjemalloc.a -ldl |
9e62dc17 | 52 | ALLOC_FLAGS=-DUSE_JEMALLOC -I../deps/jemalloc/include |
4b8a6394 | 53 | DEPENDENCY_TARGETS+= jemalloc |
52825621 PN |
54 | endif |
55 | ||
56 | CCLINK+= $(ALLOC_LINK) | |
57 | CFLAGS+= $(ALLOC_FLAGS) | |
9e62dc17 | 58 | CCOPT= $(CFLAGS) $(ARCH) $(PROF) |
ed9b544e | 59 | |
e1386503 | 60 | PREFIX= /usr/local |
0997b411 | 61 | INSTALL_BIN= $(PREFIX)/bin |
120a36f2 | 62 | INSTALL= cp -pf |
acc01854 | 63 | |
35845afb | 64 | CCCOLOR="\033[34m" |
65 | LINKCOLOR="\033[34;1m" | |
66 | SRCCOLOR="\033[33m" | |
67 | BINCOLOR="\033[37;1m" | |
68 | MAKECOLOR="\033[32;1m" | |
69 | ENDCOLOR="\033[0m" | |
70 | ||
73e71867 | 71 | ifndef V |
db6cea11 HW |
72 | QUIET_CC = @printf ' %b %b\n' $(CCCOLOR)CC$(ENDCOLOR) $(SRCCOLOR)$@$(ENDCOLOR); |
73 | QUIET_LINK = @printf ' %b %b\n' $(LINKCOLOR)LINK$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR); | |
73e71867 | 74 | endif |
75 | ||
571e257d | 76 | 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 migrate.o crc16.o endianconv.o slowlog.o scripting.o bio.o rio.o rand.o |
970e10bb | 77 | BENCHOBJ = ae.o anet.o redis-benchmark.o sds.o adlist.o zmalloc.o |
11fd0c42 | 78 | CLIOBJ = anet.o sds.o adlist.o redis-cli.o zmalloc.o release.o |
08af4d5c | 79 | CHECKDUMPOBJ = redis-check-dump.o lzf_c.o lzf_d.o |
b4bd0524 | 80 | CHECKAOFOBJ = redis-check-aof.o |
ed9b544e | 81 | |
82 | PRGNAME = redis-server | |
83 | BENCHPRGNAME = redis-benchmark | |
84 | CLIPRGNAME = redis-cli | |
08af4d5c | 85 | CHECKDUMPPRGNAME = redis-check-dump |
b4bd0524 | 86 | CHECKAOFPRGNAME = redis-check-aof |
ed9b544e | 87 | |
240f8dbf | 88 | all: redis-benchmark redis-cli redis-check-dump redis-check-aof redis-server |
c8061392 PN |
89 | @echo "" |
90 | @echo "Hint: To run 'make test' is a good idea ;)" | |
91 | @echo "" | |
ed9b544e | 92 | |
93 | # Deps (use make dep to generate this) | |
9e9c0ce1 | 94 | adlist.o: adlist.c adlist.h zmalloc.h |
970e10bb | 95 | ae.o: ae.c ae.h zmalloc.h config.h ae_kqueue.c |
96 | ae_epoll.o: ae_epoll.c | |
97 | ae_kqueue.o: ae_kqueue.c | |
266373b2 | 98 | ae_select.o: ae_select.c |
9e9c0ce1 | 99 | anet.o: anet.c fmacros.h anet.h |
8fedd04d | 100 | aof.o: aof.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \ |
00b33363 | 101 | zmalloc.h anet.h ziplist.h intset.h version.h util.h rdb.h rio.h bio.h |
b147cb9e | 102 | bio.o: bio.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \ |
00b33363 | 103 | zmalloc.h anet.h ziplist.h intset.h version.h util.h rdb.h rio.h bio.h |
8fedd04d | 104 | config.o: config.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \ |
00b33363 | 105 | zmalloc.h anet.h ziplist.h intset.h version.h util.h rdb.h rio.h |
3e2a0bf4 | 106 | crc16.o: crc16.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \ |
00b33363 | 107 | zmalloc.h anet.h ziplist.h intset.h version.h util.h rdb.h rio.h |
8fedd04d | 108 | db.o: db.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \ |
00b33363 | 109 | zmalloc.h anet.h ziplist.h intset.h version.h util.h rdb.h rio.h |
8fedd04d | 110 | debug.o: debug.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \ |
00b33363 | 111 | zmalloc.h anet.h ziplist.h intset.h version.h util.h rdb.h rio.h sha1.h |
daa70b17 | 112 | dict.o: dict.c fmacros.h dict.h zmalloc.h |
7a3e3720 | 113 | endianconv.o: endianconv.c |
114 | intset.o: intset.c intset.h zmalloc.h endianconv.h | |
9e9c0ce1 | 115 | lzf_c.o: lzf_c.c lzfP.h |
116 | lzf_d.o: lzf_d.c lzfP.h | |
00b33363 | 117 | migrate.o: migrate.c redis.h fmacros.h config.h ae.h sds.h dict.h \ |
118 | adlist.h zmalloc.h anet.h ziplist.h intset.h version.h util.h rdb.h \ | |
119 | rio.h | |
8fedd04d | 120 | multi.o: multi.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \ |
00b33363 | 121 | zmalloc.h anet.h ziplist.h intset.h version.h util.h rdb.h rio.h |
8fedd04d | 122 | networking.o: networking.c redis.h fmacros.h config.h ae.h sds.h dict.h \ |
00b33363 | 123 | adlist.h zmalloc.h anet.h ziplist.h intset.h version.h util.h rdb.h \ |
124 | rio.h | |
8fedd04d | 125 | object.o: object.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \ |
00b33363 | 126 | zmalloc.h anet.h ziplist.h intset.h version.h util.h rdb.h rio.h |
9e9c0ce1 | 127 | pqsort.o: pqsort.c |
8fedd04d | 128 | pubsub.o: pubsub.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \ |
00b33363 | 129 | zmalloc.h anet.h ziplist.h intset.h version.h util.h rdb.h rio.h |
130 | rand.o: rand.c | |
8fedd04d | 131 | rdb.o: rdb.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \ |
00b33363 | 132 | zmalloc.h anet.h ziplist.h intset.h version.h util.h rdb.h rio.h lzf.h \ |
133 | zipmap.h | |
33388d43 | 134 | redis-benchmark.o: redis-benchmark.c fmacros.h ae.h \ |
135 | ../deps/hiredis/hiredis.h sds.h adlist.h zmalloc.h | |
7a121e60 | 136 | redis-check-aof.o: redis-check-aof.c fmacros.h config.h |
cf87ebf2 | 137 | redis-check-dump.o: redis-check-dump.c lzf.h |
33388d43 | 138 | redis-cli.o: redis-cli.c fmacros.h version.h ../deps/hiredis/hiredis.h \ |
139 | sds.h zmalloc.h ../deps/linenoise/linenoise.h help.h | |
8fedd04d | 140 | redis.o: redis.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \ |
00b33363 | 141 | zmalloc.h anet.h ziplist.h intset.h version.h util.h rdb.h rio.h \ |
142 | slowlog.h bio.h asciilogo.h | |
7c4fc71c | 143 | release.o: release.c release.h |
8fedd04d | 144 | replication.o: replication.c redis.h fmacros.h config.h ae.h sds.h dict.h \ |
00b33363 | 145 | adlist.h zmalloc.h anet.h ziplist.h intset.h version.h util.h rdb.h \ |
146 | rio.h | |
147 | rio.o: rio.c fmacros.h rio.h sds.h util.h | |
b147cb9e | 148 | scripting.o: scripting.c redis.h fmacros.h config.h ae.h sds.h dict.h \ |
00b33363 | 149 | adlist.h zmalloc.h anet.h ziplist.h intset.h version.h util.h rdb.h \ |
150 | rio.h sha1.h rand.h | |
9e9c0ce1 | 151 | sds.o: sds.c sds.h zmalloc.h |
3e2a0bf4 | 152 | sha1.o: sha1.c sha1.h config.h |
daa70b17 | 153 | slowlog.o: slowlog.c redis.h fmacros.h config.h ae.h sds.h dict.h \ |
00b33363 | 154 | adlist.h zmalloc.h anet.h ziplist.h intset.h version.h util.h rdb.h \ |
155 | rio.h slowlog.h | |
8fedd04d | 156 | sort.o: sort.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \ |
00b33363 | 157 | zmalloc.h anet.h ziplist.h intset.h version.h util.h rdb.h rio.h \ |
158 | pqsort.h | |
33388d43 | 159 | syncio.o: syncio.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \ |
00b33363 | 160 | zmalloc.h anet.h ziplist.h intset.h version.h util.h rdb.h rio.h |
8fedd04d | 161 | t_hash.o: t_hash.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \ |
00b33363 | 162 | zmalloc.h anet.h ziplist.h intset.h version.h util.h rdb.h rio.h |
8fedd04d | 163 | t_list.o: t_list.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \ |
00b33363 | 164 | zmalloc.h anet.h ziplist.h intset.h version.h util.h rdb.h rio.h |
8fedd04d | 165 | t_set.o: t_set.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \ |
00b33363 | 166 | zmalloc.h anet.h ziplist.h intset.h version.h util.h rdb.h rio.h |
8fedd04d | 167 | t_string.o: t_string.c redis.h fmacros.h config.h ae.h sds.h dict.h \ |
00b33363 | 168 | adlist.h zmalloc.h anet.h ziplist.h intset.h version.h util.h rdb.h \ |
169 | rio.h | |
8fedd04d | 170 | t_zset.o: t_zset.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \ |
00b33363 | 171 | zmalloc.h anet.h ziplist.h intset.h version.h util.h rdb.h rio.h |
3e2a0bf4 | 172 | util.o: util.c fmacros.h util.h |
7a3e3720 | 173 | ziplist.o: ziplist.c zmalloc.h util.h ziplist.h endianconv.h |
174 | zipmap.o: zipmap.c zmalloc.h endianconv.h | |
3e2a0bf4 | 175 | zmalloc.o: zmalloc.c config.h zmalloc.h |
ed9b544e | 176 | |
4b8a6394 PN |
177 | # Clean local objects when ARCH is different |
178 | ifneq ($(shell sh -c '[ -f .make-arch ] && cat .make-arch'), $(ARCH)) | |
179 | .make-arch: clean | |
180 | else | |
181 | .make-arch: | |
182 | endif | |
c8061392 | 183 | |
4b8a6394 | 184 | .make-arch: |
ac834d23 | 185 | -(cd ../deps && $(MAKE) $(DEPENDENCY_TARGETS) ARCH="$(ARCH)") |
4b8a6394 | 186 | -(echo $(ARCH) > .make-arch) |
9e62dc17 | 187 | |
5bb2c88e PN |
188 | # Clean local objects when allocator changes |
189 | ifneq ($(shell sh -c '[ -f .make-malloc ] && cat .make-malloc'), $(MALLOC)) | |
190 | .make-malloc: clean | |
191 | else | |
192 | .make-malloc: | |
193 | endif | |
194 | ||
195 | .make-malloc: | |
196 | -(echo $(MALLOC) > .make-malloc) | |
197 | ||
42c6a5da PN |
198 | # Union of make-prerequisites |
199 | .make-prerequisites: .make-arch .make-malloc | |
200 | @touch $@ | |
5bb2c88e | 201 | |
42c6a5da | 202 | redis-server: .make-prerequisites $(OBJ) |
321a0440 | 203 | $(QUIET_LINK)$(CC) -o $(PRGNAME) $(CCOPT) $(DEBUG) $(OBJ) ../deps/lua/src/liblua.a $(CCLINK) |
ed9b544e | 204 | |
42c6a5da | 205 | redis-benchmark: .make-prerequisites $(BENCHOBJ) |
61c0e893 | 206 | $(QUIET_LINK)$(CC) -o $(BENCHPRGNAME) $(CCOPT) $(DEBUG) $(BENCHOBJ) ../deps/hiredis/libhiredis.a $(CCLINK) |
ec8f0667 | 207 | |
42c6a5da | 208 | redis-benchmark.o: redis-benchmark.c .make-prerequisites |
73e71867 | 209 | $(QUIET_CC)$(CC) -c $(CFLAGS) -I../deps/hiredis $(DEBUG) $(COMPILE_TIME) $< |
ed9b544e | 210 | |
42c6a5da | 211 | redis-cli: .make-prerequisites $(CLIOBJ) |
61c0e893 | 212 | $(QUIET_LINK)$(CC) -o $(CLIPRGNAME) $(CCOPT) $(DEBUG) $(CLIOBJ) ../deps/hiredis/libhiredis.a ../deps/linenoise/linenoise.o $(CCLINK) |
7fc4ce13 | 213 | |
42c6a5da | 214 | redis-cli.o: redis-cli.c .make-prerequisites |
73e71867 | 215 | $(QUIET_CC)$(CC) -c $(CFLAGS) -I../deps/hiredis -I../deps/linenoise $(DEBUG) $(COMPILE_TIME) $< |
ed9b544e | 216 | |
42c6a5da | 217 | redis-check-dump: .make-prerequisites $(CHECKDUMPOBJ) |
61c0e893 | 218 | $(QUIET_LINK)$(CC) -o $(CHECKDUMPPRGNAME) $(CCOPT) $(DEBUG) $(CHECKDUMPOBJ) $(CCLINK) |
08af4d5c | 219 | |
42c6a5da | 220 | redis-check-aof: .make-prerequisites $(CHECKAOFOBJ) |
61c0e893 | 221 | $(QUIET_LINK)$(CC) -o $(CHECKAOFPRGNAME) $(CCOPT) $(DEBUG) $(CHECKAOFOBJ) $(CCLINK) |
b4bd0524 | 222 | |
9e62dc17 | 223 | # Because the jemalloc.h header is generated as a part of the jemalloc build |
4b8a6394 PN |
224 | # process, building it should complete before building any other object. Instead of |
225 | # depending on a single artifact, simply build all dependencies first. | |
42c6a5da | 226 | %.o: %.c .make-prerequisites |
0d1650f8 | 227 | $(QUIET_CC)$(CC) -c $(CFLAGS) $(DEBUG) $(COMPILE_TIME) -I../deps/lua/src $< |
ed9b544e | 228 | |
4b8a6394 PN |
229 | .PHONY: all clean distclean |
230 | ||
ed9b544e | 231 | clean: |
b4bd0524 | 232 | rm -rf $(PRGNAME) $(BENCHPRGNAME) $(CLIPRGNAME) $(CHECKDUMPPRGNAME) $(CHECKAOFPRGNAME) *.o *.gcda *.gcno *.gcov |
4b8a6394 PN |
233 | |
234 | distclean: clean | |
235 | -(cd ../deps && $(MAKE) distclean) | |
5bb2c88e | 236 | -(rm -f .make-arch .make-malloc) |
ed9b544e | 237 | |
238 | dep: | |
33388d43 | 239 | $(CC) -MM *.c -I ../deps/hiredis -I ../deps/linenoise |
ed9b544e | 240 | |
e6fcb5b3 | 241 | test: redis-server redis-check-aof |
f790bd02 | 242 | @(cd ..; ./runtest) |
ed9b544e | 243 | |
244 | bench: | |
245 | ./redis-benchmark | |
378fd421 | 246 | |
247 | log: | |
24110a4d | 248 | git log '--pretty=format:%ad %s (%cn)' --date=short > ../Changelog |
fd8ccf44 | 249 | |
250 | 32bit: | |
9ebed7cf | 251 | @echo "" |
252 | @echo "WARNING: if it fails under Linux you probably need to install libc6-dev-i386" | |
253 | @echo "" | |
e93d36a6 | 254 | $(MAKE) ARCH="-m32" JEMALLOC_CFLAGS='CFLAGS="-std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -m32"' |
d0ccebcf | 255 | |
256 | gprof: | |
a4e48b41 | 257 | $(MAKE) PROF="-pg" |
d0ccebcf | 258 | |
fc77604c | 259 | gcov: |
a4e48b41 | 260 | $(MAKE) PROF="-fprofile-arcs -ftest-coverage" |
fc77604c | 261 | |
25fd2cb2 | 262 | noopt: |
a4e48b41 | 263 | $(MAKE) OPTIMIZATION="" |
25fd2cb2 | 264 | |
d0ccebcf | 265 | 32bitgprof: |
a4e48b41 | 266 | $(MAKE) PROF="-pg" ARCH="-arch i386" |
acc01854 | 267 | |
319bb48c | 268 | src/help.h: |
269 | @../utils/generate-command-help.rb > help.h | |
270 | ||
acc01854 | 271 | install: all |
0bb5160c | 272 | mkdir -p $(INSTALL_BIN) |
273 | $(INSTALL) $(PRGNAME) $(INSTALL_BIN) | |
274 | $(INSTALL) $(BENCHPRGNAME) $(INSTALL_BIN) | |
275 | $(INSTALL) $(CLIPRGNAME) $(INSTALL_BIN) | |
276 | $(INSTALL) $(CHECKDUMPPRGNAME) $(INSTALL_BIN) | |
277 | $(INSTALL) $(CHECKAOFPRGNAME) $(INSTALL_BIN) |