Use correct qt4 dirs for FreeBSD

Prefix should not be used as it's unreliable and may have undesired
side-effects.
Fix bashism
Specify namespace for cmath functions