Coupling of Yang-Mills to N = 4, d = 4 supergravity