Move build logic to dedicated Makefile

This removes a large amount of duplicated code, and simplifies
subdirectory Makefiles
Add history command to shell
Add atoi() string conversion function
getchar: shell func to read character values