We study SYM gauge theories living on ALE spaces. Using localization formulae we compute the prepotential (and its gravitational corrections) for SU(N) supersymmetric ${cal N}=2, 2^*$ gauge theories on ALE spaces of the $A_n$ type. Furthermore we derive the Poincar{e} polynomial describing the homologies of the corresponding moduli spaces of self-dual gauge connections. From these results we extract the ${cal N}=4$ partition function which is a modular form in agreement with the expectations of $SL(2,Z)$ duality.