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