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