Makefile 7.1 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 19

ifeq ($(USE_TCMALLOC),yes)
  CCLINK+= -ltcmalloc
A
antirez 已提交
20
  CFLAGS+= -DUSE_TCMALLOC
A
antirez 已提交
21
endif
22
CCOPT= $(CFLAGS) $(CCLINK) $(ARCH) $(PROF)
A
antirez 已提交
23

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

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

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

40
all: redis-benchmark redis-cli redis-check-dump redis-check-aof redis-server
P
Pieter Noordhuis 已提交
41 42 43
	@echo ""
	@echo "Hint: To run 'make test' is a good idea ;)"
	@echo ""
A
antirez 已提交
44 45

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

P
Pieter Noordhuis 已提交
114 115 116 117
dependencies:
	cd ../deps/hiredis && $(MAKE) static ARCH="$(ARCH)"
	cd ../deps/linenoise && $(MAKE) ARCH="$(ARCH)"

118
redis-server: $(OBJ)
119
	$(CC) -o $(PRGNAME) $(CCOPT) $(DEBUG) $(OBJ)
A
antirez 已提交
120

P
Pieter Noordhuis 已提交
121
redis-benchmark: dependencies $(BENCHOBJ)
P
Pieter Noordhuis 已提交
122
	cd ../deps/hiredis && $(MAKE) static
123 124 125 126
	$(CC) -o $(BENCHPRGNAME) $(CCOPT) $(DEBUG) $(BENCHOBJ) ../deps/hiredis/libhiredis.a

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

P
Pieter Noordhuis 已提交
128
redis-cli: dependencies $(CLIOBJ)
129
	$(CC) -o $(CLIPRGNAME) $(CCOPT) $(DEBUG) $(CLIOBJ) ../deps/hiredis/libhiredis.a ../deps/linenoise/linenoise.o
P
Pieter Noordhuis 已提交
130 131

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

134 135 136
redis-check-dump: $(CHECKDUMPOBJ)
	$(CC) -o $(CHECKDUMPPRGNAME) $(CCOPT) $(DEBUG) $(CHECKDUMPOBJ)

P
Pieter Noordhuis 已提交
137 138 139
redis-check-aof: $(CHECKAOFOBJ)
	$(CC) -o $(CHECKAOFPRGNAME) $(CCOPT) $(DEBUG) $(CHECKAOFOBJ)

A
antirez 已提交
140
.c.o:
141
	$(CC) -c $(CFLAGS) $(DEBUG) $(COMPILE_TIME) $<
A
antirez 已提交
142 143

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

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

P
Pieter Noordhuis 已提交
149
test: redis-server
150
	(cd ..; tclsh8.5 tests/test_helper.tcl --tags "${TAGS}" --file "${FILE}")
A
antirez 已提交
151 152 153

bench:
	./redis-benchmark
A
antirez 已提交
154 155

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

32bit:
159 160 161
	@echo ""
	@echo "WARNING: if it fails under Linux you probably need to install libc6-dev-i386"
	@echo ""
P
Pieter Noordhuis 已提交
162
	$(MAKE) ARCH="-m32"
163 164

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

167
gcov:
P
Pieter Noordhuis 已提交
168
	$(MAKE) PROF="-fprofile-arcs -ftest-coverage"
169

170
noopt:
P
Pieter Noordhuis 已提交
171
	$(MAKE) OPTIMIZATION=""
172

173
32bitgprof:
P
Pieter Noordhuis 已提交
174
	$(MAKE) PROF="-pg" ARCH="-arch i386"
A
antirez 已提交
175 176

install: all
177
	mkdir -p $(INSTALL_BIN)
A
antirez 已提交
178 179 180 181 182
	$(INSTALL) $(PRGNAME) $(INSTALL_BIN)
	$(INSTALL) $(BENCHPRGNAME) $(INSTALL_BIN)
	$(INSTALL) $(CLIPRGNAME) $(INSTALL_BIN)
	$(INSTALL) $(CHECKDUMPPRGNAME) $(INSTALL_BIN)
	$(INSTALL) $(CHECKAOFPRGNAME) $(INSTALL_BIN)