Build improvement: support debug build, detect x64/x86

Detect x64/x86 and pick the right PSOL library to link against
Add preliminary support for debug builds (this CL allows linking to PSOL's debug library).
Specify `BUILDTYPE=Debug` on the commandline to use.

Note that the debug version might still crash because of an (in our case harmless) assert.