hiredis-client 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +5 -0
- data/ext/redis_client/hiredis/export.clang +2 -0
- data/ext/redis_client/hiredis/export.gcc +7 -0
- data/ext/redis_client/hiredis/extconf.rb +69 -0
- data/ext/redis_client/hiredis/hiredis_connection.c +708 -0
- data/ext/redis_client/hiredis/vendor/.gitignore +9 -0
- data/ext/redis_client/hiredis/vendor/.travis.yml +131 -0
- data/ext/redis_client/hiredis/vendor/CHANGELOG.md +364 -0
- data/ext/redis_client/hiredis/vendor/CMakeLists.txt +165 -0
- data/ext/redis_client/hiredis/vendor/COPYING +29 -0
- data/ext/redis_client/hiredis/vendor/Makefile +308 -0
- data/ext/redis_client/hiredis/vendor/README.md +664 -0
- data/ext/redis_client/hiredis/vendor/adapters/ae.h +130 -0
- data/ext/redis_client/hiredis/vendor/adapters/glib.h +156 -0
- data/ext/redis_client/hiredis/vendor/adapters/ivykis.h +84 -0
- data/ext/redis_client/hiredis/vendor/adapters/libev.h +179 -0
- data/ext/redis_client/hiredis/vendor/adapters/libevent.h +175 -0
- data/ext/redis_client/hiredis/vendor/adapters/libuv.h +117 -0
- data/ext/redis_client/hiredis/vendor/adapters/macosx.h +115 -0
- data/ext/redis_client/hiredis/vendor/adapters/qt.h +135 -0
- data/ext/redis_client/hiredis/vendor/alloc.c +86 -0
- data/ext/redis_client/hiredis/vendor/alloc.h +91 -0
- data/ext/redis_client/hiredis/vendor/appveyor.yml +24 -0
- data/ext/redis_client/hiredis/vendor/async.c +887 -0
- data/ext/redis_client/hiredis/vendor/async.h +147 -0
- data/ext/redis_client/hiredis/vendor/async_private.h +75 -0
- data/ext/redis_client/hiredis/vendor/dict.c +352 -0
- data/ext/redis_client/hiredis/vendor/dict.h +126 -0
- data/ext/redis_client/hiredis/vendor/fmacros.h +12 -0
- data/ext/redis_client/hiredis/vendor/hiredis-config.cmake.in +13 -0
- data/ext/redis_client/hiredis/vendor/hiredis.c +1174 -0
- data/ext/redis_client/hiredis/vendor/hiredis.h +336 -0
- data/ext/redis_client/hiredis/vendor/hiredis.pc.in +12 -0
- data/ext/redis_client/hiredis/vendor/hiredis_ssl-config.cmake.in +13 -0
- data/ext/redis_client/hiredis/vendor/hiredis_ssl.h +157 -0
- data/ext/redis_client/hiredis/vendor/hiredis_ssl.pc.in +12 -0
- data/ext/redis_client/hiredis/vendor/net.c +612 -0
- data/ext/redis_client/hiredis/vendor/net.h +56 -0
- data/ext/redis_client/hiredis/vendor/read.c +739 -0
- data/ext/redis_client/hiredis/vendor/read.h +129 -0
- data/ext/redis_client/hiredis/vendor/sds.c +1289 -0
- data/ext/redis_client/hiredis/vendor/sds.h +278 -0
- data/ext/redis_client/hiredis/vendor/sdsalloc.h +44 -0
- data/ext/redis_client/hiredis/vendor/sockcompat.c +248 -0
- data/ext/redis_client/hiredis/vendor/sockcompat.h +92 -0
- data/ext/redis_client/hiredis/vendor/ssl.c +544 -0
- data/ext/redis_client/hiredis/vendor/test.c +1401 -0
- data/ext/redis_client/hiredis/vendor/test.sh +78 -0
- data/ext/redis_client/hiredis/vendor/win32.h +56 -0
- data/hiredis-client.gemspec +33 -0
- data/lib/hiredis-client.rb +11 -0
- data/lib/redis_client/hiredis_connection.rb +94 -0
- metadata +114 -0
@@ -0,0 +1,165 @@
|
|
1
|
+
CMAKE_MINIMUM_REQUIRED(VERSION 3.4.0)
|
2
|
+
INCLUDE(GNUInstallDirs)
|
3
|
+
PROJECT(hiredis)
|
4
|
+
|
5
|
+
OPTION(ENABLE_SSL "Build hiredis_ssl for SSL support" OFF)
|
6
|
+
OPTION(DISABLE_TESTS "If tests should be compiled or not" OFF)
|
7
|
+
OPTION(ENABLE_SSL_TESTS, "Should we test SSL connections" OFF)
|
8
|
+
|
9
|
+
MACRO(getVersionBit name)
|
10
|
+
SET(VERSION_REGEX "^#define ${name} (.+)$")
|
11
|
+
FILE(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/hiredis.h"
|
12
|
+
VERSION_BIT REGEX ${VERSION_REGEX})
|
13
|
+
STRING(REGEX REPLACE ${VERSION_REGEX} "\\1" ${name} "${VERSION_BIT}")
|
14
|
+
ENDMACRO(getVersionBit)
|
15
|
+
|
16
|
+
getVersionBit(HIREDIS_MAJOR)
|
17
|
+
getVersionBit(HIREDIS_MINOR)
|
18
|
+
getVersionBit(HIREDIS_PATCH)
|
19
|
+
getVersionBit(HIREDIS_SONAME)
|
20
|
+
SET(VERSION "${HIREDIS_MAJOR}.${HIREDIS_MINOR}.${HIREDIS_PATCH}")
|
21
|
+
MESSAGE("Detected version: ${VERSION}")
|
22
|
+
|
23
|
+
PROJECT(hiredis VERSION "${VERSION}")
|
24
|
+
|
25
|
+
SET(ENABLE_EXAMPLES OFF CACHE BOOL "Enable building hiredis examples")
|
26
|
+
|
27
|
+
SET(hiredis_sources
|
28
|
+
alloc.c
|
29
|
+
async.c
|
30
|
+
dict.c
|
31
|
+
hiredis.c
|
32
|
+
net.c
|
33
|
+
read.c
|
34
|
+
sds.c
|
35
|
+
sockcompat.c)
|
36
|
+
|
37
|
+
SET(hiredis_sources ${hiredis_sources})
|
38
|
+
|
39
|
+
IF(WIN32)
|
40
|
+
ADD_COMPILE_DEFINITIONS(_CRT_SECURE_NO_WARNINGS WIN32_LEAN_AND_MEAN)
|
41
|
+
ENDIF()
|
42
|
+
|
43
|
+
ADD_LIBRARY(hiredis SHARED ${hiredis_sources})
|
44
|
+
|
45
|
+
SET_TARGET_PROPERTIES(hiredis
|
46
|
+
PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE
|
47
|
+
VERSION "${HIREDIS_SONAME}")
|
48
|
+
IF(WIN32 OR MINGW)
|
49
|
+
TARGET_LINK_LIBRARIES(hiredis PRIVATE ws2_32)
|
50
|
+
ENDIF()
|
51
|
+
|
52
|
+
TARGET_INCLUDE_DIRECTORIES(hiredis PUBLIC $<INSTALL_INTERFACE:.> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
|
53
|
+
|
54
|
+
CONFIGURE_FILE(hiredis.pc.in hiredis.pc @ONLY)
|
55
|
+
|
56
|
+
INSTALL(TARGETS hiredis
|
57
|
+
EXPORT hiredis-targets
|
58
|
+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
59
|
+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
60
|
+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
61
|
+
|
62
|
+
INSTALL(FILES hiredis.h read.h sds.h async.h alloc.h
|
63
|
+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hiredis)
|
64
|
+
|
65
|
+
INSTALL(DIRECTORY adapters
|
66
|
+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hiredis)
|
67
|
+
|
68
|
+
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/hiredis.pc
|
69
|
+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
70
|
+
|
71
|
+
export(EXPORT hiredis-targets
|
72
|
+
FILE "${CMAKE_CURRENT_BINARY_DIR}/hiredis-targets.cmake"
|
73
|
+
NAMESPACE hiredis::)
|
74
|
+
|
75
|
+
SET(CMAKE_CONF_INSTALL_DIR share/hiredis)
|
76
|
+
SET(INCLUDE_INSTALL_DIR include)
|
77
|
+
include(CMakePackageConfigHelpers)
|
78
|
+
configure_package_config_file(hiredis-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/hiredis-config.cmake
|
79
|
+
INSTALL_DESTINATION ${CMAKE_CONF_INSTALL_DIR}
|
80
|
+
PATH_VARS INCLUDE_INSTALL_DIR)
|
81
|
+
|
82
|
+
INSTALL(EXPORT hiredis-targets
|
83
|
+
FILE hiredis-targets.cmake
|
84
|
+
NAMESPACE hiredis::
|
85
|
+
DESTINATION ${CMAKE_CONF_INSTALL_DIR})
|
86
|
+
|
87
|
+
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/hiredis-config.cmake
|
88
|
+
DESTINATION ${CMAKE_CONF_INSTALL_DIR})
|
89
|
+
|
90
|
+
|
91
|
+
IF(ENABLE_SSL)
|
92
|
+
IF (NOT OPENSSL_ROOT_DIR)
|
93
|
+
IF (APPLE)
|
94
|
+
SET(OPENSSL_ROOT_DIR "/usr/local/opt/openssl")
|
95
|
+
ENDIF()
|
96
|
+
ENDIF()
|
97
|
+
FIND_PACKAGE(OpenSSL REQUIRED)
|
98
|
+
SET(hiredis_ssl_sources
|
99
|
+
ssl.c)
|
100
|
+
ADD_LIBRARY(hiredis_ssl SHARED
|
101
|
+
${hiredis_ssl_sources})
|
102
|
+
|
103
|
+
IF (APPLE)
|
104
|
+
SET_PROPERTY(TARGET hiredis_ssl PROPERTY LINK_FLAGS "-Wl,-undefined -Wl,dynamic_lookup")
|
105
|
+
ENDIF()
|
106
|
+
|
107
|
+
SET_TARGET_PROPERTIES(hiredis_ssl
|
108
|
+
PROPERTIES
|
109
|
+
WINDOWS_EXPORT_ALL_SYMBOLS TRUE
|
110
|
+
VERSION "${HIREDIS_SONAME}")
|
111
|
+
|
112
|
+
TARGET_INCLUDE_DIRECTORIES(hiredis_ssl PRIVATE "${OPENSSL_INCLUDE_DIR}")
|
113
|
+
TARGET_LINK_LIBRARIES(hiredis_ssl PRIVATE ${OPENSSL_LIBRARIES})
|
114
|
+
IF (WIN32 OR MINGW)
|
115
|
+
TARGET_LINK_LIBRARIES(hiredis_ssl PRIVATE hiredis)
|
116
|
+
ENDIF()
|
117
|
+
CONFIGURE_FILE(hiredis_ssl.pc.in hiredis_ssl.pc @ONLY)
|
118
|
+
|
119
|
+
INSTALL(TARGETS hiredis_ssl
|
120
|
+
EXPORT hiredis_ssl-targets
|
121
|
+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
122
|
+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
123
|
+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
124
|
+
|
125
|
+
INSTALL(FILES hiredis_ssl.h
|
126
|
+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hiredis)
|
127
|
+
|
128
|
+
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/hiredis_ssl.pc
|
129
|
+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
130
|
+
|
131
|
+
export(EXPORT hiredis_ssl-targets
|
132
|
+
FILE "${CMAKE_CURRENT_BINARY_DIR}/hiredis_ssl-targets.cmake"
|
133
|
+
NAMESPACE hiredis::)
|
134
|
+
|
135
|
+
SET(CMAKE_CONF_INSTALL_DIR share/hiredis_ssl)
|
136
|
+
configure_package_config_file(hiredis_ssl-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/hiredis_ssl-config.cmake
|
137
|
+
INSTALL_DESTINATION ${CMAKE_CONF_INSTALL_DIR}
|
138
|
+
PATH_VARS INCLUDE_INSTALL_DIR)
|
139
|
+
|
140
|
+
INSTALL(EXPORT hiredis_ssl-targets
|
141
|
+
FILE hiredis_ssl-targets.cmake
|
142
|
+
NAMESPACE hiredis::
|
143
|
+
DESTINATION ${CMAKE_CONF_INSTALL_DIR})
|
144
|
+
|
145
|
+
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/hiredis_ssl-config.cmake
|
146
|
+
DESTINATION ${CMAKE_CONF_INSTALL_DIR})
|
147
|
+
ENDIF()
|
148
|
+
|
149
|
+
IF(NOT DISABLE_TESTS)
|
150
|
+
ENABLE_TESTING()
|
151
|
+
ADD_EXECUTABLE(hiredis-test test.c)
|
152
|
+
IF(ENABLE_SSL_TESTS)
|
153
|
+
ADD_DEFINITIONS(-DHIREDIS_TEST_SSL=1)
|
154
|
+
TARGET_LINK_LIBRARIES(hiredis-test hiredis hiredis_ssl)
|
155
|
+
ELSE()
|
156
|
+
TARGET_LINK_LIBRARIES(hiredis-test hiredis)
|
157
|
+
ENDIF()
|
158
|
+
ADD_TEST(NAME hiredis-test
|
159
|
+
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test.sh)
|
160
|
+
ENDIF()
|
161
|
+
|
162
|
+
# Add examples
|
163
|
+
IF(ENABLE_EXAMPLES)
|
164
|
+
ADD_SUBDIRECTORY(examples)
|
165
|
+
ENDIF(ENABLE_EXAMPLES)
|
@@ -0,0 +1,29 @@
|
|
1
|
+
Copyright (c) 2009-2011, Salvatore Sanfilippo <antirez at gmail dot com>
|
2
|
+
Copyright (c) 2010-2011, Pieter Noordhuis <pcnoordhuis at gmail dot com>
|
3
|
+
|
4
|
+
All rights reserved.
|
5
|
+
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
8
|
+
|
9
|
+
* Redistributions of source code must retain the above copyright notice,
|
10
|
+
this list of conditions and the following disclaimer.
|
11
|
+
|
12
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
14
|
+
and/or other materials provided with the distribution.
|
15
|
+
|
16
|
+
* Neither the name of Redis nor the names of its contributors may be used
|
17
|
+
to endorse or promote products derived from this software without specific
|
18
|
+
prior written permission.
|
19
|
+
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
21
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
22
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
24
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
25
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
26
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
27
|
+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
28
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
29
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
@@ -0,0 +1,308 @@
|
|
1
|
+
# Hiredis Makefile
|
2
|
+
# Copyright (C) 2010-2011 Salvatore Sanfilippo <antirez at gmail dot com>
|
3
|
+
# Copyright (C) 2010-2011 Pieter Noordhuis <pcnoordhuis at gmail dot com>
|
4
|
+
# This file is released under the BSD license, see the COPYING file
|
5
|
+
|
6
|
+
OBJ=alloc.o net.o hiredis.o sds.o async.o read.o sockcompat.o
|
7
|
+
SSL_OBJ=ssl.o
|
8
|
+
EXAMPLES=hiredis-example hiredis-example-libevent hiredis-example-libev hiredis-example-glib hiredis-example-push
|
9
|
+
ifeq ($(USE_SSL),1)
|
10
|
+
EXAMPLES+=hiredis-example-ssl hiredis-example-libevent-ssl
|
11
|
+
endif
|
12
|
+
TESTS=hiredis-test
|
13
|
+
LIBNAME=libhiredis
|
14
|
+
PKGCONFNAME=hiredis.pc
|
15
|
+
SSL_LIBNAME=libhiredis_ssl
|
16
|
+
SSL_PKGCONFNAME=hiredis_ssl.pc
|
17
|
+
|
18
|
+
HIREDIS_MAJOR=$(shell grep HIREDIS_MAJOR hiredis.h | awk '{print $$3}')
|
19
|
+
HIREDIS_MINOR=$(shell grep HIREDIS_MINOR hiredis.h | awk '{print $$3}')
|
20
|
+
HIREDIS_PATCH=$(shell grep HIREDIS_PATCH hiredis.h | awk '{print $$3}')
|
21
|
+
HIREDIS_SONAME=$(shell grep HIREDIS_SONAME hiredis.h | awk '{print $$3}')
|
22
|
+
|
23
|
+
# Installation related variables and target
|
24
|
+
PREFIX?=/usr/local
|
25
|
+
INCLUDE_PATH?=include/hiredis
|
26
|
+
LIBRARY_PATH?=lib
|
27
|
+
PKGCONF_PATH?=pkgconfig
|
28
|
+
INSTALL_INCLUDE_PATH= $(DESTDIR)$(PREFIX)/$(INCLUDE_PATH)
|
29
|
+
INSTALL_LIBRARY_PATH= $(DESTDIR)$(PREFIX)/$(LIBRARY_PATH)
|
30
|
+
INSTALL_PKGCONF_PATH= $(INSTALL_LIBRARY_PATH)/$(PKGCONF_PATH)
|
31
|
+
|
32
|
+
# redis-server configuration used for testing
|
33
|
+
REDIS_PORT=56379
|
34
|
+
REDIS_SERVER=redis-server
|
35
|
+
define REDIS_TEST_CONFIG
|
36
|
+
daemonize yes
|
37
|
+
pidfile /tmp/hiredis-test-redis.pid
|
38
|
+
port $(REDIS_PORT)
|
39
|
+
bind 127.0.0.1
|
40
|
+
unixsocket /tmp/hiredis-test-redis.sock
|
41
|
+
endef
|
42
|
+
export REDIS_TEST_CONFIG
|
43
|
+
|
44
|
+
# Fallback to gcc when $CC is not in $PATH.
|
45
|
+
CC:=$(shell sh -c 'type $${CC%% *} >/dev/null 2>/dev/null && echo $(CC) || echo gcc')
|
46
|
+
CXX:=$(shell sh -c 'type $${CXX%% *} >/dev/null 2>/dev/null && echo $(CXX) || echo g++')
|
47
|
+
OPTIMIZATION?=-O3
|
48
|
+
WARNINGS=-Wall -W -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers
|
49
|
+
DEBUG_FLAGS?= -g -ggdb
|
50
|
+
REAL_CFLAGS=$(OPTIMIZATION) -fPIC $(CPPFLAGS) $(CFLAGS) $(WARNINGS) $(DEBUG_FLAGS)
|
51
|
+
REAL_LDFLAGS=$(LDFLAGS)
|
52
|
+
|
53
|
+
DYLIBSUFFIX=so
|
54
|
+
STLIBSUFFIX=a
|
55
|
+
DYLIB_MINOR_NAME=$(LIBNAME).$(DYLIBSUFFIX).$(HIREDIS_SONAME)
|
56
|
+
DYLIB_MAJOR_NAME=$(LIBNAME).$(DYLIBSUFFIX).$(HIREDIS_MAJOR)
|
57
|
+
DYLIBNAME=$(LIBNAME).$(DYLIBSUFFIX)
|
58
|
+
|
59
|
+
DYLIB_MAKE_CMD=$(CC) -shared -Wl,-soname,$(DYLIB_MINOR_NAME)
|
60
|
+
STLIBNAME=$(LIBNAME).$(STLIBSUFFIX)
|
61
|
+
STLIB_MAKE_CMD=$(AR) rcs
|
62
|
+
|
63
|
+
SSL_DYLIB_MINOR_NAME=$(SSL_LIBNAME).$(DYLIBSUFFIX).$(HIREDIS_SONAME)
|
64
|
+
SSL_DYLIB_MAJOR_NAME=$(SSL_LIBNAME).$(DYLIBSUFFIX).$(HIREDIS_MAJOR)
|
65
|
+
SSL_DYLIBNAME=$(SSL_LIBNAME).$(DYLIBSUFFIX)
|
66
|
+
SSL_STLIBNAME=$(SSL_LIBNAME).$(STLIBSUFFIX)
|
67
|
+
SSL_DYLIB_MAKE_CMD=$(CC) -shared -Wl,-soname,$(SSL_DYLIB_MINOR_NAME)
|
68
|
+
|
69
|
+
# Platform-specific overrides
|
70
|
+
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
|
71
|
+
|
72
|
+
USE_SSL?=0
|
73
|
+
|
74
|
+
# This is required for test.c only
|
75
|
+
ifeq ($(USE_SSL),1)
|
76
|
+
CFLAGS+=-DHIREDIS_TEST_SSL
|
77
|
+
endif
|
78
|
+
|
79
|
+
ifeq ($(uname_S),Linux)
|
80
|
+
SSL_LDFLAGS=-lssl -lcrypto
|
81
|
+
else
|
82
|
+
OPENSSL_PREFIX?=/usr/local/opt/openssl
|
83
|
+
CFLAGS+=-I$(OPENSSL_PREFIX)/include
|
84
|
+
SSL_LDFLAGS+=-L$(OPENSSL_PREFIX)/lib -lssl -lcrypto
|
85
|
+
endif
|
86
|
+
|
87
|
+
ifeq ($(uname_S),SunOS)
|
88
|
+
IS_SUN_CC=$(shell sh -c '$(CC) -V 2>&1 |egrep -i -c "sun|studio"')
|
89
|
+
ifeq ($(IS_SUN_CC),1)
|
90
|
+
SUN_SHARED_FLAG=-G
|
91
|
+
else
|
92
|
+
SUN_SHARED_FLAG=-shared
|
93
|
+
endif
|
94
|
+
REAL_LDFLAGS+= -ldl -lnsl -lsocket
|
95
|
+
DYLIB_MAKE_CMD=$(CC) $(SUN_SHARED_FLAG) -o $(DYLIBNAME) -h $(DYLIB_MINOR_NAME) $(LDFLAGS)
|
96
|
+
SSL_DYLIB_MAKE_CMD=$(CC) $(SUN_SHARED_FLAG) -o $(SSL_DYLIBNAME) -h $(SSL_DYLIB_MINOR_NAME) $(LDFLAGS) $(SSL_LDFLAGS)
|
97
|
+
endif
|
98
|
+
ifeq ($(uname_S),Darwin)
|
99
|
+
DYLIBSUFFIX=dylib
|
100
|
+
DYLIB_MINOR_NAME=$(LIBNAME).$(HIREDIS_SONAME).$(DYLIBSUFFIX)
|
101
|
+
DYLIB_MAKE_CMD=$(CC) -dynamiclib -Wl,-install_name,$(PREFIX)/$(LIBRARY_PATH)/$(DYLIB_MINOR_NAME) -o $(DYLIBNAME) $(LDFLAGS)
|
102
|
+
SSL_DYLIB_MAKE_CMD=$(CC) -dynamiclib -Wl,-install_name,$(PREFIX)/$(LIBRARY_PATH)/$(SSL_DYLIB_MINOR_NAME) -o $(SSL_DYLIBNAME) $(LDFLAGS) $(SSL_LDFLAGS)
|
103
|
+
DYLIB_PLUGIN=-Wl,-undefined -Wl,dynamic_lookup
|
104
|
+
endif
|
105
|
+
|
106
|
+
all: $(DYLIBNAME) $(STLIBNAME) hiredis-test $(PKGCONFNAME)
|
107
|
+
ifeq ($(USE_SSL),1)
|
108
|
+
all: $(SSL_DYLIBNAME) $(SSL_STLIBNAME) $(SSL_PKGCONFNAME)
|
109
|
+
endif
|
110
|
+
|
111
|
+
# Deps (use make dep to generate this)
|
112
|
+
alloc.o: alloc.c fmacros.h alloc.h
|
113
|
+
async.o: async.c fmacros.h alloc.h async.h hiredis.h read.h sds.h net.h dict.c dict.h win32.h async_private.h
|
114
|
+
dict.o: dict.c fmacros.h alloc.h dict.h
|
115
|
+
hiredis.o: hiredis.c fmacros.h hiredis.h read.h sds.h alloc.h net.h async.h win32.h
|
116
|
+
net.o: net.c fmacros.h net.h hiredis.h read.h sds.h alloc.h sockcompat.h win32.h
|
117
|
+
read.o: read.c fmacros.h alloc.h read.h sds.h win32.h
|
118
|
+
sds.o: sds.c sds.h sdsalloc.h alloc.h
|
119
|
+
sockcompat.o: sockcompat.c sockcompat.h
|
120
|
+
ssl.o: ssl.c hiredis.h read.h sds.h alloc.h async.h win32.h async_private.h
|
121
|
+
test.o: test.c fmacros.h hiredis.h read.h sds.h alloc.h net.h sockcompat.h win32.h
|
122
|
+
|
123
|
+
$(DYLIBNAME): $(OBJ)
|
124
|
+
$(DYLIB_MAKE_CMD) -o $(DYLIBNAME) $(OBJ) $(REAL_LDFLAGS)
|
125
|
+
|
126
|
+
$(STLIBNAME): $(OBJ)
|
127
|
+
$(STLIB_MAKE_CMD) $(STLIBNAME) $(OBJ)
|
128
|
+
|
129
|
+
$(SSL_DYLIBNAME): $(SSL_OBJ)
|
130
|
+
$(SSL_DYLIB_MAKE_CMD) $(DYLIB_PLUGIN) -o $(SSL_DYLIBNAME) $(SSL_OBJ) $(REAL_LDFLAGS) $(LDFLAGS) $(SSL_LDFLAGS)
|
131
|
+
|
132
|
+
$(SSL_STLIBNAME): $(SSL_OBJ)
|
133
|
+
$(STLIB_MAKE_CMD) $(SSL_STLIBNAME) $(SSL_OBJ)
|
134
|
+
|
135
|
+
dynamic: $(DYLIBNAME)
|
136
|
+
static: $(STLIBNAME)
|
137
|
+
ifeq ($(USE_SSL),1)
|
138
|
+
dynamic: $(SSL_DYLIBNAME)
|
139
|
+
static: $(SSL_STLIBNAME)
|
140
|
+
endif
|
141
|
+
|
142
|
+
# Binaries:
|
143
|
+
hiredis-example-libevent: examples/example-libevent.c adapters/libevent.h $(STLIBNAME)
|
144
|
+
$(CC) -o examples/$@ $(REAL_CFLAGS) -I. $< -levent $(STLIBNAME) $(REAL_LDFLAGS)
|
145
|
+
|
146
|
+
hiredis-example-libevent-ssl: examples/example-libevent-ssl.c adapters/libevent.h $(STLIBNAME) $(SSL_STLIBNAME)
|
147
|
+
$(CC) -o examples/$@ $(REAL_CFLAGS) -I. $< -levent $(STLIBNAME) $(SSL_STLIBNAME) $(REAL_LDFLAGS) $(SSL_LDFLAGS)
|
148
|
+
|
149
|
+
hiredis-example-libev: examples/example-libev.c adapters/libev.h $(STLIBNAME)
|
150
|
+
$(CC) -o examples/$@ $(REAL_CFLAGS) -I. $< -lev $(STLIBNAME) $(REAL_LDFLAGS)
|
151
|
+
|
152
|
+
hiredis-example-glib: examples/example-glib.c adapters/glib.h $(STLIBNAME)
|
153
|
+
$(CC) -o examples/$@ $(REAL_CFLAGS) -I. $< $(shell pkg-config --cflags --libs glib-2.0) $(STLIBNAME) $(REAL_LDFLAGS)
|
154
|
+
|
155
|
+
hiredis-example-ivykis: examples/example-ivykis.c adapters/ivykis.h $(STLIBNAME)
|
156
|
+
$(CC) -o examples/$@ $(REAL_CFLAGS) -I. $< -livykis $(STLIBNAME) $(REAL_LDFLAGS)
|
157
|
+
|
158
|
+
hiredis-example-macosx: examples/example-macosx.c adapters/macosx.h $(STLIBNAME)
|
159
|
+
$(CC) -o examples/$@ $(REAL_CFLAGS) -I. $< -framework CoreFoundation $(STLIBNAME) $(REAL_LDFLAGS)
|
160
|
+
|
161
|
+
hiredis-example-ssl: examples/example-ssl.c $(STLIBNAME) $(SSL_STLIBNAME)
|
162
|
+
$(CC) -o examples/$@ $(REAL_CFLAGS) -I. $< $(STLIBNAME) $(SSL_STLIBNAME) $(REAL_LDFLAGS) $(SSL_LDFLAGS)
|
163
|
+
|
164
|
+
|
165
|
+
ifndef AE_DIR
|
166
|
+
hiredis-example-ae:
|
167
|
+
@echo "Please specify AE_DIR (e.g. <redis repository>/src)"
|
168
|
+
@false
|
169
|
+
else
|
170
|
+
hiredis-example-ae: examples/example-ae.c adapters/ae.h $(STLIBNAME)
|
171
|
+
$(CC) -o examples/$@ $(REAL_CFLAGS) $(REAL_LDFLAGS) -I. -I$(AE_DIR) $< $(AE_DIR)/ae.o $(AE_DIR)/zmalloc.o $(AE_DIR)/../deps/jemalloc/lib/libjemalloc.a -pthread $(STLIBNAME)
|
172
|
+
endif
|
173
|
+
|
174
|
+
ifndef LIBUV_DIR
|
175
|
+
hiredis-example-libuv:
|
176
|
+
@echo "Please specify LIBUV_DIR (e.g. ../libuv/)"
|
177
|
+
@false
|
178
|
+
else
|
179
|
+
hiredis-example-libuv: examples/example-libuv.c adapters/libuv.h $(STLIBNAME)
|
180
|
+
$(CC) -o examples/$@ $(REAL_CFLAGS) -I. -I$(LIBUV_DIR)/include $< $(LIBUV_DIR)/.libs/libuv.a -lpthread -lrt $(STLIBNAME) $(REAL_LDFLAGS)
|
181
|
+
endif
|
182
|
+
|
183
|
+
ifeq ($(and $(QT_MOC),$(QT_INCLUDE_DIR),$(QT_LIBRARY_DIR)),)
|
184
|
+
hiredis-example-qt:
|
185
|
+
@echo "Please specify QT_MOC, QT_INCLUDE_DIR AND QT_LIBRARY_DIR"
|
186
|
+
@false
|
187
|
+
else
|
188
|
+
hiredis-example-qt: examples/example-qt.cpp adapters/qt.h $(STLIBNAME)
|
189
|
+
$(QT_MOC) adapters/qt.h -I. -I$(QT_INCLUDE_DIR) -I$(QT_INCLUDE_DIR)/QtCore | \
|
190
|
+
$(CXX) -x c++ -o qt-adapter-moc.o -c - $(REAL_CFLAGS) -I. -I$(QT_INCLUDE_DIR) -I$(QT_INCLUDE_DIR)/QtCore
|
191
|
+
$(QT_MOC) examples/example-qt.h -I. -I$(QT_INCLUDE_DIR) -I$(QT_INCLUDE_DIR)/QtCore | \
|
192
|
+
$(CXX) -x c++ -o qt-example-moc.o -c - $(REAL_CFLAGS) -I. -I$(QT_INCLUDE_DIR) -I$(QT_INCLUDE_DIR)/QtCore
|
193
|
+
$(CXX) -o examples/$@ $(REAL_CFLAGS) $(REAL_LDFLAGS) -I. -I$(QT_INCLUDE_DIR) -I$(QT_INCLUDE_DIR)/QtCore -L$(QT_LIBRARY_DIR) qt-adapter-moc.o qt-example-moc.o $< -pthread $(STLIBNAME) -lQtCore
|
194
|
+
endif
|
195
|
+
|
196
|
+
hiredis-example: examples/example.c $(STLIBNAME)
|
197
|
+
$(CC) -o examples/$@ $(REAL_CFLAGS) -I. $< $(STLIBNAME) $(REAL_LDFLAGS)
|
198
|
+
|
199
|
+
hiredis-example-push: examples/example-push.c $(STLIBNAME)
|
200
|
+
$(CC) -o examples/$@ $(REAL_CFLAGS) -I. $< $(STLIBNAME) $(REAL_LDFLAGS)
|
201
|
+
|
202
|
+
examples: $(EXAMPLES)
|
203
|
+
|
204
|
+
TEST_LIBS = $(STLIBNAME)
|
205
|
+
ifeq ($(USE_SSL),1)
|
206
|
+
TEST_LIBS += $(SSL_STLIBNAME)
|
207
|
+
TEST_LDFLAGS = $(SSL_LDFLAGS) -lssl -lcrypto -lpthread
|
208
|
+
endif
|
209
|
+
|
210
|
+
hiredis-test: test.o $(TEST_LIBS)
|
211
|
+
$(CC) -o $@ $(REAL_CFLAGS) -I. $^ $(REAL_LDFLAGS) $(TEST_LDFLAGS)
|
212
|
+
|
213
|
+
hiredis-%: %.o $(STLIBNAME)
|
214
|
+
$(CC) $(REAL_CFLAGS) -o $@ $< $(TEST_LIBS) $(REAL_LDFLAGS)
|
215
|
+
|
216
|
+
test: hiredis-test
|
217
|
+
./hiredis-test
|
218
|
+
|
219
|
+
check: hiredis-test
|
220
|
+
TEST_SSL=$(USE_SSL) ./test.sh
|
221
|
+
|
222
|
+
.c.o:
|
223
|
+
$(CC) -std=c99 -pedantic -c $(REAL_CFLAGS) $<
|
224
|
+
|
225
|
+
clean:
|
226
|
+
rm -rf $(DYLIBNAME) $(STLIBNAME) $(SSL_DYLIBNAME) $(SSL_STLIBNAME) $(TESTS) $(PKGCONFNAME) examples/hiredis-example* *.o *.gcda *.gcno *.gcov
|
227
|
+
|
228
|
+
dep:
|
229
|
+
$(CC) $(CPPFLAGS) $(CFLAGS) -MM *.c
|
230
|
+
|
231
|
+
INSTALL?= cp -pPR
|
232
|
+
|
233
|
+
$(PKGCONFNAME): hiredis.h
|
234
|
+
@echo "Generating $@ for pkgconfig..."
|
235
|
+
@echo prefix=$(PREFIX) > $@
|
236
|
+
@echo exec_prefix=\$${prefix} >> $@
|
237
|
+
@echo libdir=$(PREFIX)/$(LIBRARY_PATH) >> $@
|
238
|
+
@echo includedir=$(PREFIX)/$(INCLUDE_PATH) >> $@
|
239
|
+
@echo >> $@
|
240
|
+
@echo Name: hiredis >> $@
|
241
|
+
@echo Description: Minimalistic C client library for Redis. >> $@
|
242
|
+
@echo Version: $(HIREDIS_MAJOR).$(HIREDIS_MINOR).$(HIREDIS_PATCH) >> $@
|
243
|
+
@echo Libs: -L\$${libdir} -lhiredis >> $@
|
244
|
+
@echo Cflags: -I\$${includedir} -D_FILE_OFFSET_BITS=64 >> $@
|
245
|
+
|
246
|
+
$(SSL_PKGCONFNAME): hiredis_ssl.h
|
247
|
+
@echo "Generating $@ for pkgconfig..."
|
248
|
+
@echo prefix=$(PREFIX) > $@
|
249
|
+
@echo exec_prefix=\$${prefix} >> $@
|
250
|
+
@echo libdir=$(PREFIX)/$(LIBRARY_PATH) >> $@
|
251
|
+
@echo includedir=$(PREFIX)/$(INCLUDE_PATH) >> $@
|
252
|
+
@echo >> $@
|
253
|
+
@echo Name: hiredis_ssl >> $@
|
254
|
+
@echo Description: SSL Support for hiredis. >> $@
|
255
|
+
@echo Version: $(HIREDIS_MAJOR).$(HIREDIS_MINOR).$(HIREDIS_PATCH) >> $@
|
256
|
+
@echo Requires: hiredis >> $@
|
257
|
+
@echo Libs: -L\$${libdir} -lhiredis_ssl >> $@
|
258
|
+
@echo Libs.private: -lssl -lcrypto >> $@
|
259
|
+
|
260
|
+
install: $(DYLIBNAME) $(STLIBNAME) $(PKGCONFNAME)
|
261
|
+
mkdir -p $(INSTALL_INCLUDE_PATH) $(INSTALL_INCLUDE_PATH)/adapters $(INSTALL_LIBRARY_PATH)
|
262
|
+
$(INSTALL) hiredis.h async.h read.h sds.h alloc.h $(INSTALL_INCLUDE_PATH)
|
263
|
+
$(INSTALL) adapters/*.h $(INSTALL_INCLUDE_PATH)/adapters
|
264
|
+
$(INSTALL) $(DYLIBNAME) $(INSTALL_LIBRARY_PATH)/$(DYLIB_MINOR_NAME)
|
265
|
+
cd $(INSTALL_LIBRARY_PATH) && ln -sf $(DYLIB_MINOR_NAME) $(DYLIBNAME)
|
266
|
+
$(INSTALL) $(STLIBNAME) $(INSTALL_LIBRARY_PATH)
|
267
|
+
mkdir -p $(INSTALL_PKGCONF_PATH)
|
268
|
+
$(INSTALL) $(PKGCONFNAME) $(INSTALL_PKGCONF_PATH)
|
269
|
+
|
270
|
+
ifeq ($(USE_SSL),1)
|
271
|
+
install: install-ssl
|
272
|
+
|
273
|
+
install-ssl: $(SSL_DYLIBNAME) $(SSL_STLIBNAME) $(SSL_PKGCONFNAME)
|
274
|
+
mkdir -p $(INSTALL_INCLUDE_PATH) $(INSTALL_LIBRARY_PATH)
|
275
|
+
$(INSTALL) hiredis_ssl.h $(INSTALL_INCLUDE_PATH)
|
276
|
+
$(INSTALL) $(SSL_DYLIBNAME) $(INSTALL_LIBRARY_PATH)/$(SSL_DYLIB_MINOR_NAME)
|
277
|
+
cd $(INSTALL_LIBRARY_PATH) && ln -sf $(SSL_DYLIB_MINOR_NAME) $(SSL_DYLIBNAME)
|
278
|
+
$(INSTALL) $(SSL_STLIBNAME) $(INSTALL_LIBRARY_PATH)
|
279
|
+
mkdir -p $(INSTALL_PKGCONF_PATH)
|
280
|
+
$(INSTALL) $(SSL_PKGCONFNAME) $(INSTALL_PKGCONF_PATH)
|
281
|
+
endif
|
282
|
+
|
283
|
+
32bit:
|
284
|
+
@echo ""
|
285
|
+
@echo "WARNING: if this fails under Linux you probably need to install libc6-dev-i386"
|
286
|
+
@echo ""
|
287
|
+
$(MAKE) CFLAGS="-m32" LDFLAGS="-m32"
|
288
|
+
|
289
|
+
32bit-vars:
|
290
|
+
$(eval CFLAGS=-m32)
|
291
|
+
$(eval LDFLAGS=-m32)
|
292
|
+
|
293
|
+
gprof:
|
294
|
+
$(MAKE) CFLAGS="-pg" LDFLAGS="-pg"
|
295
|
+
|
296
|
+
gcov:
|
297
|
+
$(MAKE) CFLAGS="-fprofile-arcs -ftest-coverage" LDFLAGS="-fprofile-arcs"
|
298
|
+
|
299
|
+
coverage: gcov
|
300
|
+
make check
|
301
|
+
mkdir -p tmp/lcov
|
302
|
+
lcov -d . -c -o tmp/lcov/hiredis.info
|
303
|
+
genhtml --legend -o tmp/lcov/report tmp/lcov/hiredis.info
|
304
|
+
|
305
|
+
noopt:
|
306
|
+
$(MAKE) OPTIMIZATION=""
|
307
|
+
|
308
|
+
.PHONY: all test check clean dep install 32bit 32bit-vars gprof gcov noopt
|