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