Add missing newlines at EOF in sources

(missing newlines break build due to -Werror)
Fix "comparison is always true due to limited range of data type" warning
Add detection of required libraries
Merge pull request #171 from AMDmi3/freebsd-fixes

FreeBSD fixes