Makefile 7.8 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
8
ifeq ($(uname_S),SunOS)
9
  CFLAGS?= -std=c99 -pedantic $(OPTIMIZATION) -Wall -W -D__EXTENSIONS__ -D_XPG6
10
  CCLINK?= -ldl -lnsl -lsocket -lm -lpthread
11
  DEBUG?= -g -ggdb 
12
else
13
  CFLAGS?= -std=c99 -pedantic $(OPTIMIZATION) -Wall -W $(ARCH) $(PROF)
14
  CCLINK?= -lm -pthread
15
  DEBUG?= -g -rdynamic -ggdb 
16
endif
A
antirez 已提交
17 18

ifeq ($(USE_TCMALLOC),yes)
P
Pieter Noordhuis 已提交
19 20
  ALLOC_LINK=-ltcmalloc
  ALLOC_FLAGS=-DUSE_TCMALLOC
A
antirez 已提交
21
endif
P
Pieter Noordhuis 已提交
22 23 24 25 26 27 28 29 30 31 32 33 34 35

ifeq ($(USE_TCMALLOC_MINIMAL),yes)
  ALLOC_LINK=-ltcmalloc_minimal
  ALLOC_FLAGS=-DUSE_TCMALLOC
endif

ifeq ($(USE_JEMALLOC),yes)
  ALLOC_LINK=-ljemalloc
  ALLOC_FLAGS=-DUSE_JEMALLOC
endif

CCLINK+= $(ALLOC_LINK)
CFLAGS+= $(ALLOC_FLAGS)

36
CCOPT= $(CFLAGS) $(CCLINK) $(ARCH) $(PROF)
A
antirez 已提交
37

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

A
antirez 已提交
42 43 44 45 46 47 48
CCCOLOR="\033[34m"
LINKCOLOR="\033[34;1m"
SRCCOLOR="\033[33m"
BINCOLOR="\033[37;1m"
MAKECOLOR="\033[32;1m"
ENDCOLOR="\033[0m"

49 50 51 52 53
ifndef V
QUIET_CC = @echo '    ' $(CCCOLOR)CC$(ENDCOLOR) $(SRCCOLOR)$@$(ENDCOLOR);
QUIET_LINK = @echo '    ' $(LINKCOLOR)LINK$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR);
endif

A
antirez 已提交
54
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 dscache.o pubsub.o multi.o debug.o sort.o intset.o syncio.o diskstore.o cluster.o crc16.o endian.o
55
BENCHOBJ = ae.o anet.o redis-benchmark.o sds.o adlist.o zmalloc.o
56
CLIOBJ = anet.o sds.o adlist.o redis-cli.o zmalloc.o release.o
57
CHECKDUMPOBJ = redis-check-dump.o lzf_c.o lzf_d.o
P
Pieter Noordhuis 已提交
58
CHECKAOFOBJ = redis-check-aof.o
A
antirez 已提交
59 60 61 62

PRGNAME = redis-server
BENCHPRGNAME = redis-benchmark
CLIPRGNAME = redis-cli
63
CHECKDUMPPRGNAME = redis-check-dump
P
Pieter Noordhuis 已提交
64
CHECKAOFPRGNAME = redis-check-aof
A
antirez 已提交
65

66
all: redis-benchmark redis-cli redis-check-dump redis-check-aof redis-server
P
Pieter Noordhuis 已提交
67 68 69
	@echo ""
	@echo "Hint: To run 'make test' is a good idea ;)"
	@echo ""
A
antirez 已提交
70 71

# Deps (use make dep to generate this)
A
antirez 已提交
72
adlist.o: adlist.c adlist.h zmalloc.h
73 74 75
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
76
ae_select.o: ae_select.c
A
antirez 已提交
77
anet.o: anet.c fmacros.h anet.h
A
antirez 已提交
78 79 80 81 82 83 84 85
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 已提交
86
dict.o: dict.c fmacros.h dict.h zmalloc.h
87 88 89 90
diskstore.o: diskstore.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
dscache.o: dscache.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 已提交
91
intset.o: intset.c intset.h zmalloc.h
A
antirez 已提交
92 93
lzf_c.o: lzf_c.c lzfP.h
lzf_d.o: lzf_d.c lzfP.h
A
antirez 已提交
94 95 96 97 98 99
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 已提交
100
pqsort.o: pqsort.c
A
antirez 已提交
101 102 103 104
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
105 106
redis-benchmark.o: redis-benchmark.c fmacros.h ae.h \
  ../deps/hiredis/hiredis.h sds.h adlist.h zmalloc.h
A
antirez 已提交
107
redis-check-aof.o: redis-check-aof.c fmacros.h config.h
108
redis-check-dump.o: redis-check-dump.c lzf.h
109 110
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 已提交
111
redis.o: redis.c redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
A
antirez 已提交
112
  zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h asciilogo.h
113
release.o: release.c release.h
A
antirez 已提交
114 115
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 已提交
116
sds.o: sds.c sds.h zmalloc.h
117
sha1.o: sha1.c sha1.h
A
antirez 已提交
118 119
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
120 121
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 已提交
122 123 124 125 126 127 128 129 130 131
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
132
util.o: util.c util.h
A
antirez 已提交
133
cluster.o: redis.h fmacros.h config.h ae.h sds.h dict.h adlist.h \
A
antirez 已提交
134
  zmalloc.h anet.h zipmap.h ziplist.h intset.h version.h
135
ziplist.o: ziplist.c zmalloc.h ziplist.h
136
zipmap.o: zipmap.c zmalloc.h
A
antirez 已提交
137
zmalloc.o: zmalloc.c config.h
A
antirez 已提交
138

P
Pieter Noordhuis 已提交
139
dependencies:
A
antirez 已提交
140 141 142 143
	@echo $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)hiredis$(ENDCOLOR)
	@cd ../deps/hiredis && $(MAKE) static ARCH="$(ARCH)"
	@echo $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)linenoise$(ENDCOLOR)
	@cd ../deps/linenoise && $(MAKE) ARCH="$(ARCH)"
P
Pieter Noordhuis 已提交
144

145
redis-server: $(OBJ)
146
	$(QUIET_CC)$(CC) -o $(PRGNAME) $(CCOPT) $(DEBUG) $(OBJ)
A
antirez 已提交
147

P
Pieter Noordhuis 已提交
148
redis-benchmark: dependencies $(BENCHOBJ)
A
antirez 已提交
149
	@cd ../deps/hiredis && $(MAKE) static
150
	$(QUIET_LINK)$(CC) -o $(BENCHPRGNAME) $(CCOPT) $(DEBUG) $(BENCHOBJ) ../deps/hiredis/libhiredis.a
151 152

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

P
Pieter Noordhuis 已提交
155
redis-cli: dependencies $(CLIOBJ)
156
	$(QUIET_LINK)$(CC) -o $(CLIPRGNAME) $(CCOPT) $(DEBUG) $(CLIOBJ) ../deps/hiredis/libhiredis.a ../deps/linenoise/linenoise.o
P
Pieter Noordhuis 已提交
157 158

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

161
redis-check-dump: $(CHECKDUMPOBJ)
162
	$(QUIET_LINK)$(CC) -o $(CHECKDUMPPRGNAME) $(CCOPT) $(DEBUG) $(CHECKDUMPOBJ)
163

P
Pieter Noordhuis 已提交
164
redis-check-aof: $(CHECKAOFOBJ)
165
	$(QUIET_LINK)$(CC) -o $(CHECKAOFPRGNAME) $(CCOPT) $(DEBUG) $(CHECKAOFOBJ)
P
Pieter Noordhuis 已提交
166

A
antirez 已提交
167
.c.o:
168
	$(QUIET_CC)$(CC) -c $(CFLAGS) $(DEBUG) $(COMPILE_TIME) $<
A
antirez 已提交
169 170

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

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

P
Pieter Noordhuis 已提交
176
test: redis-server
177
	(cd ..; tclsh8.5 tests/test_helper.tcl --tags "${TAGS}" --file "${FILE}")
A
antirez 已提交
178 179 180

bench:
	./redis-benchmark
A
antirez 已提交
181 182

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

32bit:
186 187 188
	@echo ""
	@echo "WARNING: if it fails under Linux you probably need to install libc6-dev-i386"
	@echo ""
P
Pieter Noordhuis 已提交
189
	$(MAKE) ARCH="-m32"
190 191

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

194
gcov:
P
Pieter Noordhuis 已提交
195
	$(MAKE) PROF="-fprofile-arcs -ftest-coverage"
196

197
noopt:
P
Pieter Noordhuis 已提交
198
	$(MAKE) OPTIMIZATION=""
199

200
32bitgprof:
P
Pieter Noordhuis 已提交
201
	$(MAKE) PROF="-pg" ARCH="-arch i386"
A
antirez 已提交
202 203

install: all
204
	mkdir -p $(INSTALL_BIN)
A
antirez 已提交
205 206 207 208 209
	$(INSTALL) $(PRGNAME) $(INSTALL_BIN)
	$(INSTALL) $(BENCHPRGNAME) $(INSTALL_BIN)
	$(INSTALL) $(CLIPRGNAME) $(INSTALL_BIN)
	$(INSTALL) $(CHECKDUMPPRGNAME) $(INSTALL_BIN)
	$(INSTALL) $(CHECKAOFPRGNAME) $(INSTALL_BIN)