Revamp build process

Change-Id: Ic685b3fc658d0489d16952ee0760fa6363fd58ef
Reviewed-on: http://review.couchbase.org/26929
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>