Endogenous retroviruses and the evolution of resistance to retroviral infection