Added support for GNU readline at the REPL

Implemented both cursor movement and command history at the REPL with a
conditional compilation target using GNU readline.

This change also required a large rewrite of CMakeLists.txt (which was
broken anyway) and some small changes to the Makefile.