Handle signals correctly.
Switch to cmake.