Repository: redis/redis

Issue:
[BUG] Unable to compile redis with a specific openssl version(1.1.1l) in Linux  
**Describe the bug**

Unable to compile redis with a specific openssl version(1.1.1l) in Linux  

**To reproduce**

- `docker run -it ubuntu:xenial /bin/bash`
- Download and compile openssl version 1.1.1l with prefix /root/openssl
- In redis' base dir `make BUILD_TLS=yes OPENSSL_PREFIX=/root/openssl`

output:
```
...
MAKE hiredis
cd hiredis && make static USE_SSL=1
make[3]: Entering directory '/root/redis-unstable/deps/hiredis'
cc -std=c99 -pedantic -c -O3 -fPIC  -DHIREDIS_TEST_SSL -Wall -W -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb alloc.c
cc -std=c99 -pedantic -c -O3 -fPIC  -DHIREDIS_TEST_SSL -Wall -W -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb net.c
cc -std=c99 -pedantic -c -O3 -fPIC  -DHIREDIS_TEST_SSL -Wall -W -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb hiredis.c
cc -std=c99 -pedantic -c -O3 -fPIC  -DHIREDIS_TEST_SSL -Wall -W -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb sds.c
cc -std=c99 -pedantic -c -O3 -fPIC  -DHIREDIS_TEST_SSL -Wall -W -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb async.c
cc -std=c99 -pedantic -c -O3 -fPIC  -DHIREDIS_TEST_SSL -Wall -W -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb read.c
cc -std=c99 -pedantic -c -O3 -fPIC  -DHIREDIS_TEST_SSL -Wall -W -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb sockcompat.c
ar rcs libhiredis.a alloc.o net.o hiredis.o sds.o async.o read.o sockcompat.o
cc -std=c99 -pedantic -c -O3 -fPIC  -DHIREDIS_TEST_SSL -Wall -W -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb ssl.c
ssl.c:45:25: fatal error: openssl/ssl.h: No such file or directory
compilation terminated.
Makefile:223: recipe for target 'ssl.o' failed
make[3]: *** [ssl.o] Error 1
make[3]: Leaving directory '/root/redis-unstable/deps/hiredis'
Makefile:50: recipe for target 'hiredis' failed
make[2]: *** [hiredis] Error 2
make[2]: Leaving directory '/root/redis-unstable/deps'
```

**Expected behavior**

`make BUILD_TLS=yes OPENSSL_PREFIX=/root/openssl`
Compiles and links with the specified openssl lib, NOT the system wide openssl.

**Additional information**

I'm trying to support TLS1.3 on ubuntu:xenial.  



Discussion:

Patch:
diff --git a/deps/hiredis/Makefile b/deps/hiredis/Makefile
index a8d37a2ebbd..7e41c97a574 100644
--- a/deps/hiredis/Makefile
+++ b/deps/hiredis/Makefile
@@ -77,7 +77,12 @@ ifeq ($(USE_SSL),1)
 endif
 
 ifeq ($(uname_S),Linux)
-  SSL_LDFLAGS=-lssl -lcrypto
+  ifdef OPENSSL_PREFIX
+    CFLAGS+=-I$(OPENSSL_PREFIX)/include
+    SSL_LDFLAGS+=-L$(OPENSSL_PREFIX)/lib -lssl -lcrypto
+  else
+    SSL_LDFLAGS=-lssl -lcrypto
+  endif
 else
   OPENSSL_PREFIX?=/usr/local/opt/openssl
   CFLAGS+=-I$(OPENSSL_PREFIX)/include
diff --git a/src/Makefile b/src/Makefile
index 595231ca41e..4930bbb7d96 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -121,15 +121,11 @@ ifeq ($(uname_S),Darwin)
 	# must be referenced explicitly during build.
 ifeq ($(uname_M),arm64)
 	# Homebrew arm64 uses /opt/homebrew as HOMEBREW_PREFIX
-	OPENSSL_PREFIX=/opt/homebrew/opt/openssl
+	OPENSSL_PREFIX?=/opt/homebrew/opt/openssl
 else
 	# Homebrew x86/ppc uses /usr/local as HOMEBREW_PREFIX
-	OPENSSL_PREFIX=/usr/local/opt/openssl
+	OPENSSL_PREFIX?=/usr/local/opt/openssl
 endif
-OPENSSL_CFLAGS=-I$(OPENSSL_PREFIX)/include
-OPENSSL_LDFLAGS=-L$(OPENSSL_PREFIX)/lib
-# Also export OPENSSL_PREFIX so it ends up in deps sub-Makefiles
-export OPENSSL_PREFIX
 else
 ifeq ($(uname_S),AIX)
         # AIX
@@ -190,6 +186,14 @@ endif
 endif
 endif
 endif
+
+ifdef OPENSSL_PREFIX
+	OPENSSL_CFLAGS=-I$(OPENSSL_PREFIX)/include
+	OPENSSL_LDFLAGS=-L$(OPENSSL_PREFIX)/lib
+	# Also export OPENSSL_PREFIX so it ends up in deps sub-Makefiles
+	export OPENSSL_PREFIX
+endif
+
 # Include paths to dependencies
 FINAL_CFLAGS+= -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src -I../deps/hdr_histogram