]> git.saurik.com Git - redis.git/blob - deps/hiredis/Makefile
3c4b6ce28798ccb28e2d6cdff9871513bf7df367
[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?=-O2
10 ifeq ($(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}
17 else 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}
25 else
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}
32 endif
33 CCOPT= $(CFLAGS) $(CCLINK) $(ARCH) $(PROF)
34 DEBUG?= -g -ggdb
35
36 PREFIX?= /usr/local
37 INSTALL_INC= $(PREFIX)/include/hiredis
38 INSTALL_LIB= $(PREFIX)/lib
39 INSTALL= cp -a
40
41 all: ${DYLIBNAME} ${BINS}
42
43 # Deps (use make dep to generate this)
44 net.o: net.c fmacros.h net.h
45 async.o: async.c async.h hiredis.h sds.h util.h
46 example-libev.o: example-libev.c hiredis.h async.h adapters/libev.h
47 example-libevent.o: example-libevent.c hiredis.h async.h adapters/libevent.h
48 example.o: example.c hiredis.h
49 hiredis.o: hiredis.c hiredis.h net.h sds.h util.h
50 sds.o: sds.c sds.h
51 test.o: test.c hiredis.h
52
53 ${DYLIBNAME}: ${OBJ}
54 ${DYLIB_MAKE_CMD}
55
56 ${STLIBNAME}: ${OBJ}
57 ${STLIB_MAKE_CMD}
58
59 dynamic: ${DYLIBNAME}
60 static: ${STLIBNAME}
61
62 # Binaries:
63 hiredis-example-libevent: example-libevent.o ${DYLIBNAME}
64 $(CC) -o $@ $(CCOPT) $(DEBUG) -L. -lhiredis -levent -Wl,-rpath,. example-libevent.c
65
66 hiredis-example-libev: example-libev.o ${DYLIBNAME}
67 $(CC) -o $@ $(CCOPT) $(DEBUG) -L. -lhiredis -lev -Wl,-rpath,. example-libev.c
68
69 hiredis-%: %.o ${DYLIBNAME}
70 $(CC) -o $@ $(CCOPT) $(DEBUG) -L. -lhiredis -Wl,-rpath,. $<
71
72 test: hiredis-test
73 ./hiredis-test
74
75 .c.o:
76 $(CC) -c $(CFLAGS) $(OBJARCH) $(DEBUG) $(COMPILE_TIME) $<
77
78 clean:
79 rm -rf ${DYLIBNAME} ${STLIBNAME} $(BINS) hiredis-example* *.o *.gcda *.gcno *.gcov
80
81 dep:
82 $(CC) -MM *.c
83
84 install: ${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
89 32bit:
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
95 gprof:
96 $(MAKE) PROF="-pg"
97
98 gcov:
99 $(MAKE) PROF="-fprofile-arcs -ftest-coverage"
100
101 noopt:
102 $(MAKE) OPTIMIZATION=""