Switch from custom makefiles to cmake.