From 59f1563882727a48f2967842b06adb82b82d03e0 Mon Sep 17 00:00:00 2001
From: Leo Singer <leo.singer@ligo.org>
Date: Mon, 18 Nov 2019 17:39:06 -0500
Subject: [PATCH 3/4] Use openssl-1.0 from MacPorts instead of bundled openssl

---
 ds9/macos/Makefile.in |  2 +-
 ds9/unix/Makefile.in  |  2 +-
 make.include          | 12 +--------
 tls/aclocal.m4        | 63 ++-----------------------------------------
 4 files changed, 5 insertions(+), 74 deletions(-)

diff --git a/ds9/macos/Makefile.in b/ds9/macos/Makefile.in
index d13d1d89..c7043054 100644
--- a/ds9/macos/Makefile.in
+++ b/ds9/macos/Makefile.in
@@ -175,7 +175,7 @@ ds9base	: $(OBJS) $(LLIBS)
 	$(CC) $(CFLAGS) -o $@ \
 	$(OBJS) \
 	$(LLIBS) \
-	-L $(prefix)/openssl -lssl -lcrypto \
+	-L @macports_prefix@/lib/openssl-1.0 -lssl -lcrypto \
 	$(TK_LIB_SPEC) \
 	$(TCL_LIB_SPEC) \
 	$(TK_LIBS) \
diff --git a/ds9/unix/Makefile.in b/ds9/unix/Makefile.in
index b730b4b8..f66ff675 100644
--- a/ds9/unix/Makefile.in
+++ b/ds9/unix/Makefile.in
@@ -176,7 +176,7 @@ ds9base	: $(OBJS) $(LLIBS)
 	$(CC) $(CFLAGS) -o $@ \
 	$(OBJS) \
 	$(LLIBS) \
-	-L $(prefix)/openssl -lssl -lcrypto \
+	-L @macports_prefix@/lib/openssl-1.0 -lssl -lcrypto \
 	$(TK_LIBS) \
 	$(LIBS)
 
diff --git a/make.include b/make.include
index 066c256a..f45619c1 100644
--- a/make.include
+++ b/make.include
@@ -101,16 +101,7 @@ ds9/$(OS)/Makefile :
 
 #--------------------------openssl
 
-openssl	: openssl/Makefile
-	@echo ""
-	@echo "*** $@ ***"
-	$(MAKE) -C openssl -j $(JOBS)
-
-openssl/Makefile:
-	@echo ""
-	@echo "*** $@ ***"
-	cd openssl; \
-	$(SSLCONFIG) --prefix=$(prefix)
+openssl	:
 
 #-------------------------- tcliis
 
@@ -161,7 +152,6 @@ tls/Makefile :
 	@echo "*** $@ ***"
 	cd tls; \
 	./configure \
- 	--with-ssl-dir=$(prefix)/openssl \
 	 $(TLSFLAGS) \
 	$(WITHTCL) \
 	$(PREFIX) \
diff --git a/tls/aclocal.m4 b/tls/aclocal.m4
index ff62b04b..152b3143 100644
--- a/tls/aclocal.m4
+++ b/tls/aclocal.m4
@@ -29,72 +29,13 @@ builtin(include,tclconfig/tcl.m4)
 
 AC_DEFUN(TLS_CHECK_SSL, [
 
-    #--------------------------------------------------------------------
-    # If the variable OPENSSL is set, we will build with the OpenSSL
-    # libraries.  If it is not set, then we will use RSA BSAFE SSL-C
-    # libraries instead of the default OpenSSL libaries.
-    #--------------------------------------------------------------------
-
-    AC_ARG_ENABLE(bsafe, [  --enable-bsafe          Use RSA BSAFE SSL-C libs.  Default is to use OpenSSL libs], OPENSSL="", OPENSSL="1")
-
-    #--------------------------------------------------------------------
-    # Establish the location of the root directory for OpenSSL.
-    # If we're not using OpenSSL, set the root for BSAFE SSL-C.
-    # If we're using BSAFE, define the BSAFE compiler flag.
-    # The "FLAT_INC" flag is used in the BSAFE ssl.h header file and
-    # doesn't seem to be referenced anywhere else.
-    #--------------------------------------------------------------------
-    if test -n "${OPENSSL}"; then
-	SSL_DIR='/usr /usr/local'
-	AC_DEFINE(NO_IDEA)
-	AC_DEFINE(NO_RC5)
-    else
-	SSL_DIR='/usr/sslc /usr/local/sslc'
-	AC_DEFINE(BSAFE)
-	AC_DEFINE(FLAT_INC)
-    fi
-    
-    AC_MSG_CHECKING([for SSL directory])
-
-    AC_ARG_WITH(ssl-dir, [  --with-ssl-dir=DIR      SSL root directory], with_ssldir=${withval})
-
-    AC_CACHE_VAL(ac_cv_c_ssldir, [
-	# Use the value from --with-ssl-dir, if it was given
-	if test x"${with_ssldir}" != x ; then
-	    if test -d "${with_ssldir}" ; then
-		ac_cv_c_ssldir=${with_ssldir}
-	    else
-		AC_MSG_ERROR([${with_ssldir} is not a valid directory])
-	    fi
-	else
-	    list="`ls -d ${SSL_DIR} 2>/dev/null`"
-	    for i in $list ; do
-		if test -d "$i" ; then
-		    ac_cv_c_ssldir=$i
-		    break
-		fi
-	    done
-	fi
-    ])
-
-    # Print a message based on how we determined the include path
-
-    if test x"${ac_cv_c_ssldir}" = x ; then
-	AC_MSG_ERROR([Could not find SSL directory.
-Please specify its location with --with-ssl-dir])
-    else
-	SSL_DIR=${ac_cv_c_ssldir}
-	AC_MSG_RESULT([${SSL_DIR}])
-    fi
-
-
     #--------------------------------------------------------------------
     # The OpenSSL and BSAFE SSL-C directory structures differ.
     #--------------------------------------------------------------------
 
     if test -n "${OPENSSL}"; then
-	SSL_LIB_DIR=${SSL_DIR}/lib
-	SSL_INCLUDE_DIR=${SSL_DIR}/include
+	SSL_LIB_DIR=@macports_prefix@/lib/openssl-1.0
+	SSL_INCLUDE_DIR=@macports_prefix@/include/openssl-1.0
 	if test ! -f "${SSL_INCLUDE_DIR}/openssl/opensslv.h"; then
 	    AC_ERROR([bad ssl-dir: cannot find openssl/opensslv.h under ${SSL_INCLUDE_DIR}])
 	fi
-- 
2.24.0

