From bea60bec750a458d69c6f42c080d9ffa1daeea2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Bergstr=C3=B6m?= Date: Sat, 16 Mar 2013 18:33:42 +1100 Subject: [PATCH 1/8] Slightly refactor CFLAGS/LDFLAGS/LIBS This way, we can avoid -rdynamic and -pthread warnings on darwin. --- src/Makefile | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/Makefile b/src/Makefile index 2227d545e..0d5ddfe30 100644 --- a/src/Makefile +++ b/src/Makefile @@ -45,16 +45,20 @@ endif # Override default settings if possible -include .make-settings +FINAL_CFLAGS=$(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS) $(REDIS_CFLAGS) +FINAL_LDFLAGS=$(LDFLAGS) $(REDIS_LDFLAGS) $(DEBUG) +FINAL_LIBS=-lm +DEBUG=-g -ggdb + ifeq ($(uname_S),SunOS) - FINAL_CFLAGS= $(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS) $(REDIS_CFLAGS) -D__EXTENSIONS__ -D_XPG6 - FINAL_LDFLAGS= $(LDFLAGS) $(REDIS_LDFLAGS) -g -ggdb - FINAL_LIBS= -ldl -lnsl -lsocket -lm -lpthread - DEBUG= -g -ggdb + FINAL_CFLAGS+= -D__EXTENSIONS__ -D_XPG6 + FINAL_LIBS+= -ldl -lnsl -lsocket -lpthread +else ifeq ($(uname_S),Darwin) + else - FINAL_CFLAGS= $(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS) $(REDIS_CFLAGS) - FINAL_LDFLAGS= $(LDFLAGS) $(REDIS_LDFLAGS) -g -rdynamic -ggdb - FINAL_LIBS= -lm -pthread - DEBUG= -g -rdynamic -ggdb + FINAL_LDFLAGS+= -rdynamic + FINAL_LIBS+= -pthread + DEBUG+= -rdynamic endif # Include paths to dependencies From ada7aa7ac930a50e0f860c3028554a0c6c775cd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Bergstr=C3=B6m?= Date: Sat, 16 Mar 2013 18:35:20 +1100 Subject: [PATCH 2/8] Spaces to tabs --- deps/Makefile | 4 ++-- src/Makefile | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/deps/Makefile b/deps/Makefile index d58ee5681..5a95545de 100644 --- a/deps/Makefile +++ b/deps/Makefile @@ -54,8 +54,8 @@ linenoise: .make-prerequisites .PHONY: linenoise ifeq ($(uname_S),SunOS) - # Make isinf() available - LUA_CFLAGS= -D__C99FEATURES__=1 + # Make isinf() available + LUA_CFLAGS= -D__C99FEATURES__=1 endif LUA_CFLAGS+= -O2 -Wall -DLUA_ANSI $(CFLAGS) diff --git a/src/Makefile b/src/Makefile index 0d5ddfe30..22facba47 100644 --- a/src/Makefile +++ b/src/Makefile @@ -24,22 +24,22 @@ OPT= $(OPTIMIZATION) # Default allocator ifeq ($(uname_S),Linux) - MALLOC=jemalloc + MALLOC=jemalloc else - MALLOC=libc + MALLOC=libc endif # Backwards compatibility for selecting an allocator ifeq ($(USE_TCMALLOC),yes) - MALLOC=tcmalloc + MALLOC=tcmalloc endif ifeq ($(USE_TCMALLOC_MINIMAL),yes) - MALLOC=tcmalloc_minimal + MALLOC=tcmalloc_minimal endif ifeq ($(USE_JEMALLOC),yes) - MALLOC=jemalloc + MALLOC=jemalloc endif # Override default settings if possible @@ -65,19 +65,19 @@ endif FINAL_CFLAGS+= -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src ifeq ($(MALLOC),tcmalloc) - FINAL_CFLAGS+= -DUSE_TCMALLOC - FINAL_LIBS+= -ltcmalloc + FINAL_CFLAGS+= -DUSE_TCMALLOC + FINAL_LIBS+= -ltcmalloc endif ifeq ($(MALLOC),tcmalloc_minimal) - FINAL_CFLAGS+= -DUSE_TCMALLOC - FINAL_LIBS+= -ltcmalloc_minimal + FINAL_CFLAGS+= -DUSE_TCMALLOC + FINAL_LIBS+= -ltcmalloc_minimal endif ifeq ($(MALLOC),jemalloc) - DEPENDENCY_TARGETS+= jemalloc - FINAL_CFLAGS+= -DUSE_JEMALLOC -I../deps/jemalloc/include - FINAL_LIBS+= ../deps/jemalloc/lib/libjemalloc.a -ldl + DEPENDENCY_TARGETS+= jemalloc + FINAL_CFLAGS+= -DUSE_JEMALLOC -I../deps/jemalloc/include + FINAL_LIBS+= ../deps/jemalloc/lib/libjemalloc.a -ldl endif REDIS_CC=$(QUIET_CC)$(CC) $(FINAL_CFLAGS) From a66195629b297bf670d351a52304b1a10cf71c71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Bergstr=C3=B6m?= Date: Sat, 16 Mar 2013 18:38:37 +1100 Subject: [PATCH 3/8] Inherit CC for Lua --- deps/lua/src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/lua/src/Makefile b/deps/lua/src/Makefile index 77d6a48b4..f5c45fcd3 100644 --- a/deps/lua/src/Makefile +++ b/deps/lua/src/Makefile @@ -7,7 +7,7 @@ # Your platform. See PLATS for possible values. PLAT= none -CC= gcc +CC?= gcc CFLAGS= -O2 -Wall $(MYCFLAGS) AR= ar rcu RANLIB= ranlib From 978c895b69f2aa330eb704d8b5b0bb792f0dd8ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Bergstr=C3=B6m?= Date: Sat, 16 Mar 2013 18:40:22 +1100 Subject: [PATCH 4/8] make check is a common naming convention for tests --- src/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Makefile b/src/Makefile index 22facba47..28d5a5bff 100644 --- a/src/Makefile +++ b/src/Makefile @@ -200,6 +200,8 @@ distclean: clean test: $(REDIS_SERVER_NAME) $(REDIS_CHECK_AOF_NAME) @(cd ..; ./runtest) +check: test + lcov: $(MAKE) gcov @(set -e; cd ..; ./runtest --clients 1) From 33a4bc2c70a04c33b10779e163625b150d69eb6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Bergstr=C3=B6m?= Date: Sat, 16 Mar 2013 18:44:38 +1100 Subject: [PATCH 5/8] Remove extra spaces --- src/Makefile | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Makefile b/src/Makefile index 28d5a5bff..b52ad3930 100644 --- a/src/Makefile +++ b/src/Makefile @@ -18,9 +18,9 @@ OPTIMIZATION?=-O2 DEPENDENCY_TARGETS=hiredis linenoise lua # Default settings -STD= -std=c99 -pedantic -WARN= -Wall -OPT= $(OPTIMIZATION) +STD=-std=c99 -pedantic +WARN=-Wall +OPT=$(OPTIMIZATION) # Default allocator ifeq ($(uname_S),Linux) @@ -85,8 +85,8 @@ REDIS_LD=$(QUIET_LINK)$(CC) $(FINAL_LDFLAGS) REDIS_INSTALL=$(QUIET_INSTALL)$(INSTALL) PREFIX?=/usr/local -INSTALL_BIN= $(PREFIX)/bin -INSTALL= cp -pf +INSTALL_BIN=$(PREFIX)/bin +INSTALL=cp -pf CCCOLOR="\033[34m" LINKCOLOR="\033[34;1m" @@ -101,17 +101,17 @@ QUIET_LINK = @printf ' %b %b\n' $(LINKCOLOR)LINK$(ENDCOLOR) $(BINCOLOR)$@$(EN QUIET_INSTALL = @printf ' %b %b\n' $(LINKCOLOR)INSTALL$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR) 1>&2; endif -REDIS_SERVER_NAME= redis-server -REDIS_SENTINEL_NAME= redis-sentinel -REDIS_SERVER_OBJ= adlist.o ae.o anet.o dict.o redis.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 crc64.o bitops.o sentinel.o notify.o setproctitle.o -REDIS_CLI_NAME= redis-cli -REDIS_CLI_OBJ= anet.o sds.o adlist.o redis-cli.o zmalloc.o release.o anet.o ae.o crc64.o -REDIS_BENCHMARK_NAME= redis-benchmark -REDIS_BENCHMARK_OBJ= ae.o anet.o redis-benchmark.o sds.o adlist.o zmalloc.o redis-benchmark.o -REDIS_CHECK_DUMP_NAME= redis-check-dump -REDIS_CHECK_DUMP_OBJ= redis-check-dump.o lzf_c.o lzf_d.o crc64.o -REDIS_CHECK_AOF_NAME= redis-check-aof -REDIS_CHECK_AOF_OBJ= redis-check-aof.o +REDIS_SERVER_NAME=redis-server +REDIS_SENTINEL_NAME=redis-sentinel +REDIS_SERVER_OBJ=adlist.o ae.o anet.o dict.o redis.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 crc64.o bitops.o sentinel.o notify.o setproctitle.o +REDIS_CLI_NAME=redis-cli +REDIS_CLI_OBJ=anet.o sds.o adlist.o redis-cli.o zmalloc.o release.o anet.o ae.o crc64.o +REDIS_BENCHMARK_NAME=redis-benchmark +REDIS_BENCHMARK_OBJ=ae.o anet.o redis-benchmark.o sds.o adlist.o zmalloc.o redis-benchmark.o +REDIS_CHECK_DUMP_NAME=redis-check-dump +REDIS_CHECK_DUMP_OBJ=redis-check-dump.o lzf_c.o lzf_d.o crc64.o +REDIS_CHECK_AOF_NAME=redis-check-aof +REDIS_CHECK_AOF_OBJ=redis-check-aof.o all: $(REDIS_SERVER_NAME) $(REDIS_SENTINEL_NAME) $(REDIS_CLI_NAME) $(REDIS_BENCHMARK_NAME) $(REDIS_CHECK_DUMP_NAME) $(REDIS_CHECK_AOF_NAME) @echo "" From 348be19b5f42da0f61044a0cbbe5eecaaa257c6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Bergstr=C3=B6m?= Date: Sun, 17 Mar 2013 17:49:57 +1100 Subject: [PATCH 6/8] Only pass -rdynamic as linker option --- src/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index b52ad3930..a271501b1 100644 --- a/src/Makefile +++ b/src/Makefile @@ -58,7 +58,6 @@ else ifeq ($(uname_S),Darwin) else FINAL_LDFLAGS+= -rdynamic FINAL_LIBS+= -pthread - DEBUG+= -rdynamic endif # Include paths to dependencies From dc4003be715e4ed024ec7c95594c08ba8ddd006c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Bergstr=C3=B6m?= Date: Sun, 17 Mar 2013 18:03:14 +1100 Subject: [PATCH 7/8] Silence mkdir output --- src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index a271501b1..f00210fb6 100644 --- a/src/Makefile +++ b/src/Makefile @@ -231,7 +231,7 @@ src/help.h: @../utils/generate-command-help.rb > help.h install: all - mkdir -p $(INSTALL_BIN) + @mkdir -p $(INSTALL_BIN) $(REDIS_INSTALL) $(REDIS_SERVER_NAME) $(INSTALL_BIN) $(REDIS_INSTALL) $(REDIS_BENCHMARK_NAME) $(INSTALL_BIN) $(REDIS_INSTALL) $(REDIS_CLI_NAME) $(INSTALL_BIN) From 8080e1cfbe13503bea8fc7b5933ebd461f787ba8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Bergstr=C3=B6m?= Date: Wed, 20 Mar 2013 22:05:59 +1100 Subject: [PATCH 8/8] use `install` as default installer (except on SunOS) --- src/Makefile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Makefile b/src/Makefile index f00210fb6..d4551d924 100644 --- a/src/Makefile +++ b/src/Makefile @@ -22,6 +22,10 @@ STD=-std=c99 -pedantic WARN=-Wall OPT=$(OPTIMIZATION) +PREFIX?=/usr/local +INSTALL_BIN=$(PREFIX)/bin +INSTALL=install + # Default allocator ifeq ($(uname_S),Linux) MALLOC=jemalloc @@ -51,6 +55,7 @@ FINAL_LIBS=-lm DEBUG=-g -ggdb ifeq ($(uname_S),SunOS) + INSTALL=cp -pf FINAL_CFLAGS+= -D__EXTENSIONS__ -D_XPG6 FINAL_LIBS+= -ldl -lnsl -lsocket -lpthread else ifeq ($(uname_S),Darwin) @@ -83,10 +88,6 @@ REDIS_CC=$(QUIET_CC)$(CC) $(FINAL_CFLAGS) REDIS_LD=$(QUIET_LINK)$(CC) $(FINAL_LDFLAGS) REDIS_INSTALL=$(QUIET_INSTALL)$(INSTALL) -PREFIX?=/usr/local -INSTALL_BIN=$(PREFIX)/bin -INSTALL=cp -pf - CCCOLOR="\033[34m" LINKCOLOR="\033[34;1m" SRCCOLOR="\033[33m"