Refactor doxygen check code
Make sure HAVE_DOXYGEN is defined

Thanks-to: <royj@yandex.ru>
Enable automatic build support on FreeBSD

Thanks-to: <royj@yandex.ru>