Include / link order needs to be adjusted when trying to override OpenSSL instances
If you are wanting to use a newer OpenSSL (--with-openssl=path) with named than that installed in /usr/local, /opt/local etc. the -I, -L and -R arguments need to moved before -[ILR]/{usr,opt}/local/*.
Similarly for other --with but OpenSSL is the major culprit.