Leaders of rival Palestinian groups Fatah and Hamas have signed a declaration to end years of division.