Updated build scripts

(cherry picked from commit d2de92c3efd7b5e5419adcd57212a3dc56530c80)
import bugfix

(cherry picked from commit 1270b44123c0900a1860eba9014bf0b85a259fc0)