2009-03-22 10:30:00 +01:00
|
|
|
# Redis Makefile
|
|
|
|
# Copyright (C) 2009 Salvatore Sanfilippo <antirez at gmail dot com>
|
|
|
|
# This file is released under the BSD license, see the COPYING file
|
2012-04-12 11:09:38 +02:00
|
|
|
#
|
2012-04-13 17:34:31 -07:00
|
|
|
# The Makefile composes the final FINAL_CFLAGS and FINAL_LDFLAGS using
|
2012-04-12 11:09:38 +02:00
|
|
|
# what is needed for Redis plus the standard CFLAGS and LDFLAGS passed.
|
|
|
|
# However when building the dependencies (Jemalloc, Lua, Hiredis, ...)
|
|
|
|
# CFLAGS and LDFLAGS are propagated to the dependencies, so to pass
|
2012-04-13 17:34:31 -07:00
|
|
|
# flags only to be used when compiling / linking Redis itself REDIS_CFLAGS
|
|
|
|
# and REDIS_LDFLAGS are used instead (this is the case of 'make gcov').
|
2012-04-12 11:09:38 +02:00
|
|
|
#
|
|
|
|
# Dependencies are stored in the Makefile.dep file. To rebuild this file
|
|
|
|
# Just use 'make dep', but this is only needed by developers.
|
2009-03-22 10:30:00 +01:00
|
|
|
|
2010-05-18 00:36:48 +02:00
|
|
|
release_hdr := $(shell sh -c './mkreleasehdr.sh')
|
2009-10-26 16:25:07 +01:00
|
|
|
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
|
2017-02-19 14:59:39 +00:00
|
|
|
uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
|
2015-06-22 17:28:48 +02:00
|
|
|
OPTIMIZATION?=-O2
|
2016-07-06 16:02:38 +02:00
|
|
|
DEPENDENCY_TARGETS=hiredis linenoise lua
|
2016-07-06 12:56:43 +02:00
|
|
|
NODEPS:=clean distclean
|
2011-10-30 03:20:00 +00:00
|
|
|
|
2012-04-13 17:43:06 -07:00
|
|
|
# Default settings
|
2019-05-07 13:35:27 +08:00
|
|
|
STD=-std=c11 -pedantic -DREDIS_STATIC=''
|
2018-11-08 10:13:52 +00:00
|
|
|
ifneq (,$(findstring clang,$(CC)))
|
|
|
|
ifneq (,$(findstring FreeBSD,$(uname_S)))
|
|
|
|
STD+=-Wno-c11-extensions
|
|
|
|
endif
|
2018-10-30 13:23:43 +00:00
|
|
|
endif
|
2016-07-06 16:02:38 +02:00
|
|
|
WARN=-Wall -W -Wno-missing-field-initializers
|
2013-03-16 18:44:38 +11:00
|
|
|
OPT=$(OPTIMIZATION)
|
2012-03-24 19:25:03 -07:00
|
|
|
|
2013-03-20 22:05:59 +11:00
|
|
|
PREFIX?=/usr/local
|
|
|
|
INSTALL_BIN=$(PREFIX)/bin
|
|
|
|
INSTALL=install
|
Auto-detect and link libsystemd at compile-time
This adds Makefile/build-system support for USE_SYSTEMD=(yes|no|*). This
variable's value determines whether or not libsystemd will be linked at
build-time.
If USE_SYSTEMD is set to "yes", make will use PKG_CONFIG to check for
libsystemd's presence, and fail the build early if it isn't
installed/detected properly.
If USE_SYSTEM is set to "no", libsystemd will *not* be linked, even if
support for it is available on the system redis is being built on.
For any other value that USE_SYSTEM might assume (e.g. "auto"),
PKG_CONFIG will try to determine libsystemd's presence, and set up the
build process to link against it, if it was indicated as being
installed/available.
This approach has a number of repercussions of its own, most importantly
the following: If you build redis on a system that actually has systemd
support, but no libsystemd-dev package(s) installed, you'll end up
*without* support for systemd notification/status reporting support in
redis-server. This changes established runtime behaviour.
I'm not sure if the build system and/or the server binary should
indicate this. I'm also wondering if not actually having
systemd-notify-support, but requesting it via the server's config,
should result in a fatal error now.
2019-05-30 18:44:17 +02:00
|
|
|
PKG_CONFIG?=pkg-config
|
2013-03-20 22:05:59 +11:00
|
|
|
|
2017-02-19 15:02:37 +00:00
|
|
|
# Default allocator defaults to Jemalloc if it's not an ARM
|
|
|
|
MALLOC=libc
|
|
|
|
ifneq ($(uname_M),armv6l)
|
|
|
|
ifneq ($(uname_M),armv7l)
|
2011-11-15 13:09:31 -08:00
|
|
|
ifeq ($(uname_S),Linux)
|
2013-03-16 18:35:20 +11:00
|
|
|
MALLOC=jemalloc
|
2017-02-19 15:02:37 +00:00
|
|
|
endif
|
|
|
|
endif
|
2011-11-15 13:09:31 -08:00
|
|
|
endif
|
|
|
|
|
2017-06-26 10:36:12 +02:00
|
|
|
# To get ARM stack traces if Redis crashes we need a special C flag.
|
2017-07-03 07:18:32 +00:00
|
|
|
ifneq (,$(filter aarch64 armv,$(uname_M)))
|
2017-06-26 10:36:12 +02:00
|
|
|
CFLAGS+=-funwind-tables
|
2018-10-19 10:39:57 +02:00
|
|
|
else
|
|
|
|
ifneq (,$(findstring armv,$(uname_M)))
|
|
|
|
CFLAGS+=-funwind-tables
|
|
|
|
endif
|
2017-06-26 10:36:12 +02:00
|
|
|
endif
|
|
|
|
|
2011-11-15 13:09:31 -08:00
|
|
|
# Backwards compatibility for selecting an allocator
|
2010-10-22 00:06:44 +02:00
|
|
|
ifeq ($(USE_TCMALLOC),yes)
|
2013-03-16 18:35:20 +11:00
|
|
|
MALLOC=tcmalloc
|
2011-11-15 13:09:31 -08:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(USE_TCMALLOC_MINIMAL),yes)
|
2013-03-16 18:35:20 +11:00
|
|
|
MALLOC=tcmalloc_minimal
|
2011-11-15 13:09:31 -08:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(USE_JEMALLOC),yes)
|
2013-03-16 18:35:20 +11:00
|
|
|
MALLOC=jemalloc
|
2011-11-15 13:09:31 -08:00
|
|
|
endif
|
|
|
|
|
2014-11-13 15:12:08 -05:00
|
|
|
ifeq ($(USE_JEMALLOC),no)
|
|
|
|
MALLOC=libc
|
|
|
|
endif
|
|
|
|
|
2012-04-13 17:50:38 -07:00
|
|
|
# Override default settings if possible
|
|
|
|
-include .make-settings
|
|
|
|
|
2016-07-06 16:02:38 +02:00
|
|
|
FINAL_CFLAGS=$(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS) $(REDIS_CFLAGS)
|
2013-03-16 18:33:42 +11:00
|
|
|
FINAL_LDFLAGS=$(LDFLAGS) $(REDIS_LDFLAGS) $(DEBUG)
|
2016-06-14 13:46:42 +00:00
|
|
|
FINAL_LIBS=-lm
|
2013-03-16 18:33:42 +11:00
|
|
|
DEBUG=-g -ggdb
|
|
|
|
|
2019-11-29 17:35:59 +01:00
|
|
|
# Linux ARM needs -latomic at linking time
|
|
|
|
ifneq (,$(filter aarch64 armv,$(uname_M)))
|
|
|
|
FINAL_LIBS+=-latomic
|
|
|
|
else
|
|
|
|
ifneq (,$(findstring armv,$(uname_M)))
|
|
|
|
FINAL_LIBS+=-latomic
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2012-04-13 17:43:06 -07:00
|
|
|
ifeq ($(uname_S),SunOS)
|
2013-12-12 15:19:08 +01:00
|
|
|
# SunOS
|
2017-02-24 00:00:13 +08:00
|
|
|
ifneq ($(@@),32bit)
|
|
|
|
CFLAGS+= -m64
|
|
|
|
LDFLAGS+= -m64
|
|
|
|
endif
|
|
|
|
DEBUG=-g
|
|
|
|
DEBUG_FLAGS=-g
|
|
|
|
export CFLAGS LDFLAGS DEBUG DEBUG_FLAGS
|
2013-03-20 22:05:59 +11:00
|
|
|
INSTALL=cp -pf
|
2013-03-16 18:33:42 +11:00
|
|
|
FINAL_CFLAGS+= -D__EXTENSIONS__ -D_XPG6
|
2015-01-09 11:53:47 +01:00
|
|
|
FINAL_LIBS+= -ldl -lnsl -lsocket -lresolv -lpthread -lrt
|
2012-04-13 17:43:06 -07:00
|
|
|
else
|
2013-12-12 15:19:08 +01:00
|
|
|
ifeq ($(uname_S),Darwin)
|
2016-06-14 13:46:42 +00:00
|
|
|
# Darwin
|
|
|
|
FINAL_LIBS+= -ldl
|
2019-09-12 11:10:22 +03:00
|
|
|
OPENSSL_CFLAGS=-I/usr/local/opt/openssl/include
|
|
|
|
OPENSSL_LDFLAGS=-L/usr/local/opt/openssl/lib
|
2014-07-29 16:39:37 -05:00
|
|
|
else
|
|
|
|
ifeq ($(uname_S),AIX)
|
|
|
|
# AIX
|
|
|
|
FINAL_LDFLAGS+= -Wl,-bexpall
|
2016-06-14 13:46:42 +00:00
|
|
|
FINAL_LIBS+=-ldl -pthread -lcrypt -lbsd
|
|
|
|
else
|
|
|
|
ifeq ($(uname_S),OpenBSD)
|
|
|
|
# OpenBSD
|
|
|
|
FINAL_LIBS+= -lpthread
|
2018-11-25 08:10:26 +00:00
|
|
|
ifeq ($(USE_BACKTRACE),yes)
|
|
|
|
FINAL_CFLAGS+= -DUSE_BACKTRACE -I/usr/local/include
|
|
|
|
FINAL_LDFLAGS+= -L/usr/local/lib
|
|
|
|
FINAL_LIBS+= -lexecinfo
|
|
|
|
endif
|
|
|
|
|
2016-06-14 13:46:42 +00:00
|
|
|
else
|
|
|
|
ifeq ($(uname_S),FreeBSD)
|
|
|
|
# FreeBSD
|
2018-11-24 15:49:45 +00:00
|
|
|
FINAL_LIBS+= -lpthread -lexecinfo
|
2018-11-11 18:49:55 +00:00
|
|
|
else
|
|
|
|
ifeq ($(uname_S),DragonFly)
|
|
|
|
# FreeBSD
|
2018-11-24 15:49:45 +00:00
|
|
|
FINAL_LIBS+= -lpthread -lexecinfo
|
2013-12-12 15:19:08 +01:00
|
|
|
else
|
|
|
|
# All the other OSes (notably Linux)
|
2013-03-16 18:33:42 +11:00
|
|
|
FINAL_LDFLAGS+= -rdynamic
|
2018-05-25 20:16:57 +08:00
|
|
|
FINAL_LIBS+=-ldl -pthread -lrt
|
2016-06-14 13:46:42 +00:00
|
|
|
endif
|
|
|
|
endif
|
2012-04-13 17:43:06 -07:00
|
|
|
endif
|
2013-12-12 15:19:08 +01:00
|
|
|
endif
|
2014-07-29 16:39:37 -05:00
|
|
|
endif
|
2018-11-11 18:49:55 +00:00
|
|
|
endif
|
2012-04-13 17:43:06 -07:00
|
|
|
# Include paths to dependencies
|
|
|
|
FINAL_CFLAGS+= -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src
|
|
|
|
|
Auto-detect and link libsystemd at compile-time
This adds Makefile/build-system support for USE_SYSTEMD=(yes|no|*). This
variable's value determines whether or not libsystemd will be linked at
build-time.
If USE_SYSTEMD is set to "yes", make will use PKG_CONFIG to check for
libsystemd's presence, and fail the build early if it isn't
installed/detected properly.
If USE_SYSTEM is set to "no", libsystemd will *not* be linked, even if
support for it is available on the system redis is being built on.
For any other value that USE_SYSTEM might assume (e.g. "auto"),
PKG_CONFIG will try to determine libsystemd's presence, and set up the
build process to link against it, if it was indicated as being
installed/available.
This approach has a number of repercussions of its own, most importantly
the following: If you build redis on a system that actually has systemd
support, but no libsystemd-dev package(s) installed, you'll end up
*without* support for systemd notification/status reporting support in
redis-server. This changes established runtime behaviour.
I'm not sure if the build system and/or the server binary should
indicate this. I'm also wondering if not actually having
systemd-notify-support, but requesting it via the server's config,
should result in a fatal error now.
2019-05-30 18:44:17 +02:00
|
|
|
# Determine systemd support and/or build preference (defaulting to auto-detection)
|
|
|
|
BUILD_WITH_SYSTEMD=no
|
|
|
|
# If 'USE_SYSTEMD' in the environment is neither "no" nor "yes", try to
|
|
|
|
# auto-detect libsystemd's presence and link accordingly.
|
|
|
|
ifneq ($(USE_SYSTEMD),no)
|
|
|
|
LIBSYSTEMD_PKGCONFIG := $(shell $(PKG_CONFIG) --exists libsystemd && echo $$?)
|
|
|
|
# If libsystemd cannot be detected, continue building without support for it
|
|
|
|
# (unless a later check tells us otherwise)
|
|
|
|
ifeq ($(LIBSYSTEMD_PKGCONFIG),0)
|
|
|
|
BUILD_WITH_SYSTEMD=yes
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
ifeq ($(USE_SYSTEMD),yes)
|
|
|
|
ifneq ($(LIBSYSTEMD_PKGCONFIG),0)
|
|
|
|
$(error USE_SYSTEMD is set to "$(USE_SYSTEMD)", but $(PKG_CONFIG) cannot find libsystemd)
|
|
|
|
endif
|
|
|
|
# Force building with libsystemd
|
|
|
|
BUILD_WITH_SYSTEMD=yes
|
|
|
|
endif
|
|
|
|
ifeq ($(BUILD_WITH_SYSTEMD),yes)
|
|
|
|
FINAL_LIBS+=$(shell $(PKG_CONFIG) --libs libsystemd)
|
|
|
|
FINAL_CFLAGS+= -DHAVE_LIBSYSTEMD
|
|
|
|
endif
|
|
|
|
|
2011-11-15 13:09:31 -08:00
|
|
|
ifeq ($(MALLOC),tcmalloc)
|
2013-03-16 18:35:20 +11:00
|
|
|
FINAL_CFLAGS+= -DUSE_TCMALLOC
|
|
|
|
FINAL_LIBS+= -ltcmalloc
|
2010-10-22 00:06:44 +02:00
|
|
|
endif
|
2011-04-19 23:54:43 +02:00
|
|
|
|
2011-11-15 13:09:31 -08:00
|
|
|
ifeq ($(MALLOC),tcmalloc_minimal)
|
2013-03-16 18:35:20 +11:00
|
|
|
FINAL_CFLAGS+= -DUSE_TCMALLOC
|
|
|
|
FINAL_LIBS+= -ltcmalloc_minimal
|
2011-04-19 23:54:43 +02:00
|
|
|
endif
|
|
|
|
|
2011-11-15 13:09:31 -08:00
|
|
|
ifeq ($(MALLOC),jemalloc)
|
2013-03-16 18:35:20 +11:00
|
|
|
DEPENDENCY_TARGETS+= jemalloc
|
|
|
|
FINAL_CFLAGS+= -DUSE_JEMALLOC -I../deps/jemalloc/include
|
2018-05-25 13:36:51 +02:00
|
|
|
FINAL_LIBS := ../deps/jemalloc/lib/libjemalloc.a $(FINAL_LIBS)
|
2011-04-19 23:54:43 +02:00
|
|
|
endif
|
|
|
|
|
2019-09-12 10:56:54 +03:00
|
|
|
ifeq ($(BUILD_TLS),yes)
|
|
|
|
FINAL_CFLAGS+=-DUSE_OPENSSL $(OPENSSL_CFLAGS)
|
|
|
|
FINAL_LDFLAGS+=$(OPENSSL_LDFLAGS)
|
|
|
|
FINAL_LIBS += ../deps/hiredis/libhiredis_ssl.a -lssl -lcrypto
|
|
|
|
endif
|
|
|
|
|
2012-04-13 17:34:31 -07:00
|
|
|
REDIS_CC=$(QUIET_CC)$(CC) $(FINAL_CFLAGS)
|
|
|
|
REDIS_LD=$(QUIET_LINK)$(CC) $(FINAL_LDFLAGS)
|
2012-07-23 12:54:52 +02:00
|
|
|
REDIS_INSTALL=$(QUIET_INSTALL)$(INSTALL)
|
2009-03-22 10:30:00 +01:00
|
|
|
|
2011-05-04 10:17:05 +02:00
|
|
|
CCCOLOR="\033[34m"
|
|
|
|
LINKCOLOR="\033[34;1m"
|
|
|
|
SRCCOLOR="\033[33m"
|
|
|
|
BINCOLOR="\033[37;1m"
|
|
|
|
MAKECOLOR="\033[32;1m"
|
|
|
|
ENDCOLOR="\033[0m"
|
|
|
|
|
2011-06-08 17:09:18 +02:00
|
|
|
ifndef V
|
2012-03-24 19:25:03 -07:00
|
|
|
QUIET_CC = @printf ' %b %b\n' $(CCCOLOR)CC$(ENDCOLOR) $(SRCCOLOR)$@$(ENDCOLOR) 1>&2;
|
|
|
|
QUIET_LINK = @printf ' %b %b\n' $(LINKCOLOR)LINK$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR) 1>&2;
|
2012-07-23 12:54:52 +02:00
|
|
|
QUIET_INSTALL = @printf ' %b %b\n' $(LINKCOLOR)INSTALL$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR) 1>&2;
|
2011-06-08 17:09:18 +02:00
|
|
|
endif
|
|
|
|
|
2013-03-16 18:44:38 +11:00
|
|
|
REDIS_SERVER_NAME=redis-server
|
|
|
|
REDIS_SENTINEL_NAME=redis-sentinel
|
Support setcpuaffinity on linux/bsd
Currently, there are several types of threads/child processes of a
redis server. Sometimes we need deeply optimise the performance of
redis, so we would like to isolate threads/processes.
There were some discussion about cpu affinity cases in the issue:
https://github.com/antirez/redis/issues/2863
So implement cpu affinity setting by redis.conf in this patch, then
we can config server_cpulist/bio_cpulist/aof_rewrite_cpulist/
bgsave_cpulist by cpu list.
Examples of cpulist in redis.conf:
server_cpulist 0-7:2 means cpu affinity 0,2,4,6
bio_cpulist 1,3 means cpu affinity 1,3
aof_rewrite_cpulist 8-11 means cpu affinity 8,9,10,11
bgsave_cpulist 1,10-11 means cpu affinity 1,10,11
Test on linux/freebsd, both work fine.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2020-05-02 20:05:39 +08:00
|
|
|
REDIS_SERVER_OBJ=adlist.o quicklist.o ae.o anet.o dict.o server.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o ziplist.o release.o networking.o util.o object.o db.o replication.o rdb.o t_string.o t_list.o t_set.o t_zset.o t_hash.o config.o aof.o pubsub.o multi.o debug.o sort.o intset.o syncio.o cluster.o crc16.o endianconv.o slowlog.o scripting.o bio.o rio.o rand.o memtest.o crcspeed.o crc64.o bitops.o sentinel.o notify.o setproctitle.o blocked.o hyperloglog.o latency.o sparkline.o redis-check-rdb.o redis-check-aof.o geo.o lazyfree.o module.o evict.o expire.o geohash.o geohash_helper.o childinfo.o defrag.o siphash.o rax.o t_stream.o listpack.o localtime.o lolwut.o lolwut5.o lolwut6.o acl.o gopher.o tracking.o connection.o tls.o sha256.o timeout.o setcpuaffinity.o
|
2013-03-16 18:44:38 +11:00
|
|
|
REDIS_CLI_NAME=redis-cli
|
2020-04-24 16:59:24 -07:00
|
|
|
REDIS_CLI_OBJ=anet.o adlist.o dict.o redis-cli.o zmalloc.o release.o ae.o crcspeed.o crc64.o siphash.o crc16.o
|
2013-03-16 18:44:38 +11:00
|
|
|
REDIS_BENCHMARK_NAME=redis-benchmark
|
2020-03-12 11:12:37 +08:00
|
|
|
REDIS_BENCHMARK_OBJ=ae.o anet.o redis-benchmark.o adlist.o dict.o zmalloc.o siphash.o
|
2014-05-09 12:06:06 -04:00
|
|
|
REDIS_CHECK_RDB_NAME=redis-check-rdb
|
2013-03-16 18:44:38 +11:00
|
|
|
REDIS_CHECK_AOF_NAME=redis-check-aof
|
2012-04-12 11:09:38 +02:00
|
|
|
|
2014-05-09 12:06:06 -04:00
|
|
|
all: $(REDIS_SERVER_NAME) $(REDIS_SENTINEL_NAME) $(REDIS_CLI_NAME) $(REDIS_BENCHMARK_NAME) $(REDIS_CHECK_RDB_NAME) $(REDIS_CHECK_AOF_NAME)
|
2010-12-15 12:40:23 +01:00
|
|
|
@echo ""
|
2014-03-16 20:22:36 -07:00
|
|
|
@echo "Hint: It's a good idea to run 'make test' ;)"
|
2010-12-15 12:40:23 +01:00
|
|
|
@echo ""
|
2009-03-22 10:30:00 +01:00
|
|
|
|
2016-07-06 12:24:45 +02:00
|
|
|
Makefile.dep:
|
|
|
|
-$(REDIS_CC) -MM *.c > Makefile.dep 2> /dev/null || true
|
2011-06-20 11:52:15 +02:00
|
|
|
|
2016-07-06 12:56:43 +02:00
|
|
|
ifeq (0, $(words $(findstring $(MAKECMDGOALS), $(NODEPS))))
|
2016-07-06 12:24:45 +02:00
|
|
|
-include Makefile.dep
|
2016-07-06 12:56:43 +02:00
|
|
|
endif
|
2011-11-15 13:09:31 -08:00
|
|
|
|
2016-07-06 12:24:45 +02:00
|
|
|
.PHONY: all
|
2011-11-15 13:09:31 -08:00
|
|
|
|
2012-04-13 17:50:38 -07:00
|
|
|
persist-settings: distclean
|
|
|
|
echo STD=$(STD) >> .make-settings
|
|
|
|
echo WARN=$(WARN) >> .make-settings
|
|
|
|
echo OPT=$(OPT) >> .make-settings
|
|
|
|
echo MALLOC=$(MALLOC) >> .make-settings
|
|
|
|
echo CFLAGS=$(CFLAGS) >> .make-settings
|
|
|
|
echo LDFLAGS=$(LDFLAGS) >> .make-settings
|
|
|
|
echo REDIS_CFLAGS=$(REDIS_CFLAGS) >> .make-settings
|
|
|
|
echo REDIS_LDFLAGS=$(REDIS_LDFLAGS) >> .make-settings
|
|
|
|
echo PREV_FINAL_CFLAGS=$(FINAL_CFLAGS) >> .make-settings
|
|
|
|
echo PREV_FINAL_LDFLAGS=$(FINAL_LDFLAGS) >> .make-settings
|
|
|
|
-(cd ../deps && $(MAKE) $(DEPENDENCY_TARGETS))
|
|
|
|
|
|
|
|
.PHONY: persist-settings
|
|
|
|
|
2012-03-24 19:25:03 -07:00
|
|
|
# Prerequisites target
|
|
|
|
.make-prerequisites:
|
2011-11-16 08:34:42 -08:00
|
|
|
@touch $@
|
2011-11-15 13:09:31 -08:00
|
|
|
|
2012-04-13 17:50:38 -07:00
|
|
|
# Clean everything, persist settings and build dependencies if anything changed
|
|
|
|
ifneq ($(strip $(PREV_FINAL_CFLAGS)), $(strip $(FINAL_CFLAGS)))
|
|
|
|
.make-prerequisites: persist-settings
|
2012-03-24 19:25:03 -07:00
|
|
|
endif
|
|
|
|
|
2012-04-13 17:50:38 -07:00
|
|
|
ifneq ($(strip $(PREV_FINAL_LDFLAGS)), $(strip $(FINAL_LDFLAGS)))
|
|
|
|
.make-prerequisites: persist-settings
|
2012-03-24 19:25:03 -07:00
|
|
|
endif
|
2010-11-04 13:37:05 +01:00
|
|
|
|
2012-03-24 19:25:03 -07:00
|
|
|
# redis-server
|
2012-04-13 16:13:56 +02:00
|
|
|
$(REDIS_SERVER_NAME): $(REDIS_SERVER_OBJ)
|
2016-07-06 16:02:38 +02:00
|
|
|
$(REDIS_LD) -o $@ $^ ../deps/hiredis/libhiredis.a ../deps/lua/src/liblua.a $(FINAL_LIBS)
|
2012-07-23 12:54:52 +02:00
|
|
|
|
|
|
|
# redis-sentinel
|
|
|
|
$(REDIS_SENTINEL_NAME): $(REDIS_SERVER_NAME)
|
|
|
|
$(REDIS_INSTALL) $(REDIS_SERVER_NAME) $(REDIS_SENTINEL_NAME)
|
2009-03-22 10:30:00 +01:00
|
|
|
|
2014-05-09 12:06:06 -04:00
|
|
|
# redis-check-rdb
|
|
|
|
$(REDIS_CHECK_RDB_NAME): $(REDIS_SERVER_NAME)
|
|
|
|
$(REDIS_INSTALL) $(REDIS_SERVER_NAME) $(REDIS_CHECK_RDB_NAME)
|
|
|
|
|
2017-07-10 13:38:23 +02:00
|
|
|
# redis-check-aof
|
|
|
|
$(REDIS_CHECK_AOF_NAME): $(REDIS_SERVER_NAME)
|
|
|
|
$(REDIS_INSTALL) $(REDIS_SERVER_NAME) $(REDIS_CHECK_AOF_NAME)
|
|
|
|
|
2012-03-24 19:25:03 -07:00
|
|
|
# redis-cli
|
2012-04-12 11:09:38 +02:00
|
|
|
$(REDIS_CLI_NAME): $(REDIS_CLI_OBJ)
|
2012-04-13 17:34:31 -07:00
|
|
|
$(REDIS_LD) -o $@ $^ ../deps/hiredis/libhiredis.a ../deps/linenoise/linenoise.o $(FINAL_LIBS)
|
2010-11-03 16:09:38 +01:00
|
|
|
|
2012-03-24 19:25:03 -07:00
|
|
|
# redis-benchmark
|
2012-04-12 11:09:38 +02:00
|
|
|
$(REDIS_BENCHMARK_NAME): $(REDIS_BENCHMARK_OBJ)
|
2012-04-13 17:34:31 -07:00
|
|
|
$(REDIS_LD) -o $@ $^ ../deps/hiredis/libhiredis.a $(FINAL_LIBS)
|
2009-03-22 10:30:00 +01:00
|
|
|
|
2017-04-17 13:37:59 +02:00
|
|
|
dict-benchmark: dict.c zmalloc.c sds.c siphash.c
|
|
|
|
$(REDIS_CC) $(FINAL_CFLAGS) $^ -D DICT_BENCHMARK_MAIN -o $@ $(FINAL_LIBS)
|
2016-09-07 10:32:57 +02:00
|
|
|
|
2020-01-01 10:33:02 -05:00
|
|
|
DEP = $(REDIS_SERVER_OBJ:%.o=%.d) $(REDIS_CLI_OBJ:%.o=%.d) $(REDIS_BENCHMARK_OBJ:%.o=%.d)
|
|
|
|
-include $(DEP)
|
|
|
|
|
2012-03-24 19:25:03 -07:00
|
|
|
# Because the jemalloc.h header is generated as a part of the jemalloc build,
|
|
|
|
# building it should complete before building any other object. Instead of
|
|
|
|
# depending on a single artifact, build all dependencies first.
|
2011-11-16 08:34:42 -08:00
|
|
|
%.o: %.c .make-prerequisites
|
2020-01-01 10:33:02 -05:00
|
|
|
$(REDIS_CC) -MMD -o $@ -c $<
|
2011-11-15 12:40:49 -08:00
|
|
|
|
2009-03-22 10:30:00 +01:00
|
|
|
clean:
|
2016-09-07 10:32:57 +02:00
|
|
|
rm -rf $(REDIS_SERVER_NAME) $(REDIS_SENTINEL_NAME) $(REDIS_CLI_NAME) $(REDIS_BENCHMARK_NAME) $(REDIS_CHECK_RDB_NAME) $(REDIS_CHECK_AOF_NAME) *.o *.gcda *.gcno *.gcov redis.info lcov-html Makefile.dep dict-benchmark
|
2020-01-01 10:33:02 -05:00
|
|
|
rm -f $(DEP)
|
2012-03-24 19:25:03 -07:00
|
|
|
|
|
|
|
.PHONY: clean
|
2011-11-15 12:40:49 -08:00
|
|
|
|
|
|
|
distclean: clean
|
|
|
|
-(cd ../deps && $(MAKE) distclean)
|
2012-03-24 19:25:03 -07:00
|
|
|
-(rm -f .make-*)
|
2009-03-22 10:30:00 +01:00
|
|
|
|
2012-03-24 19:25:03 -07:00
|
|
|
.PHONY: distclean
|
2009-03-22 10:30:00 +01:00
|
|
|
|
2012-04-13 16:13:56 +02:00
|
|
|
test: $(REDIS_SERVER_NAME) $(REDIS_CHECK_AOF_NAME)
|
2011-07-15 17:20:57 +02:00
|
|
|
@(cd ..; ./runtest)
|
2009-03-22 10:30:00 +01:00
|
|
|
|
2014-02-28 16:00:00 +01:00
|
|
|
test-sentinel: $(REDIS_SENTINEL_NAME)
|
|
|
|
@(cd ..; ./runtest-sentinel)
|
|
|
|
|
2013-03-16 18:40:22 +11:00
|
|
|
check: test
|
|
|
|
|
2012-04-04 19:17:32 +02:00
|
|
|
lcov:
|
2012-04-13 17:38:12 -07:00
|
|
|
$(MAKE) gcov
|
2012-04-04 19:17:32 +02:00
|
|
|
@(set -e; cd ..; ./runtest --clients 1)
|
|
|
|
@geninfo -o redis.info .
|
|
|
|
@genhtml --legend -o lcov-html redis.info
|
|
|
|
|
2014-12-10 09:50:27 +01:00
|
|
|
test-sds: sds.c sds.h
|
2017-07-05 14:32:07 +00:00
|
|
|
$(REDIS_CC) sds.c zmalloc.c -DSDS_TEST_MAIN $(FINAL_LIBS) -o /tmp/sds_test
|
2014-12-10 09:50:27 +01:00
|
|
|
/tmp/sds_test
|
|
|
|
|
2012-03-24 19:25:03 -07:00
|
|
|
.PHONY: lcov
|
|
|
|
|
2012-04-12 11:09:38 +02:00
|
|
|
bench: $(REDIS_BENCHMARK_NAME)
|
|
|
|
./$(REDIS_BENCHMARK_NAME)
|
2009-10-23 21:24:01 +02:00
|
|
|
|
|
|
|
32bit:
|
2010-02-22 17:36:54 +01:00
|
|
|
@echo ""
|
|
|
|
@echo "WARNING: if it fails under Linux you probably need to install libc6-dev-i386"
|
|
|
|
@echo ""
|
2012-04-13 17:46:28 -07:00
|
|
|
$(MAKE) CFLAGS="-m32" LDFLAGS="-m32"
|
2009-11-04 09:53:43 +01:00
|
|
|
|
2009-12-14 13:48:24 -05:00
|
|
|
gcov:
|
2012-04-13 17:34:31 -07:00
|
|
|
$(MAKE) REDIS_CFLAGS="-fprofile-arcs -ftest-coverage -DCOVERAGE_TEST" REDIS_LDFLAGS="-fprofile-arcs -ftest-coverage"
|
2009-12-14 13:48:24 -05:00
|
|
|
|
2010-01-12 09:57:00 -05:00
|
|
|
noopt:
|
2013-02-11 12:11:21 +01:00
|
|
|
$(MAKE) OPTIMIZATION="-O0"
|
|
|
|
|
|
|
|
valgrind:
|
|
|
|
$(MAKE) OPTIMIZATION="-O0" MALLOC="libc"
|
2010-01-12 09:57:00 -05:00
|
|
|
|
2017-05-10 10:01:06 +02:00
|
|
|
helgrind:
|
|
|
|
$(MAKE) OPTIMIZATION="-O0" MALLOC="libc" CFLAGS="-D__ATOMIC_VAR_FORCE_SYNC_MACROS"
|
|
|
|
|
2011-07-13 19:15:22 +02:00
|
|
|
src/help.h:
|
|
|
|
@../utils/generate-command-help.rb > help.h
|
|
|
|
|
2010-07-06 19:07:16 +02:00
|
|
|
install: all
|
2013-03-17 18:03:14 +11:00
|
|
|
@mkdir -p $(INSTALL_BIN)
|
2012-07-23 12:54:52 +02:00
|
|
|
$(REDIS_INSTALL) $(REDIS_SERVER_NAME) $(INSTALL_BIN)
|
|
|
|
$(REDIS_INSTALL) $(REDIS_BENCHMARK_NAME) $(INSTALL_BIN)
|
|
|
|
$(REDIS_INSTALL) $(REDIS_CLI_NAME) $(INSTALL_BIN)
|
2014-05-09 12:06:06 -04:00
|
|
|
$(REDIS_INSTALL) $(REDIS_CHECK_RDB_NAME) $(INSTALL_BIN)
|
2012-07-23 12:54:52 +02:00
|
|
|
$(REDIS_INSTALL) $(REDIS_CHECK_AOF_NAME) $(INSTALL_BIN)
|
2014-12-17 11:04:08 +01:00
|
|
|
@ln -sf $(REDIS_SERVER_NAME) $(INSTALL_BIN)/$(REDIS_SENTINEL_NAME)
|
2019-03-06 21:24:45 -05:00
|
|
|
|
|
|
|
uninstall:
|
|
|
|
rm -f $(INSTALL_BIN)/{$(REDIS_SERVER_NAME),$(REDIS_BENCHMARK_NAME),$(REDIS_CLI_NAME),$(REDIS_CHECK_RDB_NAME),$(REDIS_CHECK_AOF_NAME),$(REDIS_SENTINEL_NAME)}
|