West Ham have announced goalkeeper David Martin will join the club on July 1 after agreeing a two-year deal, with the option to extend for a further 12 months.