I am trying to compile postgres-14.3 with openssl-3.1.0, Openssl is also compiled by me. The problem is when I run configure script for postgres it tries to execute a test program which is not able to find openssl library. In linux, I was able to solve this problem by using LD_LIBRARY_PATH but on mac os I tried multiple ways but none worked.
I set CPPFLAGS, LDFLAGS in the below way
export LDFLAGS="$LDFLAGS -L$OPENSSL_DIR -Wl,-rpath,$OPENSSL_DIR"
export CPPFLAGS="$CPPFLAGS -I$OPENSSL_DIR/include"
I also tried changing openssl lib id using install_name_tool
find $OPENSSL_DIR -type f -name "libssl*dylib*" -exec sh -c 'install_name_tool -id @rpath/$(basename $1) $1' shell {} \;
Tried --with-libraries option during configure but that also didn't work for me.
I know DYLD_LIBRARY_PATH will not work so looking for other ways.