  This article gives a proof of the Langlands-Shelstad fundamental lemma for
the spherical Hecke algebra for every unramified p-adic reductive group G in
large positive characteristic. The proof is based on the transfer principle for
constructible motivic integration. To carry this out, we introduce a general
family of partition functions attached to the complex L-group of the unramified
p-adic group G. Our partition functions specialize to Kostant's q-partition
function for complex connected groups and also specialize to the Langlands
L-function of a spherical representation. These partition functions are used to
extend numerous results that were previously known only when the L-group is
connected (that is, when the p-adic group is split). We give explicit formulas
for branching rules, the inverse of the weight multiplicity matrix, the
Kato-Lusztig formula for the inverse Satake transform, the Plancherel measure,
and Macdonald's formula for the spherical Hecke algebra on a non-connected
complex group (that is, non-split unramified p-adic group).
