Refactor makefile script
Refactor makefile script

* Fix shellcheck issues
* Fix some shell style inconsistencies.
* Split out some functions.

Signed-off-by: Ben Kochie <9bbf917dc63fbaa40c67921332d26cf16a50db75@gmail.com>

GoogleCloudPlatform/prometheus,prometheus/prometheus,alileza/prometheus,alileza/prometheus,prometheus/prometheus,kangwoo/prometheus,keegancsmith/prometheus,Gouthamve/prometheus,kangwoo/prometheus,Gouthamve/prometheus,alileza/prometheus,GoogleCloudPlatform/prometheus,Gouthamve/prometheus,GoogleCloudPlatform/prometheus,Gouthamve/prometheus,kangwoo/prometheus,kangwoo/prometheus,keegancsmith/prometheus,prometheus/prometheus,keegancsmith/prometheus,GoogleCloudPlatform/prometheus,alileza/prometheus,prometheus/prometheus,keegancsmith/prometheus,GoogleCloudPlatform/prometheus,keegancsmith/prometheus,alileza/prometheus,prometheus/prometheus