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