Endogenous generation of amenities and the dynamics of city structure