Various build system fixes

Mainly fixes build against system PolarSSL, but also the lua backend on systems where the lua library is called differently and the remotebackend with http support.