2 # Copyright (C) 2010 Salvatore Sanfilippo <antirez at gmail dot com>
3 # This file is released under the BSD license, see the COPYING file
5 OBJ = net.o hiredis.o sds.o async.o
6 BINS = hiredis-example hiredis-test
8 uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
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
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}
19 ifeq ($(uname_S),Darwin)
20 CFLAGS?=-std=c99 -pedantic $(OPTIMIZATION) -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings $(ARCH) $(PROF)
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}
29 CFLAGS?=-std=c99 -pedantic $(OPTIMIZATION) -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings $(ARCH) $(PROF)
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}
39 CCOPT= $(CFLAGS) $(CCLINK)
43 INSTALL_INC= $(PREFIX)/include/hiredis
44 INSTALL_LIB= $(PREFIX)/lib
47 all: ${DYLIBNAME} ${BINS}
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
55 test.o: test.c hiredis.h
67 hiredis-example-libevent: example-libevent.c adapters/libevent.h ${DYLIBNAME}
68 $(CC) -o $@ $(CCOPT) $(DEBUG) $(LDFLAGS) -lhiredis -levent example-libevent.c
70 hiredis-example-libev: example-libev.c adapters/libev.h ${DYLIBNAME}
71 $(CC) -o $@ $(CCOPT) $(DEBUG) $(LDFLAGS) -lhiredis -lev example-libev.c
75 @echo "Please specify AE_DIR (e.g. <redis repository>/src)"
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
82 hiredis-%: %.o ${DYLIBNAME}
83 $(CC) -o $@ $(CCOPT) $(DEBUG) $(LDFLAGS) -lhiredis $<
89 $(CC) -c $(CFLAGS) $(OBJARCH) $(DEBUG) $(COMPILE_TIME) $<
92 rm -rf ${DYLIBNAME} ${STLIBNAME} $(BINS) hiredis-example* *.o *.gcda *.gcno *.gcov
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)
104 @echo "WARNING: if it fails under Linux you probably need to install libc6-dev-i386"
112 $(MAKE) PROF="-fprofile-arcs -ftest-coverage"
115 $(MAKE) OPTIMIZATION=""