Makefile 6.3 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
else
12
  CFLAGS?= -std=c99 -pedantic $(OPTIMIZATION) -Wall -W $(ARCH) $(PROF)
13
  CCLINK?= -lm -pthread
14
endif
A
antirez 已提交
15 16 17

ifeq ($(USE_TCMALLOC),yes)
  CCLINK+= -ltcmalloc
A
antirez 已提交
18
  CFLAGS+= -DUSE_TCMALLOC
A
antirez 已提交
19
endif
20
CCOPT= $(CFLAGS) $(CCLINK) $(ARCH) $(PROF)
H
hrothgar 已提交
21
DEBUG?= -g -rdynamic -ggdb 
A
antirez 已提交
22

23
PREFIX= /usr/local
P
Pedro Melo 已提交
24
INSTALL_BIN= $(PREFIX)/bin
A
antirez 已提交
25 26
INSTALL= cp -p

27
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
28
BENCHOBJ = ae.o anet.o redis-benchmark.o sds.o adlist.o zmalloc.o
29
CLIOBJ = anet.o sds.o adlist.o redis-cli.o zmalloc.o
30
CHECKDUMPOBJ = redis-check-dump.o lzf_c.o lzf_d.o
P
Pieter Noordhuis 已提交
31
CHECKAOFOBJ = redis-check-aof.o
A
antirez 已提交
32 33 34 35

PRGNAME = redis-server
BENCHPRGNAME = redis-benchmark
CLIPRGNAME = redis-cli
36
CHECKDUMPPRGNAME = redis-check-dump
P
Pieter Noordhuis 已提交
37
CHECKAOFPRGNAME = redis-check-aof
A
antirez 已提交
38

P
Pieter Noordhuis 已提交
39
all: redis-server redis-benchmark redis-cli redis-check-dump redis-check-aof
A
antirez 已提交
40 41

# Deps (use make dep to generate this)
A
antirez 已提交
42
adlist.o: adlist.c adlist.h zmalloc.h
43 44 45
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
46
ae_select.o: ae_select.c
A
antirez 已提交
47
anet.o: anet.c fmacros.h anet.h
A
antirez 已提交
48 49
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
50
chprgname.o: chprgname.c
A
antirez 已提交
51 52 53 54 55 56
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 已提交
57
dict.o: dict.c fmacros.h dict.h zmalloc.h
A
antirez 已提交
58
intset.o: intset.c intset.h zmalloc.h
A
antirez 已提交
59 60
lzf_c.o: lzf_c.c lzfP.h
lzf_d.o: lzf_d.c lzfP.h
A
antirez 已提交
61 62 63 64 65 66
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 已提交
67
pqsort.o: pqsort.c
A
antirez 已提交
68 69 70 71
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
72 73
redis-benchmark.o: redis-benchmark.c fmacros.h ae.h anet.h sds.h adlist.h \
  zmalloc.h
A
antirez 已提交
74
redis-check-aof.o: redis-check-aof.c fmacros.h config.h
75
redis-check-dump.o: redis-check-dump.c lzf.h
76
redis-cli.o: redis-cli.c fmacros.h version.h sds.h adlist.h zmalloc.h
A
antirez 已提交
77 78
redis.o: redis.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
79
release.o: release.c release.h
A
antirez 已提交
80 81
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 已提交
82
sds.o: sds.c sds.h zmalloc.h
83
sha1.o: sha1.c sha1.h
A
antirez 已提交
84 85
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
86
syncio.o: syncio.c
A
antirez 已提交
87 88 89 90 91 92 93 94 95 96 97 98 99 100
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
101
ziplist.o: ziplist.c zmalloc.h ziplist.h
102
zipmap.o: zipmap.c zmalloc.h
A
antirez 已提交
103
zmalloc.o: zmalloc.c config.h
A
antirez 已提交
104

105
redis-server: $(OBJ)
106
	$(CC) -o $(PRGNAME) $(CCOPT) $(DEBUG) $(OBJ)
A
antirez 已提交
107
	@echo ""
108
	@echo "Hint: To run 'make test' is a good idea ;)"
A
antirez 已提交
109 110 111 112 113 114
	@echo ""

redis-benchmark: $(BENCHOBJ)
	$(CC) -o $(BENCHPRGNAME) $(CCOPT) $(DEBUG) $(BENCHOBJ)

redis-cli: $(CLIOBJ)
P
Pieter Noordhuis 已提交
115
	cd ../deps/hiredis && make static
116 117
	cd ../deps/linenoise && make
	$(CC) -o $(CLIPRGNAME) $(CCOPT) $(DEBUG) $(CLIOBJ) ../deps/hiredis/libhiredis.a ../deps/linenoise/linenoise.o
P
Pieter Noordhuis 已提交
118 119

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

122 123 124
redis-check-dump: $(CHECKDUMPOBJ)
	$(CC) -o $(CHECKDUMPPRGNAME) $(CCOPT) $(DEBUG) $(CHECKDUMPOBJ)

P
Pieter Noordhuis 已提交
125 126 127
redis-check-aof: $(CHECKAOFOBJ)
	$(CC) -o $(CHECKAOFPRGNAME) $(CCOPT) $(DEBUG) $(CHECKAOFOBJ)

A
antirez 已提交
128
.c.o:
129
	$(CC) -c $(CFLAGS) $(DEBUG) $(COMPILE_TIME) $<
A
antirez 已提交
130 131

clean:
P
Pieter Noordhuis 已提交
132
	rm -rf $(PRGNAME) $(BENCHPRGNAME) $(CLIPRGNAME) $(CHECKDUMPPRGNAME) $(CHECKAOFPRGNAME) *.o *.gcda *.gcno *.gcov
A
antirez 已提交
133 134 135 136

dep:
	$(CC) -MM *.c

137
test:
138
	(cd ..; tclsh8.5 tests/test_helper.tcl --tags "${TAGS}" --file "${FILE}")
A
antirez 已提交
139 140 141

bench:
	./redis-benchmark
A
antirez 已提交
142 143

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

32bit:
147 148 149 150
	@echo ""
	@echo "WARNING: if it fails under Linux you probably need to install libc6-dev-i386"
	@echo ""
	make ARCH="-m32"
151 152 153 154

gprof:
	make PROF="-pg"

155 156 157
gcov:
	make PROF="-fprofile-arcs -ftest-coverage"

158 159 160
noopt:
	make OPTIMIZATION=""

161 162
32bitgprof:
	make PROF="-pg" ARCH="-arch i386"
A
antirez 已提交
163 164

install: all
165
	mkdir -p $(INSTALL_BIN)
A
antirez 已提交
166 167 168 169 170
	$(INSTALL) $(PRGNAME) $(INSTALL_BIN)
	$(INSTALL) $(BENCHPRGNAME) $(INSTALL_BIN)
	$(INSTALL) $(CLIPRGNAME) $(INSTALL_BIN)
	$(INSTALL) $(CHECKDUMPPRGNAME) $(INSTALL_BIN)
	$(INSTALL) $(CHECKAOFPRGNAME) $(INSTALL_BIN)