]> git.saurik.com Git - redis.git/blame_incremental - deps/hiredis/Makefile
Add hiredis dependency for redis-cli, redis-benchmark, etc
[redis.git] / deps / hiredis / Makefile
... / ...
CommitLineData
1# Hiredis Makefile
2# Copyright (C) 2010 Salvatore Sanfilippo <antirez at gmail dot com>
3# This file is released under the BSD license, see the COPYING file
4
5OBJ = net.o hiredis.o sds.o async.o
6BINS = hiredis-example hiredis-test
7
8uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
9OPTIMIZATION?=-O2
10ifeq ($(uname_S),SunOS)
11 CFLAGS?= -std=c99 -pedantic $(OPTIMIZATION) -fPIC -Wall -W -D__EXTENSIONS__ -D_XPG6
12 CCLINK?= -ldl -lnsl -lsocket -lm -lpthread
13 DYLIBNAME?=libhiredis.so
14 DYLIB_MAKE_CMD?=gcc -shared -Wl,-soname,${DYLIBNAME} -o ${DYLIBNAME} ${OBJ}
15 STLIBNAME?=libhiredis.a
16 STLIB_MAKE_CMD?=ar rcs ${STLIBNAME} ${OBJ}
17else ifeq ($(uname_S),Darwin)
18 CFLAGS?= -std=c99 -pedantic $(OPTIMIZATION) -fPIC -Wall -W -Wwrite-strings $(ARCH) $(PROF)
19 CCLINK?= -lm -pthread
20 OBJARCH?= -arch i386 -arch x86_64
21 DYLIBNAME?=libhiredis.dylib
22 DYLIB_MAKE_CMD?=libtool -dynamic -o ${DYLIBNAME} -lm ${DEBUG} - ${OBJ}
23 STLIBNAME?=libhiredis.a
24 STLIB_MAKE_CMD?=libtool -static -o ${STLIBNAME} - ${OBJ}
25else
26 CFLAGS?= -std=c99 -pedantic $(OPTIMIZATION) -fPIC -Wall -W -Wwrite-strings $(ARCH) $(PROF)
27 CCLINK?= -lm -pthread
28 DYLIBNAME?=libhiredis.so
29 DYLIB_MAKE_CMD?=gcc -shared -Wl,-soname,${DYLIBNAME} -o ${DYLIBNAME} ${OBJ}
30 STLIBNAME?=libhiredis.a
31 STLIB_MAKE_CMD?=ar rcs ${STLIBNAME} ${OBJ}
32endif
33CCOPT= $(CFLAGS) $(CCLINK) $(ARCH) $(PROF)
34DEBUG?= -g -ggdb
35
36PREFIX?= /usr/local
37INSTALL_INC= $(PREFIX)/include/hiredis
38INSTALL_LIB= $(PREFIX)/lib
39INSTALL= cp -a
40
41all: ${DYLIBNAME} ${BINS}
42
43# Deps (use make dep to generate this)
44net.o: net.c fmacros.h net.h
45async.o: async.c async.h hiredis.h sds.h util.h
46example-libev.o: example-libev.c hiredis.h async.h adapters/libev.h
47example-libevent.o: example-libevent.c hiredis.h async.h adapters/libevent.h
48example.o: example.c hiredis.h
49hiredis.o: hiredis.c hiredis.h net.h sds.h util.h
50sds.o: sds.c sds.h
51test.o: test.c hiredis.h
52
53${DYLIBNAME}: ${OBJ}
54 ${DYLIB_MAKE_CMD}
55
56${STLIBNAME}: ${OBJ}
57 ${STLIB_MAKE_CMD}
58
59dynamic: ${DYLIBNAME}
60static: ${STLIBNAME}
61
62# Binaries:
63hiredis-example-libevent: example-libevent.o ${DYLIBNAME}
64 $(CC) -o $@ $(CCOPT) $(DEBUG) -L. -lhiredis -levent -Wl,-rpath,. example-libevent.c
65
66hiredis-example-libev: example-libev.o ${DYLIBNAME}
67 $(CC) -o $@ $(CCOPT) $(DEBUG) -L. -lhiredis -lev -Wl,-rpath,. example-libev.c
68
69hiredis-%: %.o ${DYLIBNAME}
70 $(CC) -o $@ $(CCOPT) $(DEBUG) -L. -lhiredis -Wl,-rpath,. $<
71
72test: hiredis-test
73 ./hiredis-test
74
75.c.o:
76 $(CC) -c $(CFLAGS) $(OBJARCH) $(DEBUG) $(COMPILE_TIME) $<
77
78clean:
79 rm -rf ${DYLIBNAME} ${STLIBNAME} $(BINS) hiredis-example* *.o *.gcda *.gcno *.gcov
80
81dep:
82 $(CC) -MM *.c
83
84install: ${DYLIBNAME} ${STLIBNAME}
85 mkdir -p $(INSTALL_INC) $(INSTALL_LIB)
86 $(INSTALL) hiredis.h async.h adapters $(INSTALL_INC)
87 $(INSTALL) ${DYLIBNAME} ${STLIBNAME} $(INSTALL_LIB)
88
8932bit:
90 @echo ""
91 @echo "WARNING: if it fails under Linux you probably need to install libc6-dev-i386"
92 @echo ""
93 make ARCH="-m32"
94
95gprof:
96 make PROF="-pg"
97
98gcov:
99 make PROF="-fprofile-arcs -ftest-coverage"
100
101noopt:
102 make OPTIMIZATION=""