  The change in the composition of Pb$_{1-x}$Sn$_x$Te IV-VI semiconductor or in
its lattice parameter can drive a transition from the topologically trivial to
the topological crystalline insulator (TCI), crossing a region where the alloy
is in the Weyl semimetal phase. Incorporation of the magnetic Mn ions induces
strong perturbations of the electronic structure, which act on both orbital and
spin variables. Our first principles calculations show that the presence of Mn
shifts the TCI and the Weyl region towards higher Sn contents in
Pb$_{1-x}$Sn$_x$Te. When the Mn spin polarization is finite, the spin
perturbation, like the orbital part, induces changes in band energies
comparable to the band gap, which widens the Weyl area. The effect opens a
possibility of driving transitions between various topological phases of the
system by magnetic field or by the spontaneous Mn magnetization. We also
propose a new method to calculate topological indices for systems with a finite
spin polarization defined based on the concept of the Chern number. These valid
topological characteristics enable an identification of the three distinct
topological phases of the Pb$_{1-x-y}$Sn$_x$Mn$_y$Te alloy.
