Replace build system with autotools

This is a new PR on top of `next`. See #95 for the original discussion.