From 3238cf4fe7c0799f997a6c77c42b3884dc4cfa0d Mon Sep 17 00:00:00 2001 From: Dmitri Vorobiev Date: Wed, 27 Dec 2017 14:43:03 +0200 Subject: Remove $(ARCH) expansion from the Makefile Some compilation environments (such as Yocto) define the ARCH environment variable to indicate the target architecture. For such enviroments, hiredis build fails, because the expanded $(ARCH) variable in the Makefile gets erroneously interpreted as an argument to the `-ggdb' command line option during the compilation stage or as an input file name during the linking stage. This patch removes $(ARCH) expansions from the Makefile. This doesn't harm cross-compilation, the latter goes fine with the properly assigned CC environment variable. For native builds, this patch does not imply any changes. Signed-off-by: Dmitri Vorobiev --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index c6eb229..22ee8bd 100644 --- a/Makefile +++ b/Makefile @@ -41,8 +41,8 @@ CXX:=$(shell sh -c 'type $(CXX) >/dev/null 2>/dev/null && echo $(CXX) || echo g+ OPTIMIZATION?=-O3 WARNINGS=-Wall -W -Wstrict-prototypes -Wwrite-strings DEBUG_FLAGS?= -g -ggdb -REAL_CFLAGS=$(OPTIMIZATION) -fPIC $(CFLAGS) $(WARNINGS) $(DEBUG_FLAGS) $(ARCH) -REAL_LDFLAGS=$(LDFLAGS) $(ARCH) +REAL_CFLAGS=$(OPTIMIZATION) -fPIC $(CFLAGS) $(WARNINGS) $(DEBUG_FLAGS) +REAL_LDFLAGS=$(LDFLAGS) DYLIBSUFFIX=so STLIBSUFFIX=a -- cgit v1.2.3 From 12a9d1a32b567ad933ec62528ca4a476f514b5da Mon Sep 17 00:00:00 2001 From: Dmitri Vorobiev Date: Thu, 28 Dec 2017 11:42:45 +0200 Subject: Strip compiler options from the CC variable The Makefile checks validity of the compiler command in the CC variable by feeding the contents of that variable to the `type' utility. Some environments include compiler options in the CC variable such as architecture specific tuning flags. For such cases it is necessary to first strip everything except the command itself from the contents of the CC variable prior to checking the command with the type utility, which is what this patch is introducing. We use shell parameter expansion mechanism for this purpose. Signed-off-by: Dmitri Vorobiev --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 22ee8bd..eb18f58 100644 --- a/Makefile +++ b/Makefile @@ -36,8 +36,8 @@ endef export REDIS_TEST_CONFIG # Fallback to gcc when $CC is not in $PATH. -CC:=$(shell sh -c 'type $(CC) >/dev/null 2>/dev/null && echo $(CC) || echo gcc') -CXX:=$(shell sh -c 'type $(CXX) >/dev/null 2>/dev/null && echo $(CXX) || echo g++') +CC:=$(shell sh -c 'type $${CC%% *} >/dev/null 2>/dev/null && echo $(CC) || echo gcc') +CXX:=$(shell sh -c 'type $${CXX%% *} >/dev/null 2>/dev/null && echo $(CXX) || echo g++') OPTIMIZATION?=-O3 WARNINGS=-Wall -W -Wstrict-prototypes -Wwrite-strings DEBUG_FLAGS?= -g -ggdb -- cgit v1.2.3