]> git.saurik.com Git - redis.git/blob - deps/hiredis/Makefile
Update hiredis to 0.9.2
[redis.git] / deps / hiredis / Makefile
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
5 OBJ = net.o hiredis.o sds.o async.o
6 BINS = hiredis-example hiredis-test
7
8 uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
9 OPTIMIZATION?=-O3
10 ifeq ($(uname_S),SunOS)
11 CFLAGS?=-std=c99 -pedantic $(OPTIMIZATION) -fPIC -Wall -W -D__EXTENSIONS__ -D_XPG6 $(ARCH) $(PROF)
12 CCLINK?=-ldl -lnsl -lsocket -lm -lpthread
13 LDFLAGS?=-L. -Wl,-R,.
14 DYLIBNAME?=libhiredis.so
15 DYLIB_MAKE_CMD?=$(CC) -G -o ${DYLIBNAME} ${OBJ}
16 STLIBNAME?=libhiredis.a
17 STLIB_MAKE_CMD?=ar rcs ${STLIBNAME} ${OBJ}
18 else ifeq ($(uname_S),Darwin)
19 CFLAGS?=-std=c99 -pedantic $(OPTIMIZATION) -fPIC -Wall -W -Wwrite-strings $(ARCH) $(PROF)
20 CCLINK?=-lm -pthread
21 LDFLAGS?=-L. -Wl,-rpath,.
22 OBJARCH?=-arch i386 -arch x86_64
23 DYLIBNAME?=libhiredis.dylib
24 DYLIB_MAKE_CMD?=libtool -dynamic -o ${DYLIBNAME} -lm ${DEBUG} - ${OBJ}
25 STLIBNAME?=libhiredis.a
26 STLIB_MAKE_CMD?=libtool -static -o ${STLIBNAME} - ${OBJ}
27 else
28 CFLAGS?=-std=c99 -pedantic $(OPTIMIZATION) -fPIC -Wall -W -Wwrite-strings $(ARCH) $(PROF)
29 CCLINK?=-lm -pthread
30 LDFLAGS?=-L. -Wl,-rpath,.
31 DYLIBNAME?=libhiredis.so
32 DYLIB_MAKE_CMD?=gcc -shared -Wl,-soname,${DYLIBNAME} -o ${DYLIBNAME} ${OBJ}
33 STLIBNAME?=libhiredis.a
34 STLIB_MAKE_CMD?=ar rcs ${STLIBNAME} ${OBJ}
35 endif
36 CCOPT= $(CFLAGS) $(CCLINK)
37 DEBUG?= -g -ggdb
38
39 PREFIX?= /usr/local
40 INSTALL_INC= $(PREFIX)/include/hiredis
41 INSTALL_LIB= $(PREFIX)/lib
42 INSTALL= cp -a
43
44 all: ${DYLIBNAME} ${BINS}
45
46 # Deps (use make dep to generate this)
47 net.o: net.c fmacros.h net.h
48 async.o: async.c async.h hiredis.h sds.h util.h
49 example.o: example.c hiredis.h
50 hiredis.o: hiredis.c hiredis.h net.h sds.h util.h
51 sds.o: sds.c sds.h
52 test.o: test.c hiredis.h
53
54 ${DYLIBNAME}: ${OBJ}
55 ${DYLIB_MAKE_CMD}
56
57 ${STLIBNAME}: ${OBJ}
58 ${STLIB_MAKE_CMD}
59
60 dynamic: ${DYLIBNAME}
61 static: ${STLIBNAME}
62
63 # Binaries:
64 hiredis-example-libevent: example-libevent.c adapters/libevent.h ${DYLIBNAME}
65 $(CC) -o $@ $(CCOPT) $(DEBUG) $(LDFLAGS) -lhiredis -levent example-libevent.c
66
67 hiredis-example-libev: example-libev.c adapters/libev.h ${DYLIBNAME}
68 $(CC) -o $@ $(CCOPT) $(DEBUG) $(LDFLAGS) -lhiredis -lev example-libev.c
69
70 ifndef AE_DIR
71 hiredis-example-ae:
72 @echo "Please specify AE_DIR (e.g. <redis repository>/src)"
73 @false
74 else
75 hiredis-example-ae: example-ae.c adapters/ae.h ${DYLIBNAME}
76 $(CC) -o $@ $(CCOPT) $(DEBUG) -I$(AE_DIR) $(LDFLAGS) -lhiredis example-ae.c $(AE_DIR)/ae.o $(AE_DIR)/zmalloc.o
77 endif
78
79 hiredis-%: %.o ${DYLIBNAME}
80 $(CC) -o $@ $(CCOPT) $(DEBUG) $(LDFLAGS) -lhiredis $<
81
82 test: hiredis-test
83 ./hiredis-test
84
85 .c.o:
86 $(CC) -c $(CFLAGS) $(OBJARCH) $(DEBUG) $(COMPILE_TIME) $<
87
88 clean:
89 rm -rf ${DYLIBNAME} ${STLIBNAME} $(BINS) hiredis-example* *.o *.gcda *.gcno *.gcov
90
91 dep:
92 $(CC) -MM *.c
93
94 install: ${DYLIBNAME} ${STLIBNAME}
95 mkdir -p $(INSTALL_INC) $(INSTALL_LIB)
96 $(INSTALL) hiredis.h async.h adapters $(INSTALL_INC)
97 $(INSTALL) ${DYLIBNAME} ${STLIBNAME} $(INSTALL_LIB)
98
99 32bit:
100 @echo ""
101 @echo "WARNING: if it fails under Linux you probably need to install libc6-dev-i386"
102 @echo ""
103 $(MAKE) ARCH="-m32"
104
105 gprof:
106 $(MAKE) PROF="-pg"
107
108 gcov:
109 $(MAKE) PROF="-fprofile-arcs -ftest-coverage"
110
111 noopt:
112 $(MAKE) OPTIMIZATION=""