]>
Commit | Line | Data |
---|---|---|
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 | ||
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') | |
a1e97d69 | 9 | OPTIMIZATION?=-O3 |
24f753a8 | 10 | ifeq ($(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} | |
18 | else 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} | |
27 | else | |
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} | |
35 | endif | |
a1e97d69 PN |
36 | CCOPT= $(CFLAGS) $(CCLINK) |
37 | DEBUG?= -g -ggdb | |
24f753a8 PN |
38 | |
39 | PREFIX?= /usr/local | |
40 | INSTALL_INC= $(PREFIX)/include/hiredis | |
41 | INSTALL_LIB= $(PREFIX)/lib | |
42 | INSTALL= cp -a | |
43 | ||
44 | all: ${DYLIBNAME} ${BINS} | |
45 | ||
46 | # Deps (use make dep to generate this) | |
47 | net.o: net.c fmacros.h net.h | |
48 | async.o: async.c async.h hiredis.h sds.h util.h | |
24f753a8 PN |
49 | example.o: example.c hiredis.h |
50 | hiredis.o: hiredis.c hiredis.h net.h sds.h util.h | |
51 | sds.o: sds.c sds.h | |
52 | test.o: test.c hiredis.h | |
53 | ||
54 | ${DYLIBNAME}: ${OBJ} | |
55 | ${DYLIB_MAKE_CMD} | |
56 | ||
57 | ${STLIBNAME}: ${OBJ} | |
58 | ${STLIB_MAKE_CMD} | |
59 | ||
60 | dynamic: ${DYLIBNAME} | |
61 | static: ${STLIBNAME} | |
62 | ||
63 | # Binaries: | |
a1e97d69 PN |
64 | hiredis-example-libevent: example-libevent.c adapters/libevent.h ${DYLIBNAME} |
65 | $(CC) -o $@ $(CCOPT) $(DEBUG) $(LDFLAGS) -lhiredis -levent example-libevent.c | |
66 | ||
67 | hiredis-example-libev: example-libev.c adapters/libev.h ${DYLIBNAME} | |
68 | $(CC) -o $@ $(CCOPT) $(DEBUG) $(LDFLAGS) -lhiredis -lev example-libev.c | |
24f753a8 | 69 | |
a1e97d69 PN |
70 | ifndef AE_DIR |
71 | hiredis-example-ae: | |
72 | @echo "Please specify AE_DIR (e.g. <redis repository>/src)" | |
73 | @false | |
74 | else | |
75 | hiredis-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 | |
77 | endif | |
24f753a8 PN |
78 | |
79 | hiredis-%: %.o ${DYLIBNAME} | |
a1e97d69 | 80 | $(CC) -o $@ $(CCOPT) $(DEBUG) $(LDFLAGS) -lhiredis $< |
24f753a8 PN |
81 | |
82 | test: hiredis-test | |
83 | ./hiredis-test | |
84 | ||
85 | .c.o: | |
86 | $(CC) -c $(CFLAGS) $(OBJARCH) $(DEBUG) $(COMPILE_TIME) $< | |
87 | ||
88 | clean: | |
89 | rm -rf ${DYLIBNAME} ${STLIBNAME} $(BINS) hiredis-example* *.o *.gcda *.gcno *.gcov | |
90 | ||
91 | dep: | |
92 | $(CC) -MM *.c | |
93 | ||
94 | install: ${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 | ||
99 | 32bit: | |
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 | |
105 | gprof: | |
a4e48b41 | 106 | $(MAKE) PROF="-pg" |
24f753a8 PN |
107 | |
108 | gcov: | |
a4e48b41 | 109 | $(MAKE) PROF="-fprofile-arcs -ftest-coverage" |
24f753a8 PN |
110 | |
111 | noopt: | |
a4e48b41 | 112 | $(MAKE) OPTIMIZATION="" |