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