Fixes compilation for i686 and possibly other platforms.
Compiles libx8664 only when the target is x86_64.
Proper platform detection.
Use target instead of host.
Fix compilation for non win32 and non x86_64 platforms.
Restore jansson check
Rebase manually into one commit. For the future, please rebase to fold fixes for bugs you add, into the main commit itself.