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