]> git.saurik.com Git - redis.git/blob - Makefile
create release.h in make process and add this information to INFO listing
[redis.git] / Makefile
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 uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
6 OPTIMIZATION?=-O2
7 ifeq ($(uname_S),SunOS)
8 CFLAGS?= -std=c99 -pedantic $(OPTIMIZATION) -Wall -W -D__EXTENSIONS__ -D_XPG6
9 CCLINK?= -ldl -lnsl -lsocket -lm -lpthread
10 else
11 CFLAGS?= -std=c99 -pedantic $(OPTIMIZATION) -Wall -W $(ARCH) $(PROF)
12 CCLINK?= -lm -pthread
13 endif
14 CCOPT= $(CFLAGS) $(CCLINK) $(ARCH) $(PROF)
15 DEBUG?= -g -rdynamic -ggdb
16
17 GIT_SHA1:=$(shell sh -c '(git show-ref --head --hash=8 2> /dev/null || echo 00000000) | head -n1')
18 GIT_DIRTY:=$(shell sh -c 'git status -s 2> /dev/null | wc -l')
19 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
20 BENCHOBJ = ae.o anet.o redis-benchmark.o sds.o adlist.o zmalloc.o
21 CLIOBJ = anet.o sds.o adlist.o redis-cli.o zmalloc.o linenoise.o
22 CHECKDUMPOBJ = redis-check-dump.o lzf_c.o lzf_d.o
23 CHECKAOFOBJ = redis-check-aof.o
24
25 PRGNAME = redis-server
26 BENCHPRGNAME = redis-benchmark
27 CLIPRGNAME = redis-cli
28 CHECKDUMPPRGNAME = redis-check-dump
29 CHECKAOFPRGNAME = redis-check-aof
30
31 all: redis-server redis-benchmark redis-cli redis-check-dump redis-check-aof
32
33 # Deps (use make dep to generate this)
34 adlist.o: adlist.c adlist.h zmalloc.h
35 ae.o: ae.c ae.h zmalloc.h config.h ae_kqueue.c
36 ae_epoll.o: ae_epoll.c
37 ae_kqueue.o: ae_kqueue.c
38 ae_select.o: ae_select.c
39 anet.o: anet.c fmacros.h anet.h
40 dict.o: dict.c fmacros.h dict.h zmalloc.h
41 dict2.o: dict2.c fmacros.h dict2.h zmalloc.h
42 linenoise.o: linenoise.c fmacros.h
43 lzf_c.o: lzf_c.c lzfP.h
44 lzf_d.o: lzf_d.c lzfP.h
45 pqsort.o: pqsort.c
46 printraw.o: printraw.c
47 redis-benchmark.o: redis-benchmark.c fmacros.h ae.h anet.h sds.h adlist.h \
48 zmalloc.h
49 redis-check-aof.o: redis-check-aof.c fmacros.h config.h
50 redis-check-dump.o: redis-check-dump.c lzf.h
51 redis-cli.o: redis-cli.c fmacros.h anet.h sds.h adlist.h zmalloc.h \
52 linenoise.h
53 redis.o: redis.c fmacros.h config.h redis.h ae.h sds.h anet.h dict.h \
54 adlist.h zmalloc.h lzf.h pqsort.h zipmap.h staticsymbols.h sha1.h
55 sds.o: sds.c sds.h zmalloc.h
56 zipmap.o: zipmap.c zmalloc.h
57 zmalloc.o: zmalloc.c config.h
58
59 redis-server: releaseheader $(OBJ)
60 $(CC) -o $(PRGNAME) $(CCOPT) $(DEBUG) $(OBJ)
61 @echo ""
62 @echo "Hint: To run the test-redis.tcl script is a good idea."
63 @echo "Launch the redis server with ./redis-server, then in another"
64 @echo "terminal window enter this directory and run 'make test'."
65 @echo ""
66
67 redis-benchmark: $(BENCHOBJ)
68 $(CC) -o $(BENCHPRGNAME) $(CCOPT) $(DEBUG) $(BENCHOBJ)
69
70 redis-cli: $(CLIOBJ)
71 $(CC) -o $(CLIPRGNAME) $(CCOPT) $(DEBUG) $(CLIOBJ)
72
73 redis-check-dump: $(CHECKDUMPOBJ)
74 $(CC) -o $(CHECKDUMPPRGNAME) $(CCOPT) $(DEBUG) $(CHECKDUMPOBJ)
75
76 redis-check-aof: $(CHECKAOFOBJ)
77 $(CC) -o $(CHECKAOFPRGNAME) $(CCOPT) $(DEBUG) $(CHECKAOFOBJ)
78
79 releaseheader:
80 @echo "#define REDIS_GIT_SHA1 \"$(GIT_SHA1)\"" > release.h
81 @echo "#define REDIS_GIT_DIRTY $(GIT_DIRTY)" >> release.h
82 @touch redis.c # force recompile of redis.c
83
84 .c.o:
85 $(CC) -c $(CFLAGS) $(DEBUG) $(COMPILE_TIME) $<
86
87 clean:
88 rm -rf $(PRGNAME) $(BENCHPRGNAME) $(CLIPRGNAME) $(CHECKDUMPPRGNAME) $(CHECKAOFPRGNAME) *.o *.gcda *.gcno *.gcov
89
90 dep:
91 $(CC) -MM *.c
92
93 staticsymbols:
94 tclsh utils/build-static-symbols.tcl > staticsymbols.h
95
96 test:
97 tclsh8.5 tests/test_helper.tcl
98
99 bench:
100 ./redis-benchmark
101
102 log:
103 git log '--pretty=format:%ad %s (%cn)' --date=short > Changelog
104
105 32bit:
106 @echo ""
107 @echo "WARNING: if it fails under Linux you probably need to install libc6-dev-i386"
108 @echo ""
109 make ARCH="-m32"
110
111 gprof:
112 make PROF="-pg"
113
114 gcov:
115 make PROF="-fprofile-arcs -ftest-coverage"
116
117 noopt:
118 make OPTIMIZATION=""
119
120 32bitgprof:
121 make PROF="-pg" ARCH="-arch i386"