Fix build script to respect directories

The build script now creates directories properly, so that
all internal references actually work.

http://jira.webinos.org/browse/APPPOL-18

Jira issue: APPPOL-18