]> git.saurik.com Git - redis.git/blame - src/Makefile
Added -ldl when linking against jemalloc, needed on Linux
[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
ecc91094 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 dscache.o pubsub.o multi.o debug.o sort.o intset.o syncio.o diskstore.o cluster.o crc16.o endian.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 \
89 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
90config.o: config.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
92db.o: db.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
93 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
94debug.o: debug.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 sha1.h
9e9c0ce1 96dict.o: dict.c fmacros.h dict.h zmalloc.h
33388d43 97diskstore.o: diskstore.c redis.h fmacros.h config.h ae.h sds.h dict.h \
98 adlist.h zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
99dscache.o: dscache.c redis.h fmacros.h config.h ae.h sds.h dict.h \
100 adlist.h zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
8fedd04d 101intset.o: intset.c intset.h zmalloc.h
9e9c0ce1 102lzf_c.o: lzf_c.c lzfP.h
103lzf_d.o: lzf_d.c lzfP.h
8fedd04d 104multi.o: multi.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
105 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
106networking.o: networking.c redis.h fmacros.h config.h ae.h sds.h dict.h \
107 adlist.h zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
108object.o: object.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
109 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
9e9c0ce1 110pqsort.o: pqsort.c
8fedd04d 111pubsub.o: pubsub.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
112 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
113rdb.o: rdb.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
114 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h lzf.h
33388d43 115redis-benchmark.o: redis-benchmark.c fmacros.h ae.h \
116 ../deps/hiredis/hiredis.h sds.h adlist.h zmalloc.h
7a121e60 117redis-check-aof.o: redis-check-aof.c fmacros.h config.h
cf87ebf2 118redis-check-dump.o: redis-check-dump.c lzf.h
33388d43 119redis-cli.o: redis-cli.c fmacros.h version.h ../deps/hiredis/hiredis.h \
120 sds.h zmalloc.h ../deps/linenoise/linenoise.h help.h
8fedd04d 121redis.o: redis.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
996d503d 122 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h asciilogo.h
7c4fc71c 123release.o: release.c release.h
8fedd04d 124replication.o: replication.c redis.h fmacros.h config.h ae.h sds.h dict.h \
125 adlist.h zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
9e9c0ce1 126sds.o: sds.c sds.h zmalloc.h
7c4fc71c 127sha1.o: sha1.c sha1.h
8fedd04d 128sort.o: sort.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
129 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h pqsort.h
33388d43 130syncio.o: syncio.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
131 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
8fedd04d 132t_hash.o: t_hash.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
133 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
134t_list.o: t_list.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
135 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
136t_set.o: t_set.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
137 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
138t_string.o: t_string.c redis.h fmacros.h config.h ae.h sds.h dict.h \
139 adlist.h zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
140t_zset.o: t_zset.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
141 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
5d081931 142util.o: util.c util.h
ecc91094 143cluster.o: redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
8fedd04d 144 zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
7c4fc71c 145ziplist.o: ziplist.c zmalloc.h ziplist.h
5234952b 146zipmap.o: zipmap.c zmalloc.h
9e9c0ce1 147zmalloc.o: zmalloc.c config.h
ed9b544e 148
9e62dc17 149.PHONY: dependencies
150
c8061392 151dependencies:
db6cea11 152 @printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)hiredis$(ENDCOLOR)
35845afb 153 @cd ../deps/hiredis && $(MAKE) static ARCH="$(ARCH)"
db6cea11 154 @printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)linenoise$(ENDCOLOR)
35845afb 155 @cd ../deps/linenoise && $(MAKE) ARCH="$(ARCH)"
c8061392 156
9e62dc17 157../deps/jemalloc/lib/libjemalloc.a:
158 cd ../deps/jemalloc && ./configure --with-jemalloc-prefix=je_ --enable-cc-silence && $(MAKE) lib/libjemalloc.a
159
73287b2b 160redis-server: $(OBJ)
9e62dc17 161 $(QUIET_CC)$(CC) -o $(PRGNAME) $(CCOPT) $(DEBUG) $(OBJ) $(CCLINK) $(ALLOC_LINK)
ed9b544e 162
c8061392 163redis-benchmark: dependencies $(BENCHOBJ)
35845afb 164 @cd ../deps/hiredis && $(MAKE) static
9e62dc17 165 $(QUIET_LINK)$(CC) -o $(BENCHPRGNAME) $(CCOPT) $(DEBUG) $(BENCHOBJ) ../deps/hiredis/libhiredis.a $(CCLINK) $(ALLOC_LINK)
ec8f0667
PN
166
167redis-benchmark.o:
73e71867 168 $(QUIET_CC)$(CC) -c $(CFLAGS) -I../deps/hiredis $(DEBUG) $(COMPILE_TIME) $<
ed9b544e 169
c8061392 170redis-cli: dependencies $(CLIOBJ)
9e62dc17 171 $(QUIET_LINK)$(CC) -o $(CLIPRGNAME) $(CCOPT) $(DEBUG) $(CLIOBJ) ../deps/hiredis/libhiredis.a ../deps/linenoise/linenoise.o $(CCLINK) $(ALLOC_LINK)
7fc4ce13
PN
172
173redis-cli.o:
73e71867 174 $(QUIET_CC)$(CC) -c $(CFLAGS) -I../deps/hiredis -I../deps/linenoise $(DEBUG) $(COMPILE_TIME) $<
ed9b544e 175
08af4d5c 176redis-check-dump: $(CHECKDUMPOBJ)
9e62dc17 177 $(QUIET_LINK)$(CC) -o $(CHECKDUMPPRGNAME) $(CCOPT) $(DEBUG) $(CHECKDUMPOBJ) $(CCLINK) $(ALLOC_LINK)
08af4d5c 178
b4bd0524 179redis-check-aof: $(CHECKAOFOBJ)
9e62dc17 180 $(QUIET_LINK)$(CC) -o $(CHECKAOFPRGNAME) $(CCOPT) $(DEBUG) $(CHECKAOFOBJ) $(CCLINK) $(ALLOC_LINK)
b4bd0524 181
9e62dc17 182# Because the jemalloc.h header is generated as a part of the jemalloc build
183# process, building it should complete before building any other object.
184%.o: %.c $(ALLOC_DEP)
73e71867 185 $(QUIET_CC)$(CC) -c $(CFLAGS) $(DEBUG) $(COMPILE_TIME) $<
ed9b544e 186
187clean:
b4bd0524 188 rm -rf $(PRGNAME) $(BENCHPRGNAME) $(CLIPRGNAME) $(CHECKDUMPPRGNAME) $(CHECKAOFPRGNAME) *.o *.gcda *.gcno *.gcov
ed9b544e 189
190dep:
33388d43 191 $(CC) -MM *.c -I ../deps/hiredis -I ../deps/linenoise
ed9b544e 192
c8061392 193test: redis-server
9f1ae9ab 194 (cd ..; tclsh8.5 tests/test_helper.tcl --tags "${TAGS}" --file "${FILE}")
ed9b544e 195
196bench:
197 ./redis-benchmark
378fd421 198
199log:
24110a4d 200 git log '--pretty=format:%ad %s (%cn)' --date=short > ../Changelog
fd8ccf44 201
20232bit:
9ebed7cf 203 @echo ""
204 @echo "WARNING: if it fails under Linux you probably need to install libc6-dev-i386"
205 @echo ""
a4e48b41 206 $(MAKE) ARCH="-m32"
d0ccebcf 207
208gprof:
a4e48b41 209 $(MAKE) PROF="-pg"
d0ccebcf 210
fc77604c 211gcov:
a4e48b41 212 $(MAKE) PROF="-fprofile-arcs -ftest-coverage"
fc77604c 213
25fd2cb2 214noopt:
a4e48b41 215 $(MAKE) OPTIMIZATION=""
25fd2cb2 216
d0ccebcf 21732bitgprof:
a4e48b41 218 $(MAKE) PROF="-pg" ARCH="-arch i386"
acc01854 219
220install: all
e984050f 221 mkdir -p $(INSTALL_BIN)
acc01854 222 $(INSTALL) $(PRGNAME) $(INSTALL_BIN)
223 $(INSTALL) $(BENCHPRGNAME) $(INSTALL_BIN)
224 $(INSTALL) $(CLIPRGNAME) $(INSTALL_BIN)
225 $(INSTALL) $(CHECKDUMPPRGNAME) $(INSTALL_BIN)
226 $(INSTALL) $(CHECKAOFPRGNAME) $(INSTALL_BIN)