Merge pull request #3306 from hathach/refactor-buildsystem

Refactor buildsystem and bsp