When you say you created a new Makefile, do you mean you used
CubeMX2Makefile? The following assumes that’s the case:
That tool is super hacky and very unreliable. It’s better than nothing, and was useful, but don’t trust it to just work xP. I would use
git diff to check which files got added by CubeMX, and just add them manually to the makefile.
Of course, feel free to dig into
CubeMX2Makefile and try to fix the problems; it would be very useful to many people if it was more reliable.