Don't rebuild core.a when not needed

As pointed out in #1991, the core.a file was always rebuilt, even when nothing about it changed. This fixes that by only rebuilding it when needed. Note that the .o files for the core were already reused, this concerns just the .a file.