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