Makefile 7.7 KB
Newer Older
A
antirez 已提交
1 2 3 4
# Redis Makefile
# Copyright (C) 2009 Salvatore Sanfilippo <antirez at gmail dot com>
# This file is released under the BSD license, see the COPYING file

5
release_hdr := $(shell sh -c './mkreleasehdr.sh')
6
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
7
OPTIMIZATION?=-O2
A
antirez 已提交
8 9 10 11 12 13 14 15 16 17 18 19 20

CCCOLOR="\033[34m"
LINKCOLOR="\033[34;1m"
SRCCOLOR="\033[33m"
BINCOLOR="\033[37;1m"
MAKECOLOR="\033[32;1m"
ENDCOLOR="\033[0m"

ifndef V
QUIET_CC = @printf '    %b %b\n' $(CCCOLOR)CC$(ENDCOLOR) $(SRCCOLOR)$@$(ENDCOLOR);
QUIET_LINK = @printf '    %b %b\n' $(LINKCOLOR)LINK$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR);
endif

21
ifeq ($(uname_S),SunOS)
22
  CFLAGS?= -std=c99 -pedantic $(OPTIMIZATION) -Wall -W -D__EXTENSIONS__ -D_XPG6
23
  CCLINK?= -ldl -lnsl -lsocket -lm -lpthread
24
  DEBUG?= -g -ggdb 
25
else
26
  CFLAGS?= -std=c99 -pedantic $(OPTIMIZATION) -Wall -W $(ARCH) $(PROF)
27
  CCLINK?= -lm -pthread
28
  DEBUG?= -g -rdynamic -ggdb 
29
endif
A
antirez 已提交
30 31 32

ifeq ($(USE_TCMALLOC),yes)
  CCLINK+= -ltcmalloc
A
antirez 已提交
33
  CFLAGS+= -DUSE_TCMALLOC
A
antirez 已提交
34
endif
35
CCOPT= $(CFLAGS) $(ARCH) $(PROF)
A
antirez 已提交
36

37
PREFIX= /usr/local
P
Pedro Melo 已提交
38
INSTALL_BIN= $(PREFIX)/bin
A
antirez 已提交
39 40
INSTALL= cp -p

A
antirez 已提交
41
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 vm.o pubsub.o multi.o debug.o sort.o intset.o syncio.o slowlog.o
42
BENCHOBJ = ae.o anet.o redis-benchmark.o sds.o adlist.o zmalloc.o
43
CLIOBJ = anet.o sds.o adlist.o redis-cli.o zmalloc.o release.o
44
CHECKDUMPOBJ = redis-check-dump.o lzf_c.o lzf_d.o
P
Pieter Noordhuis 已提交
45
CHECKAOFOBJ = redis-check-aof.o
A
antirez 已提交
46 47 48 49

PRGNAME = redis-server
BENCHPRGNAME = redis-benchmark
CLIPRGNAME = redis-cli
50
CHECKDUMPPRGNAME = redis-check-dump
P
Pieter Noordhuis 已提交
51
CHECKAOFPRGNAME = redis-check-aof
A
antirez 已提交
52

53
all: redis-benchmark redis-cli redis-check-dump redis-check-aof redis-server
P
Pieter Noordhuis 已提交
54 55 56
	@echo ""
	@echo "Hint: To run 'make test' is a good idea ;)"
	@echo ""
A
antirez 已提交
57 58

# Deps (use make dep to generate this)
A
antirez 已提交
59
adlist.o: adlist.c adlist.h zmalloc.h
60 61 62
ae.o: ae.c ae.h zmalloc.h config.h ae_kqueue.c
ae_epoll.o: ae_epoll.c
ae_kqueue.o: ae_kqueue.c
63
ae_select.o: ae_select.c
A
antirez 已提交
64
anet.o: anet.c fmacros.h anet.h
A
antirez 已提交
65 66 67 68 69 70 71 72
aof.o: aof.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
  zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
config.o: config.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
  zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
db.o: db.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
  zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
debug.o: debug.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
  zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h sha1.h
A
antirez 已提交
73
dict.o: dict.c fmacros.h dict.h zmalloc.h
A
antirez 已提交
74
intset.o: intset.c intset.h zmalloc.h
A
antirez 已提交
75 76
lzf_c.o: lzf_c.c lzfP.h
lzf_d.o: lzf_d.c lzfP.h
A
antirez 已提交
77 78 79 80 81 82
multi.o: multi.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
  zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
networking.o: networking.c redis.h fmacros.h config.h ae.h sds.h dict.h \
  adlist.h zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
object.o: object.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
  zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
A
antirez 已提交
83
pqsort.o: pqsort.c
A
antirez 已提交
84 85 86 87
pubsub.o: pubsub.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
  zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
rdb.o: rdb.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
  zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h lzf.h
A
antirez 已提交
88 89
redis-benchmark.o: redis-benchmark.c fmacros.h ae.h \
  ../deps/hiredis/hiredis.h sds.h adlist.h zmalloc.h
A
antirez 已提交
90
redis-check-aof.o: redis-check-aof.c fmacros.h config.h
91
redis-check-dump.o: redis-check-dump.c lzf.h
A
antirez 已提交
92 93
redis-cli.o: redis-cli.c fmacros.h version.h ../deps/hiredis/hiredis.h \
  sds.h zmalloc.h ../deps/linenoise/linenoise.h help.h
A
antirez 已提交
94
redis.o: redis.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
A
antirez 已提交
95
  zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h slowlog.h
96
release.o: release.c release.h
A
antirez 已提交
97 98
replication.o: replication.c redis.h fmacros.h config.h ae.h sds.h dict.h \
  adlist.h zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
A
antirez 已提交
99
sds.o: sds.c sds.h zmalloc.h
100
sha1.o: sha1.c sha1.h
A
antirez 已提交
101 102 103
slowlog.o: slowlog.c redis.h fmacros.h config.h ae.h sds.h dict.h \
  adlist.h zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h \
  slowlog.h
A
antirez 已提交
104 105
sort.o: sort.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
  zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h pqsort.h
A
antirez 已提交
106 107
syncio.o: syncio.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
  zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
A
antirez 已提交
108 109 110 111 112 113 114 115 116 117 118 119 120 121
t_hash.o: t_hash.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
  zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
t_list.o: t_list.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
  zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
t_set.o: t_set.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
  zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
t_string.o: t_string.c redis.h fmacros.h config.h ae.h sds.h dict.h \
  adlist.h zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
t_zset.o: t_zset.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
  zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
util.o: util.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
  zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
vm.o: vm.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
  zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
122
ziplist.o: ziplist.c zmalloc.h ziplist.h
123
zipmap.o: zipmap.c zmalloc.h
A
antirez 已提交
124
zmalloc.o: zmalloc.c config.h zmalloc.h
A
antirez 已提交
125

P
Pieter Noordhuis 已提交
126
dependencies:
A
antirez 已提交
127
	@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)hiredis$(ENDCOLOR)
P
Pieter Noordhuis 已提交
128
	cd ../deps/hiredis && $(MAKE) static ARCH="$(ARCH)"
A
antirez 已提交
129
	@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)linenoise$(ENDCOLOR)
P
Pieter Noordhuis 已提交
130 131
	cd ../deps/linenoise && $(MAKE) ARCH="$(ARCH)"

132
redis-server: $(OBJ)
133
	$(QUIET_LINK)$(CC) -o $(PRGNAME) $(CCOPT) $(DEBUG) $(OBJ) $(CCLINK)
A
antirez 已提交
134

P
Pieter Noordhuis 已提交
135
redis-benchmark: dependencies $(BENCHOBJ)
A
antirez 已提交
136 137
	@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)hiredis$(ENDCOLOR)
	cd ../deps/hiredis && $(MAKE) static ARCH="$(ARCH)"
138
	$(QUIET_LINK)$(CC) -o $(BENCHPRGNAME) $(CCOPT) $(DEBUG) $(BENCHOBJ) ../deps/hiredis/libhiredis.a $(CCLINK)
139 140

redis-benchmark.o:
A
antirez 已提交
141
	$(QUIET_CC)$(CC) -c $(CFLAGS) -I../deps/hiredis $(DEBUG) $(COMPILE_TIME) $<
A
antirez 已提交
142

P
Pieter Noordhuis 已提交
143
redis-cli: dependencies $(CLIOBJ)
144
	$(QUIET_LINK)$(CC) -o $(CLIPRGNAME) $(CCOPT) $(DEBUG) $(CLIOBJ) ../deps/hiredis/libhiredis.a ../deps/linenoise/linenoise.o $(CCLINK)
P
Pieter Noordhuis 已提交
145 146

redis-cli.o:
A
antirez 已提交
147
	$(QUIET_CC)$(CC) -c $(CFLAGS) -I../deps/hiredis -I../deps/linenoise $(DEBUG) $(COMPILE_TIME) $<
A
antirez 已提交
148

149
redis-check-dump: $(CHECKDUMPOBJ)
150
	$(QUIET_LINK)$(CC) -o $(CHECKDUMPPRGNAME) $(CCOPT) $(DEBUG) $(CHECKDUMPOBJ) $(CCLINK)
151

P
Pieter Noordhuis 已提交
152
redis-check-aof: $(CHECKAOFOBJ)
153
	$(QUIET_LINK)$(CC) -o $(CHECKAOFPRGNAME) $(CCOPT) $(DEBUG) $(CHECKAOFOBJ) $(CCLINK)
P
Pieter Noordhuis 已提交
154

A
antirez 已提交
155
.c.o:
A
antirez 已提交
156
	$(QUIET_CC)$(CC) -c $(CFLAGS) $(DEBUG) $(COMPILE_TIME) $<
A
antirez 已提交
157 158

clean:
P
Pieter Noordhuis 已提交
159
	rm -rf $(PRGNAME) $(BENCHPRGNAME) $(CLIPRGNAME) $(CHECKDUMPPRGNAME) $(CHECKAOFPRGNAME) *.o *.gcda *.gcno *.gcov
A
antirez 已提交
160 161

dep:
A
antirez 已提交
162
	$(CC) -MM *.c -I ../deps/hiredis -I ../deps/linenoise
A
antirez 已提交
163

P
Pieter Noordhuis 已提交
164
test: redis-server
165
	(cd ..; tclsh8.5 tests/test_helper.tcl --tags "${TAGS}" --file "${FILE}")
A
antirez 已提交
166 167 168

bench:
	./redis-benchmark
A
antirez 已提交
169 170

log:
A
antirez 已提交
171
	git log '--pretty=format:%ad %s (%cn)' --date=short > ../Changelog
172 173

32bit:
174 175 176
	@echo ""
	@echo "WARNING: if it fails under Linux you probably need to install libc6-dev-i386"
	@echo ""
P
Pieter Noordhuis 已提交
177
	$(MAKE) ARCH="-m32"
178 179

gprof:
P
Pieter Noordhuis 已提交
180
	$(MAKE) PROF="-pg"
181

182
gcov:
P
Pieter Noordhuis 已提交
183
	$(MAKE) PROF="-fprofile-arcs -ftest-coverage"
184

185
noopt:
P
Pieter Noordhuis 已提交
186
	$(MAKE) OPTIMIZATION=""
187

188
32bitgprof:
P
Pieter Noordhuis 已提交
189
	$(MAKE) PROF="-pg" ARCH="-arch i386"
A
antirez 已提交
190 191

install: all
192
	mkdir -p $(INSTALL_BIN)
A
antirez 已提交
193 194 195 196 197
	$(INSTALL) $(PRGNAME) $(INSTALL_BIN)
	$(INSTALL) $(BENCHPRGNAME) $(INSTALL_BIN)
	$(INSTALL) $(CLIPRGNAME) $(INSTALL_BIN)
	$(INSTALL) $(CHECKDUMPPRGNAME) $(INSTALL_BIN)
	$(INSTALL) $(CHECKAOFPRGNAME) $(INSTALL_BIN)