  We consider the possibility that dark matter halos are made of quantum
particles such as fermions or bosons in the form of Bose-Einstein condensates.
In that case, they generically have a "core-halo" structure with a quantum core
that depends on the type of particle considered and a halo that is relatively
independent of the dark matter particle and that is similar to the NFW profile
of cold dark matter. We model the halo by an isothermal gas with an effective
temperature $T$. We then derive the core mass -- halo mass relation $M_c(M_v)$
of dark matter halos from an effective thermodynamical model by extremizing the
free energy $F(M_c)$ with respect to the core mass $M_c$. We obtain a general
relation that is equivalent to the "velocity dispersion tracing" relation
according to which the velocity dispersion in the core $v_c^2\sim GM_c/R_c$ is
of the same order as the velocity dispersion in the halo $v_v^2\sim GM_v/r_v$.
We provide therefore a justification of this relation from thermodynamical
arguments. In the case of fermions, we obtain a relation $M_c\propto M_v^{1/2}$
that agrees with the relation found numerically by Ruffini {\it et al.}. In the
case of noninteracting bosons, we obtain a relation $M_c\propto M_v^{1/3}$ that
agrees with the relation found numerically by Schive {\it et al.}. In the case
of bosons with a repulsive self-interaction in the Thomas-Fermi limit, we
predict a relation $M_c\propto M_v^{2/3}$ that still has to be confirmed
numerically. We also obtain a general approximate core mass -- halo mass
relation that is valid for bosons with arbitrary repulsive or attractive
self-interaction. For an attractive self-interaction, we determine the maximum
halo mass that can harbor a stable quantum core (dilute axion "star").
