Deal reached to link EU funding to respect for rule of law