re-write build script for all-in-one building (need to work on loki)

Change-Id: I3cd178d1e0c2fee5bdb1406d3067bd6d34a3300a