I'd sat the answer is 'all of the above'. Because 'history of the relationship' is important - you won't greet a person you've just met the same way you'd great your best friend. "Context' is also important, because you won't speak the same way at a gala, or at a casual meeting with your friends. "Type of the conversation desired" is also relevant, because the way you greet someone will lead the course of your conversation.