Toolchain: Rewrite build script

Signed-off-by: Anton Kolesov <Anton.Kolesov@synopsys.com>
Common: Fix an error with CFLAGS handling

Signed-off-by: Anton Kolesov <Anton.Kolesov@synopsys.com>