Is this right way to do? Are there any other ways to set the environment variables inside a recipe?
This is valid; I would recommend setting them within the function though (e.g. do_configure) rather than at the recipe level, assuming that works for your case.