From f5f608b7b2339499197819503c892e46939f1fea Mon Sep 17 00:00:00 2001 From: Shawn Presser Date: Tue, 31 Oct 2023 19:54:29 -0700 Subject: [PATCH] build: add checks for openssl dir via brew on macOS --- .gitignore | 1 + configure.ac | 3 +++ m4/check_darwin_paths.m4 | 23 +++++++++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 m4/check_darwin_paths.m4 diff --git a/.gitignore b/.gitignore index 52556ec5..d1cb67fa 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ /configure~ # m4/ directory: only keep certain files /m4/* +!/m4/check_darwin_paths.m4 !/m4/check_disable_compiler_warnings.m4 !/m4/check_libcperciva_posix.m4 !/m4/check_memlimit_support.m4 diff --git a/configure.ac b/configure.ac index e1f56d23..d9a6c57c 100644 --- a/configure.ac +++ b/configure.ac @@ -27,6 +27,9 @@ CHECK_POSIX_SH # Check if we need -std=c99 in LDFLAGS (for gcc on Solaris). CHECK_SOLARIS_C99 +# Check if we need to add extra paths to CPPFLAGS and LDFLAGS for macOS. +CHECK_DARWIN_PATHS + # Checks for AES support in OpenSSL. AC_SEARCH_LIBS([AES_encrypt], [crypto],, AC_MSG_ERROR([function AES_ENCRYPT not found])) diff --git a/m4/check_darwin_paths.m4 b/m4/check_darwin_paths.m4 new file mode 100644 index 00000000..f7b025c4 --- /dev/null +++ b/m4/check_darwin_paths.m4 @@ -0,0 +1,23 @@ +# CHECK_DARWIN_PATHS +# ------------------- +AC_DEFUN([CHECK_DARWIN_PATHS], +[AC_REQUIRE([AC_CANONICAL_TARGET]) + +case $target_os in +*darwin*) + # Get the homebrew directory, which varies based on arch. + case "$(uname -m)" in + arm64) + homebrew_dir=/opt/homebrew + ;; + *) + homebrew_dir=/usr/local + ;; + esac + + # Use the homebrew directory to specify the paths to openssl. + CPPFLAGS="${CPPFLAGS} -I${homebrew_dir}/opt/openssl/include" + LDFLAGS="${LDFLAGS} -L${homebrew_dir}/opt/openssl/lib" + ;; +esac +])# CHECK_DARWIN_PATHS