]> git.saurik.com Git - redis.git/blame - src/Makefile
Use CCLINK as last argument
[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)
b28d0461 49LUA_CFLAGS+= $(ARCH)
52825621 50
9e62dc17 51CCOPT= $(CFLAGS) $(ARCH) $(PROF)
ed9b544e 52
e1386503 53PREFIX= /usr/local
0997b411 54INSTALL_BIN= $(PREFIX)/bin
acc01854 55INSTALL= cp -p
56
35845afb 57CCCOLOR="\033[34m"
58LINKCOLOR="\033[34;1m"
59SRCCOLOR="\033[33m"
60BINCOLOR="\033[37;1m"
61MAKECOLOR="\033[32;1m"
62ENDCOLOR="\033[0m"
63
73e71867 64ifndef V
db6cea11
HW
65QUIET_CC = @printf ' %b %b\n' $(CCCOLOR)CC$(ENDCOLOR) $(SRCCOLOR)$@$(ENDCOLOR);
66QUIET_LINK = @printf ' %b %b\n' $(LINKCOLOR)LINK$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR);
73e71867 67endif
68
cbdac04a 69OBJ = 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 70BENCHOBJ = ae.o anet.o redis-benchmark.o sds.o adlist.o zmalloc.o
11fd0c42 71CLIOBJ = anet.o sds.o adlist.o redis-cli.o zmalloc.o release.o
08af4d5c 72CHECKDUMPOBJ = redis-check-dump.o lzf_c.o lzf_d.o
b4bd0524 73CHECKAOFOBJ = redis-check-aof.o
ed9b544e 74
75PRGNAME = redis-server
76BENCHPRGNAME = redis-benchmark
77CLIPRGNAME = redis-cli
08af4d5c 78CHECKDUMPPRGNAME = redis-check-dump
b4bd0524 79CHECKAOFPRGNAME = redis-check-aof
ed9b544e 80
240f8dbf 81all: redis-benchmark redis-cli redis-check-dump redis-check-aof redis-server
c8061392
PN
82 @echo ""
83 @echo "Hint: To run 'make test' is a good idea ;)"
84 @echo ""
ed9b544e 85
86# Deps (use make dep to generate this)
9e9c0ce1 87adlist.o: adlist.c adlist.h zmalloc.h
970e10bb 88ae.o: ae.c ae.h zmalloc.h config.h ae_kqueue.c
89ae_epoll.o: ae_epoll.c
90ae_kqueue.o: ae_kqueue.c
266373b2 91ae_select.o: ae_select.c
9e9c0ce1 92anet.o: anet.c fmacros.h anet.h
8fedd04d 93aof.o: aof.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
b147cb9e 94 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h util.h
95bio.o: bio.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
96 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h util.h bio.h
3e2a0bf4 97cluster.o: cluster.c redis.h fmacros.h config.h ae.h sds.h dict.h \
b147cb9e 98 adlist.h zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h util.h
8fedd04d 99config.o: config.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
b147cb9e 100 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h util.h
3e2a0bf4 101crc16.o: crc16.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
b147cb9e 102 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h util.h
8fedd04d 103db.o: db.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
b147cb9e 104 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h util.h
8fedd04d 105debug.o: debug.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 sha1.h
daa70b17 107dict.o: dict.c fmacros.h dict.h zmalloc.h
3e2a0bf4 108endian.o: endian.c
109intset.o: intset.c intset.h zmalloc.h endian.h
9e9c0ce1 110lzf_c.o: lzf_c.c lzfP.h
111lzf_d.o: lzf_d.c lzfP.h
8fedd04d 112multi.o: multi.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 114networking.o: networking.c redis.h fmacros.h config.h ae.h sds.h dict.h \
b147cb9e 115 adlist.h zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h util.h
8fedd04d 116object.o: object.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
9e9c0ce1 118pqsort.o: pqsort.c
8fedd04d 119pubsub.o: pubsub.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
b147cb9e 120 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h util.h
8fedd04d 121rdb.o: rdb.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
b147cb9e 122 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h util.h lzf.h
33388d43 123redis-benchmark.o: redis-benchmark.c fmacros.h ae.h \
124 ../deps/hiredis/hiredis.h sds.h adlist.h zmalloc.h
7a121e60 125redis-check-aof.o: redis-check-aof.c fmacros.h config.h
cf87ebf2 126redis-check-dump.o: redis-check-dump.c lzf.h
33388d43 127redis-cli.o: redis-cli.c fmacros.h version.h ../deps/hiredis/hiredis.h \
128 sds.h zmalloc.h ../deps/linenoise/linenoise.h help.h
8fedd04d 129redis.o: redis.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
daa70b17 130 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h util.h slowlog.h \
b147cb9e 131 bio.h asciilogo.h
7c4fc71c 132release.o: release.c release.h
8fedd04d 133replication.o: replication.c redis.h fmacros.h config.h ae.h sds.h dict.h \
b147cb9e 134 adlist.h zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h util.h
135scripting.o: scripting.c redis.h fmacros.h config.h ae.h sds.h dict.h \
daa70b17 136 adlist.h zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h util.h \
e108bab0 137 sha1.h rand.h
2e4b0e77 138rio.o: rio.c sds.h
9e9c0ce1 139sds.o: sds.c sds.h zmalloc.h
3e2a0bf4 140sha1.o: sha1.c sha1.h config.h
daa70b17 141slowlog.o: slowlog.c redis.h fmacros.h config.h ae.h sds.h dict.h \
142 adlist.h zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h util.h \
143 slowlog.h
8fedd04d 144sort.o: sort.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
b147cb9e 145 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h util.h pqsort.h
33388d43 146syncio.o: syncio.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
b147cb9e 147 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h util.h
8fedd04d 148t_hash.o: t_hash.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
b147cb9e 149 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h util.h
8fedd04d 150t_list.o: t_list.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
b147cb9e 151 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h util.h
8fedd04d 152t_set.o: t_set.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
b147cb9e 153 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h util.h
8fedd04d 154t_string.o: t_string.c redis.h fmacros.h config.h ae.h sds.h dict.h \
b147cb9e 155 adlist.h zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h util.h
8fedd04d 156t_zset.o: t_zset.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
b147cb9e 157 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h util.h
3e2a0bf4 158util.o: util.c fmacros.h util.h
159ziplist.o: ziplist.c zmalloc.h util.h ziplist.h endian.h
160zipmap.o: zipmap.c zmalloc.h endian.h
161zmalloc.o: zmalloc.c config.h zmalloc.h
ed9b544e 162
9e62dc17 163.PHONY: dependencies
ed9b544e 164
c8061392 165dependencies:
db6cea11 166 @printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)hiredis$(ENDCOLOR)
35845afb 167 @cd ../deps/hiredis && $(MAKE) static ARCH="$(ARCH)"
db6cea11 168 @printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)linenoise$(ENDCOLOR)
35845afb 169 @cd ../deps/linenoise && $(MAKE) ARCH="$(ARCH)"
21d3294c 170 @echo $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)Lua ansi$(ENDCOLOR)
b28d0461 171 @cd ../deps/lua && $(MAKE) CFLAGS="$(LUA_CFLAGS)" MYLDFLAGS="$(ARCH)" ansi
c8061392 172
9e62dc17 173../deps/jemalloc/lib/libjemalloc.a:
e93d36a6 174 cd ../deps/jemalloc && ./configure $(JEMALLOC_CFLAGS) --with-jemalloc-prefix=je_ --enable-cc-silence && $(MAKE) lib/libjemalloc.a
9e62dc17 175
4d6bf65c 176redis-server: dependencies $(OBJ)
321a0440 177 $(QUIET_LINK)$(CC) -o $(PRGNAME) $(CCOPT) $(DEBUG) $(OBJ) ../deps/lua/src/liblua.a $(CCLINK)
ed9b544e 178
c8061392 179redis-benchmark: dependencies $(BENCHOBJ)
35845afb 180 @cd ../deps/hiredis && $(MAKE) static
61c0e893 181 $(QUIET_LINK)$(CC) -o $(BENCHPRGNAME) $(CCOPT) $(DEBUG) $(BENCHOBJ) ../deps/hiredis/libhiredis.a $(CCLINK)
ec8f0667
PN
182
183redis-benchmark.o:
73e71867 184 $(QUIET_CC)$(CC) -c $(CFLAGS) -I../deps/hiredis $(DEBUG) $(COMPILE_TIME) $<
ed9b544e 185
c8061392 186redis-cli: dependencies $(CLIOBJ)
61c0e893 187 $(QUIET_LINK)$(CC) -o $(CLIPRGNAME) $(CCOPT) $(DEBUG) $(CLIOBJ) ../deps/hiredis/libhiredis.a ../deps/linenoise/linenoise.o $(CCLINK)
7fc4ce13
PN
188
189redis-cli.o:
73e71867 190 $(QUIET_CC)$(CC) -c $(CFLAGS) -I../deps/hiredis -I../deps/linenoise $(DEBUG) $(COMPILE_TIME) $<
ed9b544e 191
08af4d5c 192redis-check-dump: $(CHECKDUMPOBJ)
61c0e893 193 $(QUIET_LINK)$(CC) -o $(CHECKDUMPPRGNAME) $(CCOPT) $(DEBUG) $(CHECKDUMPOBJ) $(CCLINK)
08af4d5c 194
b4bd0524 195redis-check-aof: $(CHECKAOFOBJ)
61c0e893 196 $(QUIET_LINK)$(CC) -o $(CHECKAOFPRGNAME) $(CCOPT) $(DEBUG) $(CHECKAOFOBJ) $(CCLINK)
b4bd0524 197
9e62dc17 198# Because the jemalloc.h header is generated as a part of the jemalloc build
199# process, building it should complete before building any other object.
200%.o: %.c $(ALLOC_DEP)
0d1650f8 201 $(QUIET_CC)$(CC) -c $(CFLAGS) $(DEBUG) $(COMPILE_TIME) -I../deps/lua/src $<
ed9b544e 202
203clean:
b4bd0524 204 rm -rf $(PRGNAME) $(BENCHPRGNAME) $(CLIPRGNAME) $(CHECKDUMPPRGNAME) $(CHECKAOFPRGNAME) *.o *.gcda *.gcno *.gcov
319bb48c 205 cd ../deps/hiredis && $(MAKE) $@
206 cd ../deps/linenoise && $(MAKE) $@
207 cd ../deps/lua && $(MAKE) $@
208 -(cd ../deps/jemalloc && $(MAKE) distclean)
ed9b544e 209
210dep:
33388d43 211 $(CC) -MM *.c -I ../deps/hiredis -I ../deps/linenoise
ed9b544e 212
e6fcb5b3 213test: redis-server redis-check-aof
f790bd02 214 @(cd ..; ./runtest)
ed9b544e 215
216bench:
217 ./redis-benchmark
378fd421 218
219log:
24110a4d 220 git log '--pretty=format:%ad %s (%cn)' --date=short > ../Changelog
fd8ccf44 221
22232bit:
9ebed7cf 223 @echo ""
224 @echo "WARNING: if it fails under Linux you probably need to install libc6-dev-i386"
225 @echo ""
e93d36a6 226 $(MAKE) ARCH="-m32" JEMALLOC_CFLAGS='CFLAGS="-std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -m32"'
d0ccebcf 227
228gprof:
a4e48b41 229 $(MAKE) PROF="-pg"
d0ccebcf 230
fc77604c 231gcov:
a4e48b41 232 $(MAKE) PROF="-fprofile-arcs -ftest-coverage"
fc77604c 233
25fd2cb2 234noopt:
a4e48b41 235 $(MAKE) OPTIMIZATION=""
25fd2cb2 236
d0ccebcf 23732bitgprof:
a4e48b41 238 $(MAKE) PROF="-pg" ARCH="-arch i386"
acc01854 239
319bb48c 240src/help.h:
241 @../utils/generate-command-help.rb > help.h
242
acc01854 243install: all
0bb5160c 244 mkdir -p $(INSTALL_BIN)
245 $(INSTALL) $(PRGNAME) $(INSTALL_BIN)
246 $(INSTALL) $(BENCHPRGNAME) $(INSTALL_BIN)
247 $(INSTALL) $(CLIPRGNAME) $(INSTALL_BIN)
248 $(INSTALL) $(CHECKDUMPPRGNAME) $(INSTALL_BIN)
249 $(INSTALL) $(CHECKAOFPRGNAME) $(INSTALL_BIN)