From 72ae0a6e5eaad939d2f7fe6d2e8a8bcbf00a2ec6 Mon Sep 17 00:00:00 2001
From: Daniel Hahler <git@thequod.de>
Date: Sun, 30 Jun 2019 01:29:10 +0200
Subject: [PATCH] Makefile: CMAKE_INSTALL_PREFIX: skip parsing
 CMAKE_EXTRA_FLAGS if set (#10374)

Fixes:

>  Recursive variable 'CMAKE_EXTRA_FLAGS' references itself (eventually).  Stop.
---
 Makefile | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 973f39568c..dde78e5274 100644
--- a/Makefile
+++ b/Makefile
@@ -16,12 +16,12 @@ CMAKE_EXTRA_FLAGS ?=
 # CMAKE_INSTALL_PREFIX
 #   - May be passed directly or as part of CMAKE_EXTRA_FLAGS.
 #   - `checkprefix` target checks that it matches the CMake-cached value. #9615
-ifneq (,$(CMAKE_EXTRA_FLAGS))
-CMAKE_INSTALL_PREFIX ?= $(shell echo $(CMAKE_EXTRA_FLAGS) | 2>/dev/null \
+ifneq (,$(CMAKE_INSTALL_PREFIX)$(CMAKE_EXTRA_FLAGS))
+CMAKE_INSTALL_PREFIX := $(shell echo $(CMAKE_EXTRA_FLAGS) | 2>/dev/null \
     grep -o 'CMAKE_INSTALL_PREFIX=[^ ]\+' | cut -d '=' -f2)
 endif
 ifneq (,$(CMAKE_INSTALL_PREFIX))
-  CMAKE_EXTRA_FLAGS += -DCMAKE_INSTALL_PREFIX=$(CMAKE_INSTALL_PREFIX)
+CMAKE_EXTRA_FLAGS += -DCMAKE_INSTALL_PREFIX=$(CMAKE_INSTALL_PREFIX)
 
 checkprefix:
 	@if [ -f build/.ran-cmake ]; then \