There is no universal formula for this. However, some philosophers tried to give the answer to this, and stoic school of philosophy is pretty interesting one. 
My opinion on this is that every human being has to find what is it that makes him happy and then seek that. I would also like to add that happiness as an only life purpose is wrong because having one mood forever is wrong. Downs and ups are what make happiness possible.