Merge pull request #965 from reaperhulk/make-build-ffi-more-flexible

expand build_ffi helper function