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