Make is a great tool for performing multi-step tasks with dependencies such a compiling.
make depend make