I am trying to build rtems-arm toolchain for v5.3 on a Debian 13 host. The first hurdle was to make a minor modification to version.py so it would run under Python 3. The build of the various tools starts but the end of the output shows a failure with rtems-gdb-9.1-1.
then in your case, gdb-python-config-libs is most likely empty. What it would need there is -lpython3.6m or -lpython3.12 or what ever pythonX.Y-config --ldflags returns in your case.
I can just guess that the fix may not have been ported back to RTEMS 5.
Just guessing, the next thing which is empty is the gdb-python-config-libpath. From your output it probably needs -L/usr/lib/python3.13/config-3.13-x86_64-linux-gnu or -L/usr/lib/x86_64-linux-gnu to find libpython3.13.so.
Adding --embed to end of the line %define gdb-python-config-lib-check-flags --ldflags (or wherever --ldflags appears in your case) is probably a better way to fix these issues than to hard replace these variables.
It needs --embed when Python version is larger than 3.8. %if %{gdb-python-ver-mm} < 3.8 does not work correctly because mathematically (floating point numbers) 3.13 < 3.8.