Rework makefile to work with KitKat's build system.

Originally this was leveraging some things that are only in AOSP master branch, causing linker problems for KitKat.