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