Making script more generic. Work in progress.
Some fixes.
Fixed unterminated quote.
Added missing target to subdir make rules.