build: Give internal libraries higher precedence

Linking local libraries too late may cause preinstalled libraries to
get found earlier, due to external library paths in .la files.

https://bugzilla.gnome.org/show_bug.cgi?id=712314