Fix build with gyp on OS X
Fix FreeBSD and Linux build; use make if ninja is not installed

Ninja is used if it is installed in Linux or FreeBSD machines.
Use gyp as a meta build tool; use make for Linux, xcode for OS X

- Delete files for autotools
- Move gyp files to gyp/
- Rewrite build scripts based on gyp