darwin* never defined CL_THREAD_SAFE, which was probably the cause for bug
I found this out when fixing the no pthreads case (bb #1897) and accidentally
broke it instead of fixing it. The Mac OS X buildbot failed.
This commit moves the CL_THREAD_SAFE definition to the same place as BUILD_CLAMD
(have_pthreads=yes) so no system with pthread is forgotten.
darwin has pthread in libc so no linker flags are needed (which is probably why
defining CL_THREAD_SAFE was forgotten)
We defined WORDS_BIGENDIAN to 0 if it wasn't defined, however that doesn't work with Apple universal
builds, since we don't know the endianness at configure time!
So add the ifndef WORDS_BIGNENDIAN -> define WORDS_BIGENDIAN 0 logic to
platform.h.
Apply a libltdl patch to avoid adding -ldl to LIBS.
Only add -lz to LIBCLAMAV_LIBS, libtool will add -lz as necessary
to programs linking libclamav.la.
Also add an export map to clamdscan, it only needs to export main.
Also remove the [1] from g++ version check to allow buildtesting with clang++.
Disabled Wbad-function-cast as error (it warned about double to int conversion).
Also run configure itself without Werror, and only set Werror at the end,
because otherwise the check for -lm fails (resulting in link error for missing
symbol of sqrt). Apparently the configure check for -lm uses a wrong prototype,
which due to Werror makes configure think it doesn't need -lm (since it doesn't
have any math symbols in it).
This simplifies the various clamd/clamscan tests a lot,
since the valgrind tests can now be parallelized by automake,
and we don't need to do that in the script itself.
This is tricky, because autoconf provides no way to do this automatically
(AC_PROG_CXX fails if no C++ compiler).
One could override AC_MSG_ERROR/FAILURE for AC_PROG_CXX, but that causes all
sorts of problems later (like sys/types.h not found).
So instead create yet another configure in libclamav/c++,
but teach autoconf not to fail if the subconfigure fails
(by overriding AC_MSG_ERROR to set a variable instead of exiting).
This seems to work with shared and static builds, "-all-static" builds
don't work yet, will fix that later.