libraries like openssl, libxml, zlib, etc... are not in the standard places
Issue is there is no such "standard". There is Linux Base Standard, but it's limited to Linux distro, which others OS not based on Linux don't have to comply with.
An approach is to use a meta-build system like CMake and rely on pkg-info to get target specific BY relying I mean write (or adapt) cmake files to use it, as hardcoding is still possible there too and way too often done alas.
General approach is to stop assuming that includes are under /usr/include on every OS, that system libraries are always under /lib and /usr/lib, that maths API are always in libm, that clock_* are in librt and so on.
What is your build system currently? Autoconf ? Plain makefile ? Cmake ?
With autoconf, there is AC_CHECK_LIB and AC_SEARCH_LIBS that are handy.
With CMake, look at find_path, find_library, find_package documentation.
Haikuports is a good source of hints for porting stuffs, if you don't know it already: